What is the order of precedence for RedHat network configuration files?

Solution 1:

Assuming configuration files resided in all three of these key directories, in which order are they evaluated for use, and are they on an atomic directory level, or does order take place for every individual file?

/etc/sysconfig/network-scripts/ is the only directory used. The proof is to start reading /etc/rc.d/init.d/network. Ignore /etc/sysconfig/networking/.

If you're curious about how the profile system is implemented see the updateNetworkScripts function in /usr/share/system-config-network/netconfpkg/NC_functions.py.

Basically it makes hardlinks of the ifcfg-* files in /etc/sysconfig/network-scripts/, /etc/sysconfig/networking/devices/, and /etc/sysconfig/networking/profiles/*.

E.g., given that you are in profile foo

  • /etc/sysconfig/network-scripts/ifcg-eth0
  • /etc/sysconfig/networking/devices/ifcg-eth0
  • /etc/sysconfig/networking/profiles/foo/ifcg-eth0

are all the same file.

P.S. I am an RHCE so what I say must be correct. ;)

Solution 2:

Firstly, i am not RHEL certified. :p

I have check against one of my RHEL 5.4 box:

1.During bootup or network service restart, it will use this startup script "/etc/init.d/network", which is a plain bash script that you can check it out in details yourself.

2.Two main things about the startup script:

a.It checks the existence of "/etc/sysconfig/network" before proceeding.

b.Then it change directory to "/etc/sysconfig/network-scripts", which means, this is the main directory it refers to and load the config file.

 16 if [ ! -f /etc/sysconfig/network ]; then
 17     exit 0
 18 fi
 19
 20 . /etc/sysconfig/network
 21
 22 if [ -f /etc/sysconfig/pcmcia ]; then
 23         . /etc/sysconfig/pcmcia
 24 fi
 25
 26
 27 # Check that networking is up.
 28 [ "${NETWORKING}" = "no" ] && exit 0
 29

 38
 39 CWD=`pwd`
 40 cd /etc/sysconfig/network-scripts
 41
 42 . ./network-functions
 43
 44 # find all the interfaces besides loopback.
 45 # ignore aliases, alternative configurations, and editor backup files
 46 interfaces=$(ls ifcfg* | \
 47             LANG=C sed -e "$__sed_discard_ignored_files" \
 48                        -e '/\(ifcfg-lo\|:\|ifcfg-.*-range\)/d' \
 49                        -e '/ifcfg-[A-Za-z0-9\._-]\+$/ { s/^ifcfg-//g;s/[0-9]/ &/}' | \
 50             LANG=C sort -k 1,1 -k 2n | \
 51             LANG=C sed 's/ //')
 52

3.About the other two directories or ultimately one "/etc/sysconfig/networking/", it has been warned in RHEL manual that it is a no fly zone. I believe when you use the "system-config-network", it will utimately copied the file over to the main directory as per 2(b).

4.If you need to be really really sure about it, you can browse through the developer python source code for "system-config-network" in "/usr/share/system-config-network". Which might point you back to (3) that the tool will finally copy or write the config file in "/etc/sysconfig/network-scripts".