In this step, you will begin by installing ethtool, a crucial command-line utility for examining and modifying network interface controller parameters. After ensuring the tool is available, you will learn how to identify the name of the primary network interface on your system, which is a prerequisite for any further network analysis.
First, let's update the package list and install ethtool. It's a good practice to run apt update before installing new packages to ensure you are getting the latest available versions from the repositories.
Open a terminal, which should already be open in your ~/project directory. Execute the following commands:
sudo apt update
sudo apt install ethtool -y
The -y flag automatically answers "yes" to the installation prompt, making the process non-interactive. You should see output indicating that the package lists are being read and ethtool is being installed.
Now that ethtool is installed, you need to determine which network interface you want to examine. A system can have multiple interfaces, such as a loopback interface (lo), a wired Ethernet interface (eth0 or enp0s3), and others. The ip command is the modern standard for displaying and manipulating network devices, addresses, and routes.
To list all network interfaces and their configurations, use the ip a command (a shorthand for ip addr):
ip a
You will see a list of all network interfaces. Look for an interface that is not lo (the loopback interface) and has a state of UP. This is typically your primary network connection. The name is usually eth0 or a name starting with enp.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:16:3e:01:b1:ae brd ff:ff:ff:ff:ff:ff
altname enp0s5
altname ens5
inet 172.16.50.232/24 metric 100 brd 172.16.50.255 scope global dynamic eth0
valid_lft 1892159922sec preferred_lft 1892159922sec
inet6 fe80::216:3eff:fe01:b1ae/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:da:5e:55:d4 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
From the example output above, the primary network interface name is eth0. You may also see other interfaces like docker0, but for this lab, we will focus on eth0. Make a note of your interface name, as you will need it in the following steps. You have now successfully installed the necessary tool and identified your target network interface.