Skip to content

Linux route command (route table)

The route command in Linux manipulates the kernel’s IP routing table. Its main use is to configure static routes to specified hosts or networks through an interface, after it has been configured with the ip program.

Everything that the route command does can be performed by the ip command.

If the route is used without any options, it displays the route table.

$ route <br></br>Kernel IP Routing Table <br></br>Destination Router MascarAgen. Metric Options Ref Use Iface <br></br>default ip-172-30-0-1.e 0.0.0.0 UG 0 0 0 eth0 <br></br>10.8.0.0 ip-10-8-0-2.ec2 255.255.255.0 UG & nbsp; 0 0 0 tun0 <br></br>ip-10-8-0-2.ec2 0.0.0.0 255.255.255 UH 0 0 0 tun0 <br></br>instance-data.e 0.0.0.0 255.255.255.255 UH 0 & nbsp; 0 0 eth0

The same information can be viewed with the ip command:

$ ip route show default via 172.30.0.1 dev eth0 10.8.0.0/24 via 10.8.0.2 dev tun0 dev tun0 proto kernel scope link src 10.8.0.1 169.254.169.254 dev eth0 172.30.0.0/24 dev eth0 proto kernel scope link src 172.30.0.46

The netstat -r command also lists the route table:

$ netstat -r
Kernel IP Routing Table
Destination Router MascarGen. MSS Options - Firtt Iface Window
default ip-172-30-0-1.e 0.0.0.0 UG 0 0 0 eth0
10.8.0.0 ip-10-8-0-2.ec2 255.255.255.0 UG 0 0 0 tun0
ip-10-8-0-2.ec2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
instance-data.e 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
172.30.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

In some distributions, the Net-Tools package containing the route command is not even installed as standard, the iproute2 package containing the “ip” command is preferred.