Naming the network device

Nowadays, it's not uncommon for a computer to have multiple network interfaces. For example, if you're using a laptop (other than an Ultrabook), it's likely that you have a wired, as well as a wireless, network interface. Each network interface will have its own IP address and they operate independently of each other. In fact, you can even route traffic between multiple interfaces, though this is typically disabled by default in most Linux distributions. Just like each interface has its own IP address, each will also be identified by the system by its own device name. Before we discuss this further, go ahead and take a look at the device names on your system. Open up a terminal and type the following command:

ip addr show

Your output will look like this:

Naming the network device

The output of the ip command, showing network interfaces and address assignments

In this example, we see three network interfaces listed. The first, lo, is the local loopback adapter. The second listing, eth0, is the wired interface. Finally, wlan0 represents the wireless interface. Given this output, you can deduce that there is a network cable plugged in (eth0 has an IP address) and it is not currently utilizing its wireless interface (there is no IP address listed for wlan0).

The output shown previously was taken from a system running Debian. Now, let's take a look at the output of the same command when run on a CentOS system:

Naming the network device

The output of the ip command, this time run from a CentOS system

Do you see the difference? If you look at the wired connection, you can tell that it's named quite differently than the wired connection from the Debian example. With Debian, it was named eth0. But on CentOS, it was named enp0s3. This brings us to the point of this section: network devices are named differently in CentOS and Debian.

In the past, wired ethernet devices were named beginning with the prefix of eth, and wireless devices were prefixed with wlan. For example, the first wired ethernet adapter would be labeled eth0; the second would be eth1, and so on. Wireless devices were handled similarly as well, with the first device being wlan0, the second would be wlan1, and so on. With Debian, this is still the case (even in newer releases). However, some distributions that utilize systemd feature a different naming scheme for network devices. In fact, Debian 9 will change its naming scheme for interfaces once it's released.

The reason for this change is because the previous naming scheme was at times unpredictable. It was possible to have network device names cross when a machine was rebooted, causing confusion as to which interface is which. The various distributions deal with this problem in their own way, but systemd has a built in naming scheme that is based on the position of the card in the system's bus, rather than just using the names eth0, eth1, and so on as the devices are probed. As mentioned before, Debian still utilizes the older naming scheme, despite the fact that Debian 8 also utilizes systemd. Throughout this book, we will practice systemd commands; however, systemd will be explained more thoroughly in Chapter 5, Monitoring System Resources, so don't worry too much if you aren't aware of how it works just yet.

For the CentOS machine used in the second example, the wired network card was given the designation of enp0s3. So, what exactly does this mean? First of all, we know that en represents ethernet, and this part of the designation is given to wired network cards. The rest of the given name represents the position of the network card on the bus of the system. Since each wired card, if you had more than one, would reside in its own physical position, the name given to the device would be predictable. If you were to write startup scripts for a specific network interface, you can be reasonably certain that you'd be writing the script to reference the appropriate device.