Internet

Install the ifconfig and route tool on your Debian machine

What are ifconfig and route in Debian?

We are sure that you have ever had to use the ifconfig tool to configure a network interface, either to drop the interface or lift it, to change the IP address and mask assigned to us by the DHCP server of the main router, and even to create subinterfaces among many other features. Ifconfig has always been the tool par excellence both in Debian operating systems and in other Linux-based distributions.

The same happens with the command «route», the tool par excellence to add static routes to our server or PC, to remove the static routes previously added, route is also used to configure the default gateway and to delete it from the system, for Of course, we can also see the current routing table and prioritize different routes over others.

Both tools, both ifconfig and router, are essential to manage the network correctly in any Linux operating system, and we are sure that many of you have used them both on the command line and also in your scripts to automate different actions.

Why are they not included since Debian 9 by default?

Although the two tools are essential for good network management, for many years we have had the iproute2 tool in all Linux-based operating systems. This suite of tools will allow us to manage network interfaces, static routes, the default gateway, and we can even configure various routing tables in our Linux-based operating system, and, of course, also in Debian.

For many years ifconfig and route have been considered “deprecated”, that is, old. However, many network administrators were still using it, and for this reason it was not started to be phased out from different Linux-based distributions. After several years of administrators using iproute2, it was decided that both ifconfig and router would not be incorporated into the operating system by default.

We must bear in mind that iproute is a much better, more complete, more intuitive tool because the commands are very similar to Cisco syntax, and we will be able to perform advanced configurations such as configuring several routing tables and several default gateways.

If in a Linux-based operating system we try to execute “ifconfig” or “route”, it will automatically return an error. Starting with the Debian 9 version, you must install it manually, and if you use other Linux distributions in their latest versions, exactly the same thing happens, we must install it in order to use it.

Once we have verified that in Debian 9 and later versions it is not installed by default, we are going to do it manually. There is still third-party software that internally uses automatic scripts for the installation of their software, these scripts still usually use ifconfig and route, so it is absolutely necessary to have these tools installed if we want to execute these scripts correctly and that they do not return any type of error.

Ifconfig and route installation on Debian 9 or higher

Installing the old suite of ifconfig and route networking tools is really simple, the first thing we have to do is open a terminal, log in in root mode or use the “sudo” command, and install a package called “net-tools” . This package integrates all the “old” tools that we have been using for many years. If in the installation we have chosen to do “sudo” to promote superuser to install packages, we type:

sudo apt install net-tools

If we have incorporated a superuser password, we must put «su» in the console to promote superuser and then type:

apt install net-tools

When we have installed it, if we execute ifconfig we will get the interface configuration summary:

This ifconfig command can be used together with the typical iproute2 commands such as “ip link show” or “ip addr show”, there is no problem of using both tools simultaneously. However, certain changes we make with iproute2 may not be reflected if we use ifconfig to display data.

Another important change in Debian 9 or higher is that the names eth0, eth1 and ethX no longer exist on Ethernet network interfaces. Now it is a random name and it looks like “ens32”, “ens33” or similar, however, when executing the “ip addr show” or the “ifconfig” we can see the name of our network interface without problems. Another command you can run is the following to see the name:

dmesg | grep -i eth

Of course, with the installation of «net-tools» we will also have at our disposal the «route» command to view and configure the static routes and the default gateway of the operating system. The commands that we must execute to add or delete static routes are the same as always, the same happens if we want to set the default gateway, in these cases nothing has changed.

In the following screenshot you can see that the operation of this command is now perfect, since it works correctly.

If you missed the possibility of using ifconfig or route in your operating system, thanks to the installation of “net-tools” you will be able to use it again without problems with the same commands as always. From RedesZone we recommend using iproute2 because it is much more complete, efficient, fast and current, in addition, we have a complete tutorial where you can learn all the commands that can be executed. We must not forget that the new iproute2 allows us to configure several routing tables, ideal for having several gateways in the event that you have several network interfaces on your computer or server.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *