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  


# route add default gw
Add Default Gateway
Add Default Gateway

Delete default gateway

To delete default gateway type following command:

# route del default gw 


# route del default gw

Add and deleting route to a host type

To add route to a host type enter following command:

# route add -host  gw


# route add -host gw

Route add
Deleting a route to a host, type:

# route del -host  gw


# route del -host gw

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.

Back to top button