Linux route command (route table) [Basic Guide]

Linux routing 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 
Kernel IP Routing Table
Destination Router MascarAgen. Metric Options Ref Use Iface
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 & nbsp; 0 0 0 tun0
ip-10-8-0-2.ec2 0.0.0.0 255.255.255 UH 0 0 0 tun0
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.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Need help?