Last Updated: January 15, 2018
· dmcrodrigues

Default gateway on CentOS


On CentOS you can check the routing table with:

$ route -n

The previous command prints a table like this:

Kernel IP routing table
Destination     Gateway        Genmask         Flags Metric Ref    Use Iface   U     0      0        0 eth0   U     0      0        0 eth1         UG    0      0        0 eth1

The last line of the table indicates the default gateway of the machine. In this case:         UG    0      0        0 eth1

Change default gateway

You can control default gateway using route command:

$ route del default gw <default_gateway_ip>
$ route add default gw <default_gateway_ip>

Keep in mind that this changes are only temporary. To change default gateway permanently you need to edit the file /etc/sysconfig/network and change to:


With multiple interfaces on the same subnet it's also possible designate the prefered route to the default gateway with:


1 Response
Add your response


THANK YOU A LOT OF AFTER hard seach in the web and thousand responses here I found the right answer
it works with me perfect ......

over 1 year ago ·