What initiates parsing of the /etc/sysconfig/network-scripts/ifcfg-* interface scripts

ifconfiginitnetworking

I have been searching for a while and looking at source code and various scripts on the Linux filesystem and still have been unable to figure out what ultimately initiates the reading of the scripts for network interfaces (or other interfaces) in /etc/sysconfig/network-scripts/ that parses and grabs the basic parameters like IPADDR and assigns it to the interface.

The documentation from Redhat, for example, is not very specific:

Interface configuration files control the software interfaces for individual network devices. As the system boots, it uses these files to determine what interfaces to bring up and how to configure them. These files are usually named ifcfg-, where refers to the name of the device that the configuration file controls.

Very generally the "system" is said to read the files.

I do think that I've found one of the final programs in the chain of calls that parses those files and the parameters in them: /etc/sysconfig/network-scripts/ifup (which then calls other ifup-* scripts and executes various commands with the /sbin/ip binary and sets values under /sys/class/net/). But what calls that ifup script (which is a symbolic link to /sbin/ifup)? I started looking at udev but hit a dead end there. I used https://livegrep.com/search/linux to search the kernel code for references to those files and didn't find anything there either.

I basically would like to see a clear explanation of the chain of calls that lead to /etc/sysconfig/network-scripts/ifcfg-* scripts being parsed, starting from boot time.

Edit: Thanks to LinuxNinja for supplying the answer below. Following that answer I also found this similar post on the Unix SE site.

Best Answer

The service 'network' is where you want to start (/etc/init.d/network)

It sets interfaces=$(ls ifcfg*)

That is also piped to sed to do some other magic, but this is where the ifcfg* files are identified.

There is a for statement that goes through each of the found ifcfg files using the $interfaces variable and evaluates each one, calling ifup eth0 boot, for example.

Related Topic