Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

In order to make the statically assigned IP work, I have already modified the file /etc/sysconfig/network-scripts/ifcfg-eth0 as follows:


Any other configuration files that I might need to take care of before the static IP could be used? I am trying to change the network settings from the default DHCP to static IP.

share|improve this question
up vote 2 down vote accepted

You may also need to set a default route (often known as your default gateway) in /etc/sysconfig/network-scripts/route-eth0 as follows:

default via

Just make sure you substitute the correct Default Gateway for otherwise Bad Things Will Happen... ;)

share|improve this answer
Thanks for your suggestion, but I can't find such a file as route-eth0 or alike in the directory. – Terry Li Jul 18 '11 at 20:11
You could add GATEWAY=x.x.x.x to ifcfg-eth0 to set a default gateway – katriel Jul 18 '11 at 20:34
I found from elsewhere that the DNS server also needs to be reconfigured, but haven't got an idea how to do it. – Terry Li Jul 19 '11 at 15:10
If the file doesn't exist, just create it. :) @katriel is correct that you can add the default gateway to ifcfg-eth0, however by putting it in the routes file you can add many more routes and view them all in one easy place. It also makes things easier to manage if you're using something such as puppet or chef. – Prof Falken Jul 20 '11 at 19:04

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.