Categories: Networking

Linux route command (route table) [Basic Guide]

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.

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.

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.