Networking

Kernel's ARP Table

Show the numerical addresses of the kernel's ARP cache

arp -n

# example of command output

Address HWtype HWaddress Flags Mask Iface

10.153.0.254 ether a2:01:00:00:00:12 C eth1

172.16.65.254 ether a2:01:00:00:00:06 C eth0

Send arp requests to a neighbour host (192.168.1.100 in the example)

# -c 2 : stop after sending two ARP REQUEST packets

# -U : Unsolicited ARP mode to update neighbours’ ARP caches.

# No replies are expected

# -I : Name of network device where to send ARP REQUEST packets

arping -c 2 -U -I eth0 192.168.1.100

Show, manipulate IP addresses

Show the list of the IPv4 addresses assigned to all the network interfaces

ip -4 addr list

Show the list of the IPv4 address(es) assigned to the eth0 interface only

ip -4 addr list dev eth0

Assign a VIP address to the interface bond0.29

ip addr add 10.6.173.56/26 broadcast 10.6.173.63 dev bond0.29 label bond0.29:0

Modify the network mask from /24 to /25 with minimal service disruption

# ping output in another console

64 bytes from 9.212.11.1: icmp_seq=1 ttl=255 time=0.449 ms

64 bytes from 9.212.11.1: icmp_seq=2 ttl=255 time=0.582 ms

64 bytes from 9.212.11.1: icmp_seq=3 ttl=255 time=0.614 ms

64 bytes from 9.212.11.1: icmp_seq=4 ttl=255 time=0.535 ms

64 bytes from 9.212.11.1: icmp_seq=5 ttl=255 time=0.430 ms

ip addr add dev eth0 9.212.11.37/24

ip addr del dev eth0 9.212.11.37/25

64 bytes from 9.212.11.1: icmp_seq=6 ttl=255 time=11.4 ms

64 bytes from 9.212.11.1: icmp_seq=7 ttl=255 time=0.627 ms

64 bytes from 9.212.11.1: icmp_seq=8 ttl=255 time=0.436 ms

Kernel Routing

In its simplest form, ip route can be used to display the main routing table output.

ip route show

Using ip route add to populate a routing table

ip route add 10.38.0.0/16 via 192.168.2.254

Setting the default route with ip route add default

ip route add default via 192.168.2.254