I have a CentOS running. It is important to have my CentOS available when I am remotely connected to a VPN router. I tried to add a default gateway to the VPN router, but after reboot it goes away. How can i put this as permanent?

ip route add via dev eth0

If i've read your question right, i think you want to add


into /etc/sysconfig/network then reboot or do service network restart to test it.

Although i'm not entirely sure from your question that you do actually want a default gateway at all. I think you may just want to make a static route permanent ?


If anyone is running CentOS with multiple NICs, only 1 is connected to the Internet and you want to make that particular interface to take all the Internet traffic, then add following line in to your /etc/sysconfig/network file:


Save and restart your network services. This worked for me and nothing else was working.


You may be able to add that line to the appropriate /etc/ifconfig.INT (where "INT" represents the appropriate interface), just like we do with dhclient sometimes (notice the leading explanation point inserted as the first character):

!ip route add via dev eth0

(I haven't tried CentOS, but I'm assuming this mechanism should essentially be the same as it is on NetBSD.)


Just realized, to add below to the /etc/sysconfig/network-scripts/route-your_interface_name doesn't work, must be on the ifcfg file:

default via x.x.x.x dev y

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.