Linux networking
Network interfaces
ifconfig
→ Display network interfaces
ifconfig eth0 192.168.2.1 netmask 255.255.255.0 up
→ Create an interface and bring it up
ifup eth0
→ Bring interface up
ifdown eth0
→ Bring interface down
ip link show
→ Show interface information for all interfaces
ip -s link show eth0
→ Show the statistics of an interface
ip address show
→ Show ip addresses allocated to interfaces
ip link set eth0 up
→ Bring interface up
ip link set eth0 down
→ Bring interface down
ip address add 192.168.1.1/24 dev eth0
→ Add an ip address to an interface
Route
sudo route add -net 192.168.2.1/23 gw 10.11.12.3
→ Add a new route
sudo route del -net 192.168.2.1/23
→ Delete a route
ip route add 192.168.2.1/23 via 10.11.12.3
→ Add route with ip command
ip route delete 192.168.2.1/23
→ Delete route with ip command
dhclient
sudo dhclient
→ Obtain a fresh ip
arp
arp
→ View arp cache
ip neighbour show
→ View arp cache with ip command
Troubleshooting
ping -c 3 [www.google.com](<http://www.google.com>)
→ Test whether or not a packet can reach a host and stop sending echo request packets after the count (3
) has been reached
traceroute [google.com](<http://google.com>)
→ See how packets are getting routed
sudo tcpdump -i wlan0
→ Capture packet data on an interface
netstat -anpt
→ Find out what services are listening for connection on the machine
sudo service network-manager restart
→ Restart the network manager
rfkill list
→ List wifi to see if its blocked or not
rfkill block 0
→ Block wifi interface
rfkill unblock 0
→ Unblock wifi interface
DNS
nslookup [www.google.com](<http://www.google.com>)
→ Query name servers to find information about resource records
dig [www.google.com](<http://www.google.com>)
→ Getting information about DNS name servers
Last updated
Was this helpful?