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

As I can see there are 2 places where GATEWAY option could be used in CentOS:

  1. /etc/sysconfig/network
  2. /etc/sysconfig/network-scripts/ifcfg-*

What is the right place for default gateway and what the difference?

share|improve this question
up vote 3 down vote accepted

The current convention is /etc/sysconfig/network-scripts/ifcfg-ethX.

That's how Red Hat's tools (e.g. system-config-network) are configuring things, and it helps with persistence as NICs change, etc.


This depends on how many interfaces you may have. Suppose you have two interfaces, eth0 and eth1, on the same subnet... What if I want the default gateway access to flow through eth0? I'd define it in the interface specification rather than the global /etc/sysconfig/network file. Of course, this can also be done in that file using the GATEWAYDEV directive...

share|improve this answer
Why is that current convention? I have always used "/etc/sysconfig/network". It seems logical, since a host should only have a single default gateway, and not a different one for each interface. That's what route-ethX would be used for. – jordanm Aug 15 '12 at 1:03
See updated answer. – ewwhite Aug 15 '12 at 1:20

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.