Networking commands
suggest changeifconfig
The above command shows all active interfaces of the machine and also gives:
- the IP address assigned to the interface
- the MAC address of the interface
- the broadcast address
- transmit and receive byte counts
Some examples:
ifconfig -a
The above command also shows disabled interfaces.
ifconfig eth0
The above command shows only the eth0 interface.
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
The above command assigns the static IP to the eth0 interface.
ifup eth0
The above command enables the eth0 interface.
ifdown eth0
The above command disables the eth0 interface.
ping
The above command (Packet InterNet Groper) tests connectivity between two nodes.
ping -c2 8.8.8.8
The above command sends 2 ICMP echo requests (-c is a count, not a number of seconds) to 8.8.8.8.
traceroute
The above command is used in troubleshooting to find out how many hops are taken to reach the destination.
netstat
The above command (network statistics) gives connection information and connection states.
dig www.google.com
The above command (domain information groper) queries DNS-related information.
nslookup www.google.com
The above command queries DNS and finds the IP address for a host name.
route
The above command shows the network route information: the routing table.
route add default gw 192.168.1.1 eth0
The above command adds a default route for eth0 via 192.168.1.1.
route del default
The above command deletes the default route from the routing table.