How to manage network interfaces on Ubuntu server 22.04 - Ubuntu Server 22.04

Team AApril 15th 2022, 3:34

First and foremost, we must learn how to analyze the current connection parameters that our server's network card is now employing to communicate with the outside world. The major goal of this section is to accomplish just that. This can be accomplished with two simple commands: ip (which is highly recommended) and ifconfig (which is optional) (which was the previous method).

Step 1. Using the ip command, we may inspect information about our network interfaces and manage them. If we want to know what our current IP address is, we may use the command ip addr show to find out:

ip addr show

Step 2. Consequently, you will get an output that looks something like what is seen in the screenshot below:

Step 3. You can even shorten the command to ip an if you want to be really efficient. The outcome will be the same regardless of the circumstances. In addition to the IP address (if any) and MAC addresses of each device, the output contains a variety of other useful information about the system.

ip a

Step 4. In addition, the ip command allows us to control the state of an interface. We can shut down a device (i.e. prevent it from connecting to networks) and then restart it with the following command:

sudo ip link set ens3 down
sudo ip link set ens3 up 

Step 5. The "ifconfig" command is part of the deprecated "net-tools" package of utilities (for the most part).

Step 6. The "net-tools" package is no longer installed by default in Ubuntu Server 22.04, although it is still available if you choose to manually install it.

sudo apt install net-tools

Step 7. When executed without any options, the ifconfig command shows information about your interfaces, similar to what we saw with ip addr show earlier in this tutorial. That appears to be a rather basic procedure.

Step 8. Second, similar to the ip instructions we practiced previously, we can use ifconfig to bring an interface down or up:

sudo ifconfig ens3 down
sudo ifconfig ens3 up

There are, of course, additional options and modifications to ip and ifconfig, so consult the man pages for either if you need more information.