Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 192.168.2.3 via 10.0.0.1 dev eth0
share|improve this question
up vote 2 down vote accepted

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

GATEWAY=192.168.2.3

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 ?

share|improve this answer
1  
I want to make 192.168.2.1/24 subnet route permanent. – YumYumYum Aug 9 '11 at 13:14
2  
ok. add a route-eth0 file in /etc/sysconfig/network-scripts, as outlined here: linuxquestions.org/questions/linux-networking-3/… – Sirex Aug 9 '11 at 13:44

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:

GATEWAYDEV=network_interface
GATEWAY=default_gateway_ip

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

share|improve this answer

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 192.168.2.3 via 10.0.0.1 dev eth0

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .