facebook youtube pinterest twitter reddit whatsapp instagram

Understanding & Managing Network Interfaces In Ubuntu

A network interface card is installed on every computer so that it can connect to a network. Without a network card, you can't use the network.

If your server's hardware has been properly configured, you should have one or more network interfaces available for you to use.

You can view the information regarding the interfaces in your server using the IP command, also, you can manage your interfaces with the IP command.

For example, to show your currently assigned IP address, you can either use ip aor ip addr show:

 ip a (show the current IP address

Both commands would show the above output, so, use the one you prefer.

If you look at the image carefully, you would see that it provides us useful information regarding the network interfaces and the IP address of each device.

The one you should be concern about is the enp0s3, which represents the wired network card (we would come back to the naming convention later), first, let's see how you bring down and bring up an interface.

To bring a device down, you use:

sudo ip link set enp0s3 down

This removes its IP assignment and prevents it from connecting to networks or the internet.

To bring up a device, you use:

sudo ip link set enp0s3 up

This brings up the network and allows connecting back to the internet, this is the same as toggling the state of the interface enp0s3; on & off, you get the idea!

If you are used to Ubuntu 16 and below, you will notice the naming convention is a little bit different, in Ubuntu 16, the network interface names are eth0, wlan0, and the likes.

The issue with that naming convention is that the names aren't predictable and aren't persistent between boots.

For example, if you add a second network card (which then becomes eth1; eth0 are the first network card, so, if you add a second one, it becomes eth1), it is likely your configuration breaks if names were to get switched during the next boot, this happens to me a lot, and it wasn't a nice thing at all.

To solve this issue, you use the udev to make the names stick, this way, the order won't get changed during the next boot. While you don't need this anymore in new the new version of Ubuntu (18.04 and above), it doesn't hurt to know how it works.

To do this, you open up the following configuration file:

/etc/udev/rules.d/70-persistent-net-rules

This would show the order in which the networks comes up, the card you recognize as eth1 will always be eth1 and the one you recognize as eth0 would always be eth0, An example from my older server:

2. 70-persistent-net.rules

You can see it is using the MAC address of the card to identify with the network interface cards, an illustration below:

illustration of how the configuration in 70-persistent-net rules made show the info sticks

You can see how it is connected, but even if you got this to work, it becomes a problem when you want to redeploy the image of the server onto another server.

When you restore the image onto another server, you will have to make changes to the 70-persistent-net-rules in order to reclaim the network interface cards. You delete the line that contains the card that's not on the system and then changing the device designation on the remaining line back to eth0 and eth1 respectively.

since you have a good understanding of how it works on older versions of Ubuntu, let's get back to the new naming convention.

The new naming convention references the physical location of the network card on your system's bus, meaning it can't change even if you boot a hundred times, it would only change unless you were to actually remove the network card and place it in a different slot on the system's board. if you are using a VPS, you have no problem with this too unless your VPS provider changes the position of the network device in the hypervisor.

This doesn't mean you can't use the old naming convention, you can decide to opt for that if you so wish.

Let's take a quick overview of how the network names break down in newer versions of Ubuntu (18.04 and above).

enp0s3
en means Ethernet
p0 means the interface card is placed in the system first bus, p stands for bus and the numbering starts at 0
s3 means PCI slot 3

Putting it all together, enp0s3 references a wired network interface cards on the system first bus, place in PCI slot 3.

Bottom line is that the new naming scheme is based on where the card is physically located, so, it can't change unless you aren't physically switching the position of the network cards.

See, you later!

Related Post(s)

  • Monitoring Multiple Log Files In RealTime With MultiTail (Ubuntu)

    Oh my... I really find scanning through the logs file time consuming, and painful. Luckily for me, I founded Multitail, which is an awesome, and powerful tool for not only browsing through several f

  • How To Find Files Using Locate in Ubuntu

    It's kind of frustrating when you are searching for a particular file, and you have no idea of how to find it, In this guide, I'll walk you through on two different ways you can find a file in your G

  • Managing MariaDB Databases (Ubuntu Server)

    In this guide, you'll learn how to manage MariaDB databases in your terminal, from connecting to the database server using the mariadb command, creating a database, removing (drop) database, and mana

  • Understanding the Linux Filesystem

    Understanding the filesystem is important if you want to know how data is stored and retrieved, but really, the term might be somewhat confusing in Linux, as it means two different things. A filesys

  • Viewing Disk Usage in Ubuntu

    There are several ways to view disk usage in your Linux system, and that is what we would be going over in this guide... Out of the box, Linux provides us the df command, which is the standard Unix c

  • Understanding & Using Symbolic & Hard Links (Ubuntu)

    Have you ever wondered how you can create shortcuts that link to other files in Linux? Well, let me introduce you to symbolic and hard links. The two types of links in Linux are symbolic links and ha