Home » Random Goodies » Out of network gateway IP on CentOS

Out of network gateway IP on CentOS

I recently noticed that CentOS will refuse to assign an out of network gateway IP. Even though your network scripts syntax may be correct, it will still refuse to work no matter how many times you restart your network 🙂

Assuming your configuration is:

Device: eth0

The default gateway route will have to be created as follows:

route add -host dev eth0
route add default dev eth0 gw

Now to have eth0 use as the gateway on boot, you would have to add the above lines to:


This was tested on a CentOS 6.3 x86_64 Virtual Machine using ESXi 5.0 😀