Server Fault is a question and answer site for system and network administrators. 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 type the "neat" command (CentOS) A network configuration pop-up window is displayed. I double click on active eth1 And I change the Default gaeway address

Is there anyway to automate this?

share|improve this question
up vote 2 down vote accepted

You can use the two commands below

route del default # This removes the current default gateway
route add default gw "ipaddress" # This adds the new default gateway

This way you do not even have to restart the network.

share|improve this answer
these changes will vanish after restart of the system. – Christian Jan 16 '10 at 11:48

the gateway is saved in the file /etc/sysconfig/network. in the file you'll find an entry GATEWAY=a.b.c.d. you could change this with:

sed -i -e 's/ol\.d\.i\.p/ne\.w\.i\.p/' /etc/sysconfig/network
share|improve this answer
Don't forget to either manually remove/replace the old entry, or do a 'service network restart', or 'reboot', to have the change take effect. Just changing the config files doesn't translate into an immediate change. – David Mackintosh Jan 15 '10 at 17:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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