When running a linux machine, it is beneficial to have a basic understanding of networking tools for configuring or inspecting various settings. This post will go through several linux utilities for configuring network equipment.
Network Interfaces
It is the connection between a computer and a network. To put it simply, it links up the network side of the software to the hardware side. There are basically two types of network interfaces in a linux system: physical interfaces and virtual interfaces. A network hardware device, such as a modem, NIC (Network Interface Card), or WNIC (Wireless Network Interface Card), is represented by a physical network interface. On the other hand, a virtual interface is linked to network devices, not to a hardware device.
Let’s check the network interfaces available on your system by running the command below.
$ ls /sys/class/net
In my system, there are two network interfaces available and they are lo and wlo1. The lo (loopback interface) is a special interface that is used by the system to communicate with itself. And the wlo1 is a wireless network interface (NIC). To view more information about these interfaces run the command below.
$ ifconfig -a
A great chunk of information is shown in the terminal which is discussed below.
- UP/DOWN: Interfaces can be in two modes UP or DOWN. If you want to turn off an interface, you have to down the interface.
- BROADCAST: Refers to the point that the network is configured to handle broadcast packets which is vital to get the IP address.
- RUNNING: This means that the network is ready to accept data.
- mtu: stands for maximum transmission unit. If IP datagrams are larger than MTU bytes, they will be divided into multiple Ethernet frames.
- inet: it is the IPv4 IP address of the interface.
- inet6: it is the IPv6 IP address of the interface.
- MULTICAST: it refers to an interface supporting multicasting.
- RX packets: number of the received data packets by the interface.
- RX errors: shows the total number of packets received with an error.
- RX dropped: Several packets are dropped as a result of unwanted VLAN tagging or receiving IPv6 frames on an interface that isn’t set up for IPv6.
- RX overruns: Several received packets encountered FIFO overruns as a result of the speed at which a buffer fills up and the kernel’s inability to clear it.
For transmission (TX), TX packets, TX errors, TX dropped, and TX overruns represent similar things as RX.
To turn up or turn down an interface,
$ ifup [interface name]
$ ifdown [interface name]
If these commands are not found on your system, you have installed the ifupdown
package which can be done using the following command.
$ sudo apt install ifupdown
You can also achieve this stuff using the ip
command. Some basic commands are listed below. To view the available interfaces,
$ ip link
To view the IP addresses of the interface,
To turn on or off an interface,
$ ip link set [interface name] up
$ ip link set [interface name] down
Network Manager
It configures your network automatically. It would be extremely inconvenient for users if they had to set up the system every time they booted it. It is in charge of the network hardware. After starting, the system looks for and activates any accessible wired or wireless network for hardware. There is an excellent tool named nmclient
. Run it in the terminal.
$ nmclient
wlo1: connected to Sabre_5G
"Realtek RTL8821CE"
wifi (rtw_8821ce), DC:F5:05:DB:3F:2F, hw, mtu 1500
ip4 default
inet4 192.168.0.115/24
route4 0.0.0.0/0
route4 192.168.0.0/24
route4 169.254.0.0/16
route4 0.0.0.0/0
inet6 fe80::94a8:1899:827e:60c/64
route6 fe80::/64
lo: unmanaged
"lo"
loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536
DNS configuration:
servers: 118.179.223.130 202.4.96.6
interface: wlo1
Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.
Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.
Find MAC Address
In computer networking, ARP stands for address resolution protocol. The main goal of the ARP is to find out the MAC address of a device associated with a specific IP address. There is a tool in linux named arp
which performs the job for us. Just run the command.
$ arp -n
When you run the command, it looks in the ARP cache. HWaddress is a MAC address associated with the IP address. There are options that be passed with the command. Some basic options are listed below.
-n
: it shows the numeric format of the addresses instead of names or symbols-v
: shows the verbose information.-d
: it deletes the specified MAC address from the arp cache. Be careful in terms of running this command. You may delete your primary network connection. In that case, you have to reboot the system.
There is another tool for this action named ip neigh
which shows the information similar to the arp
command. The reason for using ip neigh
is that the arp command is now close to depreciation and many of the dependencies of arp
are now obsolete. But arp command still maintains its popularity. Let’s run the ip neigh
command below and check its output.
$ ip neigh