I've noticed that by default the below line is included in
What is the purpose of this line and what does it actually do?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
From the Ubuntu interfaces man page:
Lines beginning with "source" are used to include stanzas from other files, so configuration can be split into many files. The word "source" is followed by the path of file to be sourced. Shell wildcards can be used. Currently only supports absolute path names.
source command is the textual version of the
. (source) syntax. This allows you to include / import code from one file and merge it into a parent. However, what is not clear from a base install of Ubuntu 16.04 is why the
source line would be first. Meaning, if one wanted to use a static IP for interface
enp0s3 below, does that mean I must first comment out / erase the
iface line for
The file and file.d scheme is pretty common. If you run the Apache HTTP Server, you have probably seen the apache24/conf/httpd.conf and it's side kick the extra/ directory, that contains more *.conf files (typically httpd-ssl.conf, httpd-vhosts.conf, php.conf, httpd-default.conf, and more). In this case, shell scripts are not being included, but the principle is basically the same.
1. Separation of concerns.
It is better to mess up only one interface configuration up, then do something that might affect more than one interface. By keeping things separate, it actually makes it easier to write shell scripts that automate stuff.
Instead of sifting through
awkfor the correct interface, you can simply target the correct file in
/etc/network/interfaces.d/ with basic file globbing.
By keeping things separate, your chances of messing things up are reduced dramatically.
2. Better organization in the long run.
If you think about what interfaces.d/ holds, it holds "instances" of network interface configurations (which can get rather elaborate). In that way, the time saved from having to scroll may make interfaces.d/ the way to go.
Are you planning a professional setup? Use
/etc/network/interfaces.d/ to hold the configurations of your network interfaces (one file per interface).
Are you a hobbyist using Linux in your basement (on a computer with one interface) and could care less about making life easier for someone else? Use
/etc/network/interfaces and go on with your life. Comment out the default configuration settings, or remove them altogether.
Remember, though the man page for interfaces says that interface configuration commands are cumulative allowing for multiple protocols and multiple IP addresses (v4 and v6) on each interface. At the end of the day, YOU decide what goes into
/etc/network/interfaces. Like the default loop back configuration? Dump the configuration into a file and put it into
Now, do the same for any other default install interface settings.
Leave a note in
/etc/network/interfaces that this says "This file is not to be used to alter interface configurations! Look in /etc/network/interfaces.d for the correct interface file.
Name the files in
/etc/netowork/interfaces.d/ with a similar convention. Red Hat systems use an interface file prefix convention of ifcfg-.
Thus, I might go ahead and use that convention in
/etc/network/interfaces/d, absent guidance.