Linux route Command: Viewing and Configuring the IP Routing Table
The route command on Linux manipulates the kernel's IP routing table. Its main purpose is to configure static routes for specified hosts or networks through an interface, after it has been configured with the ip program.
Everything the route command does can be accomplished with the ip command.
If route is used without any options, it displays the routing table.
$ routeTabela de Roteamento IP do KernelDestino Roteador MáscaraGen. Opções Métrica Ref Uso Ifacedefault ip-172-30-0-1.e 0.0.0.0 UG 0 0 0 eth010.8.0.0 ip-10-8-0-2.ec2 255.255.255.0 UG 0 0 0 tun0ip-10-8-0-2.ec2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0instance-data.e 0.0.0.0 255.255.255.255 UH 0 0 0 eth0172.30.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
The same information can be viewed with the ip command:
$ ip route showdefault via 172.30.0.1 dev eth0 10.8.0.0/24 via 10.8.0.2 dev tun0 10.8.0.2 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 routing table:
$ netstat -r
Tabela de Roteamento IP do Kernel
Destino Roteador MáscaraGen. Opções MSS Janela irtt 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 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
On some distributions, the Net-Tools package containing the route command is not even installed by default, with preference given to the iproute2 package containing the "ip" command.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, simply sign in or create your user here. Check out our content with all the main commands in Linux.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.