infoLinux

route Command in Linux

The Unix or Linux route command displays and manipulate IP routing table for your system.

Linux router is a device which is basically used to determine the best way to route packets to a destination.

Sample syntax of route :

$ route

After running the command and see your command, it displays all existing routing table entries on our system.

It shows that if the destination is within the network range of 000.000.000.000 to 000.000.000.000, then the gateway is *, which is 000.000.000.000.

It is a special address which represents an invalid or non-existent destination.

Which are not within this IP range packets and it will be forwarded to default gateway, which further routes the packet

Displaying numerical IP address

So this command displays output in full numerical form.

Like syntax of numerical IP address :

# route -n

See your terminal after running the command, the numerical IP address is display.

Adding a default gateway

The network packets that are not within the network range are forward to the gateway. Now we can specify the gateway with the following command.

Sample syntax of default gateway :

# route add default gw <IP address>

Routing cache information

The Unix and Linux kernel maintains a routing cache table to route the packets faster. To list this information, use the following command.

Like syntax of cache information :

# route -Cn

Leave a Reply

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