commands.page Website Logo

  • Home
  • Categories
  • Search

Network Interfaces Available on the Terminal in Ubuntu

This is an article about the network interfaces that are available for monitoring and configuration through the terminal environment in Ubuntu. In this article, you will find detailed information on how to view, manage, and troubleshoot these interfaces using command-line tools. Read this article to find out how to take full advantage of your system’s networking capabilities from within the terminal.

Overview of Network Interfaces

Network interfaces are hardware or software components that allow a computer to communicate with other devices over a network. In Ubuntu, you can manage these interfaces directly through the terminal using various commands and utilities. The types of network interfaces commonly found in an Ubuntu environment include:

  • Ethernet: Wired connections
  • Wi-Fi: Wireless networking
  • Bluetooth: Short-range wireless communications for devices like keyboards or mice
  • Modem: For internet access via dial-up or mobile networks

For this article, we will focus primarily on Ethernet and Wi-Fi interfaces as these are the most commonly used types in a typical Ubuntu system. We’ll explore how to identify which network interfaces are present, their status, configuration details, and how to troubleshoot common issues.

Using ifconfig Command

The ifconfig command is one of the oldest tools for managing network interfaces on Unix-based systems like Ubuntu. Although it’s still widely used, a more modern alternative called ip (part of the iproute2 package) has largely replaced ifconfig.

How to Use ifconfig

To use ifconfig, you need administrative privileges. Open your terminal and type:

sudo ifconfig

This command lists all network interfaces currently configured on your system. For example, it might show output like this for an Ethernet interface:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::aede:48ff:fe7e:3b9f prefixlen 64 scopeid 0x20<link> ether aa:ee:d4:7e:3b:9f txqueuelen 1000 (Ethernet) RX packets 512345 bytes 8192345 (7.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 345678 bytes 5342156 (5.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

And for a Wi-Fi interface:

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::aede:48ff:fe7e:3ba0 prefixlen 64 scopeid 0x20<link> ether aa:ee:d4:7e:3b:a0 txqueuelen 1000 (Ethernet)

Key Information Provided by ifconfig

  • Interface Name: Such as eth0 or wlan0.
  • IP Address and Subnet Mask (inet): The IP address assigned to the interface.
  • MAC Address (ether): The hardware identifier for the network device.

Using ip Command

The ip command is part of the iproute2 package, which has replaced many older networking utilities such as ifconfig. It provides a more powerful and flexible way to manage interfaces.

Listing Interfaces with ip

To see all available network interfaces:

ip link show

This will list each interface along with its status (e.g., UP or DOWN).

Example output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether aa:ee:d4:7e:3b:9f brd ff:ff:ff:ff:ff:ff 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether aa:ee:d4:7e:3b:a0 brd ff:ff:ff:ff:ff:ff

Getting Detailed Interface Information with ip

To get detailed information about a specific interface, use:

ip addr show <interface_name>

For example:

ip addr show eth0

Output:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic eth0 valid_lft 86399sec preferred_lft 86399sec inet6 fe80::aede:48ff:fe7e:3b9f/64 scope link valid_lft forever preferred_lft forever

Managing Network Interfaces with ip

  • Bring up/down interfaces:

    sudo ip link set <interface_name> down/up
  • Change IP address:

    sudo ip addr add <ip_address>/24 dev <interface_name>

Using Netplan for Network Configuration

Ubuntu uses Netplan to manage network configuration, which provides a consistent and declarative way of configuring networking. You can find configuration files typically in /etc/netplan/.

Viewing Current Netplan Configurations

To view your current netplan configurations:

cat /etc/netplan/*.yaml

Example output:

network: version: 2 ethernets: eth0: dhcp4: no addresses: - 192.168.1.10/24 gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8, 8.8.4.4]

Applying Netplan Configurations

Once you have edited your configuration files, apply the changes with:

sudo netplan apply

Troubleshooting Network Interfaces

Common issues include problems with IP addresses not being assigned correctly or network interfaces failing to connect.

  • Check connection status:

    sudo ip link show <interface_name>
  • Ping test: Check connectivity by pinging the default gateway or another device on your network.

    ping -c 4 192.168.1.1
  • nslookup/DNS lookup:

    To verify DNS resolution, use nslookup to look up an IP address.

    nslookup www.google.com

Conclusion

Understanding and managing network interfaces through the terminal is crucial for system administrators and developers working on Ubuntu systems. With tools like ifconfig, ip, and Netplan, you can efficiently configure, monitor, and troubleshoot your network connections. This article has provided an overview of these tools and their usage; further exploration will deepen your mastery over networking in the terminal environment.

By mastering these commands and configurations, you’ll be able to diagnose issues, adjust settings dynamically, and keep your Ubuntu systems running smoothly.

Last Modified: 22/03/2018 - 09:25:54