CentosLinux

How to use route command on RHEL/CentOS Linux

Route manipulates the kernel’s IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig(8) program.
When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.
In this article we will show you how to use the route command to add/delete default gateway, add/delete a route with a temporary way, it means that the changes will be lost if the system is shutdown or reboot.

Add default gateway

To add default gateway to route table use following command:

# route add default gw  

Example:

# route add default gw 192.168.1.1
Add Default Gateway
Add Default Gateway

Delete default gateway


To delete default gateway type following command:

# route del default gw 

Example:

# route del default gw 192.168.1.1

Add and deleting route to a host type

To add route to a host type enter following command:

# route add -host  gw

Example:

# route add -host 192.168.1.100 gw 192.168.1.2

Route add
Deleting a route to a host, type:

# route del -host  gw

Example:

# route del -host 192.168.1.100 gw 192.168.1.2

For more information about route command ask a question in the comments.

One Comment

Leave a Reply

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.

Close