What and why is /dev/.sysconfig/network?

I’ve been fiddling with my network configuration, and discovered that removing form /etc/sysconfig/network did not remove the device from the environment when the network services were restarted. That is to say,

# ifconfig -a

still showed the device. It did not show with a simple

# ifconfig

.

# cd /etc;grep -r wlp3s0 *;cd -

found nothing under /etc. I got frustrated and took out the sledge hammer with

# cd /;grep -r wlp3s0 *;cd -

. That found a sneaky little directory called /dev/.sysconfig/network/.

Where did that come from? How long has it been part of Linux? Why is it there? What uses it?

I’ve never noticed it before, but that doesn’t mean it hasn’t been lurking in the darkness for all these years. Putting configuration in hidden directories under /dev seems contrary to the principle of least astonishment, and downright Microsoftish. Perhaps there is a good reason for this, but I can’t see it.

As I recall it’s been there for years and years as a workaround for a problem with /dev/shm related to network card initialization but I can’t seem to find the Bugzilla entry for it right now.

It’s the standard file in all distros (I’m aware of) which contain the Network Device properties.

So, for instance when I clone (make and exact copy of the machine), aside from the usual requirements for a unique IP address I always modify this file to give the machine a unique machine name on the network.

Or, in openSUSE you can modify this file in your YAST > Network Devices

TSU

That is the kind of configuration that properly belongs in /etc. Once upon a time, it was kept in

http://www.pathname.com/fhs/pub/fhs-2.3.html#ETCHOSTSPECIFICSYSTEMCONFIGURATION

Filesystem Hierarchy Standard…
/etc : Host-specific system configurationPurposeThe /etc hierarchy contains configuration files. A “configuration file” is a local file used to control the operation of a program; it must be static and cannot be an executable binary.

Apparently there is no standard configuration file where the hostname is expected to be defined. One traditional location was /etc/hosts. I seem to recall having to change it in more than one place on ancient Solaris systems. OS13.1 has /etc/HOSTNAME. In my case it has domain.hostname which seems a bit amis, but the system is working.

I guess the introduction of DHCP made such configurations more complicated.

Believe you’re confusing the usage of /etc/hosts and /etc/sysconfig/network

/etc/hosts is the file used for local Host Name Resolution. Not for declaring the machine’s Hostname, it’s for <resolving> Hostnames.

/etc/sysconfig/network is used for <declaring> the machines Hostname. It won’t work for hostname resolution. It might not even match what machines on the network might use to identify your machine. But, in any case your declared name should still be unique.

The difference is…
If you configure functionality like a service or app that needs to connect to a machine (local or remote) by networking, unless you wish to connect by IP address or MAC address, you need to <resolve> the name of the machine you wish to connect to. So a lookup is performed in /etc/hosts and if no matching entry is found then a query is issued to the configured DNS.

On the other hand, when your machine boots up on your network, you want to advertise to all the other Hosts on your network who your machine is, and this is the name in /etc/sysconfig/network. NOTE that although this is the name your machine wants to be known as, it’s not necessarily the same name used by other machines to connect to your machine. Name resolution on other machines and DNS may reference your IP address with a different hostname, and in most cases it doesn’t make any difference. The only thing that matters is that machines know how to contact your machine and utilize the offered functionality(typically a network service).

Getting partly off-topic while still on, a well known and used example of multiple hostnames pointing to the same IP address is when you configure multiple websites that share the same IP address. Each website is configured with different host headers often related to the web domain name so that an http request is directed to the correct website.

I’ve never paid any attention to the file you discovered /dev/.sysconfig/network and have never seen anyone reference it as something important. It’s probably something temporary and transient.

And, DHCP has nothing to do with hostnames. DHCP deals exclusively with mapping MAC addresses to IP addresses. The closest it might come to any kind of name resolution is distributing a hosts or lmhosts file to clients, but still does not use the contents of the files in any way.

HTH,
TSU

On 2014-07-26 18:06, hattons wrote:

> . That found a sneaky little directory called
> -/dev/.sysconfig/network/-.
>
> Where did that come from? How long has it been part of Linux? Why is
> it there? What uses it?

It is there because /dev/ is a volatile directory, dynamic. It was the
first one commonly available. Perhaps now a better place now could be
“/run”.

Look:


minas-tirith:~ # l /dev/.udev
lrwxrwxrwx 1 root root 9 Jul 23 20:06 /dev/.udev -> /run/udev/

This one has been moved over to the correct place. But as programs still
remember the older location, they had to symlink it… (guessing).


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))