Network interfaces are essential components in Linux systems that facilitate communication between the computer and external networks, including the internet and local area networks (LANs).
To ensure reliable connectivity and optimize performance, it is crucial to know how to view and configure these interfaces. Linux offers several commands and configuration methods—ranging from command-line utilities to editing configuration files and using network managers—that empower users to manage network settings efficiently.
Viewing Network Interfaces
Knowing the status and details of network interfaces is the first step in network configuration and troubleshooting.
1. ip addr show or ip a
Displays all network interfaces with detailed information, including IP addresses, MAC addresses, and connection states.
ip addr show2. ifconfig (deprecated but still widely used)
Shows interface configurations and statistics.
ifconfig -a3. nmcli device status
Shows network devices status managed by NetworkManager.
4. Listing interface names:
ls /sys/class/net5. Other commands:
ethtool eth0 to show and configure physical device parameters.
ip link show to list interfaces with statuses.
The following are common methods used to configure network interfaces in Linux. They include both modern and legacy command-line tools.
1. Using ip Command (Modern Standard)
sudo ip addr add 192.168.1.100/24 dev eth0sudo ip addr del 192.168.1.100/24 dev eth0sudo ip link set eth0 up
sudo ip link set eth0 down2. Using ifconfig Command (Legacy)
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0sudo ifconfig eth0 up
sudo ifconfig eth0 downPersistent Configuration via Configuration Files
On Debian/Ubuntu: Modify /etc/network/interfaces with entries such as:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1On Red Hat/CentOS: Configuration files reside in /etc/sysconfig/network-scripts/ifcfg-eth0.
Example static IP configuration includes:
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yesAfter configuration, restart the network service:
sudo systemctl restart NetworkManageror
sudo systemctl restart networkUsing Network Manager Tools
nmcli is the command-line tool for NetworkManager.
nmcli device statusnmcli device wifi connect SSID password PASSWORD1. Check interface status:
ip link show eth02. View routing table:
ip route show3. Display DNS settings:
cat /etc/resolv.conf