# lsdev –Cc adapter
# lsdev –Cc if
Where If stands for the Interface.
This command will check how many interfaces are available.
Each adapter will have 2 interfaces.
For eg:
Ent0 adapter will have 2 interfaces:
En0
Et0
En0 is a standard Ethernet interface used in assigning ip addresses.
Et0 is used basically in IEEE as Ethernet interface.
Ip is never assigned directly to the adapter.
To assign an ip, command used is:
# ifconfig en0 <ip address> <network address>
To check current ip address, command used is:
# ifconfig –a
254 ip addresses can be assigned to a single interface.
Eg to assign an ip to an interface is:
# ifconfig en0 192.168.0.1 255.255.255.0
i.e.
# ifconfig en0 <ip address> <subnet mask>
When do we use ‘ALIAS’?
Consider the following command:
# ifconfig en0 <ip address> <subnet mask> alias
What is the function of ‘alias’ here?
Alias is basically used to assign more than 1 ip address to a single interface.
For eg:
# ifconfig en0 192.168.0.2 255.255.255.0 alias
This command will assign 2 ip addresses to a single interface en0.
If no ‘alias’ is used:
# ifconfig en0 192.168.0.2 255.255.255.0
This command will replace the earlier ip address for the interface en0 with a new ip address.
So, by using ‘alias’, we can assign 255 ip addresses to a single interface.
Command to delete an ip address from an interface:
# ifconfig en0 192.168.0.2 255.255.255.0 delete
This command will delete this particular ip address from en0 interface.
# ifconfig en0 down
This command will turn off network interface en0.
To permanently add an ip address to en0 or en1 interface, command used is:
# chdev –EH –l en0 –a netaddr = <ip address> -a <subnet mask>
For eg:
# chdev –EH –l en0 –a netaddr = 192.168.0.1 –a 255.255.255.0
To permanently add alias to the interface, command used is:
# chdev –EH –l en0 –a alias = <ip address> -a <subnet mask>
For eg:
# chdev –EH –l en0 –a alias = 192.168.0.2 –a 255.255.255.0
To permanently remove added alias from the interface, command used is:
# chdev –EH –l en0 –a delalias = <ip address> -a <subnet mask>
For eg:
# chdev –EH –l en0 –a delalias = 192.168.0.2 –a 255.255.255.0
To remove all tcp / ip configuration from host, command used is:
# rmtcpip
One can see ent0 statistics by running the following command:
# netstat –v ent0 | more
To add gateway:
A gateway is basically added to connect intranet to internet i.e. to connect your home/private network to the internet.
To add a gateway, command used is:
# route add –net <destination network ip address> <default gateway>
To check gateway, command used is:
# netstat –r
To delete a gateway, command used is:
# route delete <destionation network ip address> <default gateway>
To add / make STATIC gateway:
Edit the file /etc/rc.net by running the following command:
# vi /etc/rc.net
Add the following line:
# route add –net <ip address> <subnet mask> -a <gateway>
# route
Command will make manual entries in routing table till the next reboot.
To check the routing table which has gateway information, command used is:
# netstat –rn
To check MAC address of a particular Ethernet interface, command used is:
# entstat en0
Or
# netstat –i
This command will check incoming/outgoing network packet errors.
Ip packets can be captured using iptrace or tcpdump or netstat –in command.
To listen / capture packets from a specific device, command used is:
# tcpdump –I en0 –n <filename where information will be stored> <destination ip address>
Only the root user can run this command.
Arp stands for address resolution protocol.
arp command displays and modifies address resolution.
# arp –a
Command will display local arp cache.
Nslookup command always query internet domain name servers.
Tracert (traceroute) command displays route that ip packets takes to network hosts. For eg:
# tracert google.com
Comments