3

Different Linux distributions store the same configuration parameters in different files. For example IPv4 address in Debian Wheezy is stored in /etc/network/interfaces file while in Fedora 20 it is stored in /etc/sysconfig/network-scripts/ifcfg-eth0 file. In addition, syntax of those configuration files is different. How do distributions parse those files? In addition, is the content of configuration files parsed in a way that userspace utilities like ip and ifconfig are called or are there some lower-level system calls which actually configure the kernel?

3

The kernel doesn't read any configuration file. As a rule, kernels avoid accessing the filesystem; there are a few exceptions and variation, but mainly, the kernel launches a program at the location /sbin/init when it boots, and the only accesses filesystems on behalf of user land processes.

Network configuration files (like other kinds of configuration files) are read by applications. For the network configuration files, these applications are suites of scripts and accompanying binaries that read the file and apply the configuration by making system calls. For network configuration on Linux, the system calls are mostly ioctl calls on sockets (you don't need to understand this).

Over the history of Linux (and Unix before it), some configurations have become standard, because everybody agreed on how to do it. This is largely the case (though not universal) for users (/etc/passwd, NSSwitch) and filesystems (fstab). On the other hand, network configuration has remained pretty diverse. Distributions derived from Red Hat keep it under /etc/sysconfig/network; distributions derived from Debian keep it in /etc/network/interfaces.

Going with Debian as an example, /etc/network/interfaces is parsed by the ifup program, which is invoked from /etc/init.d/networking, the init script in charge of setting up networking, itself invoked by init.

  • linux kernels launch init at boot by default. /sbin/init is often later execed by init. – mikeserv Sep 4 '14 at 4:51
  • @Gilles Thank you very much for this explanation! So in case of Debian it is the /sbin/ifup binary which understands the /etc/network/interfaces file and creates system calls accordingly? And for example it's some other binary which parses the /etc/sysconfig/network-scripts/ifcfg-eth0 file under Fedora and creates appropriate system calls? And usually users create those very same system calls with ip or ifconfig utility? Same principle probably applies for all the configuration files not just for network related configuration? – Martin Sep 8 '14 at 11:21
  • 1
    @Martin Yes, that's correct. – Gilles Sep 8 '14 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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