Ivy Consultants Inc.

Consulting Services for Security, Networking, Wi-Fi and Windows Server

A network interface in Linux is a software representation of a network connection. It’s how the operating system interacts with the underlying network hardware or virtual network connections.

Types of Network Interfaces

  1. Physical Interfaces: These are associated with physical network hardware. Examples include:
    • Ethernet interfaces (e.g., eth0enp0s3)
    • Wi-Fi interfaces (e.g., wlan0wlp2s0)
  2. Virtual Interfaces: These are not tied to physical hardware and include:
    • Loopback interface (lo), used for internal communication within the host.
    • Virtual Ethernet interfaces (e.g., veth), often used in container networking.
    • VPN interfaces (e.g., tun0tap0), used for virtual private networks.

Managing Network Interfaces

Listing Network Interfaces

You can list all network interfaces using the ip command:

ip link show

This will display all available network interfaces along with their state (up or down) and hardware addresses.

sonnyb@ubuntu-server:~$ ip link show1: 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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 

   link/ether 08:00:27:3e:6b:88 brd ff:ff:ff:ff:ff:ff

Explaining everything that is written here can get pretty deep, and I don’t want to go off the rails to explain every detail which you probably don’t need right now. Here is a high-level breakdown of the output you see if you’re interested:

  1. Loopback Interface (lo):
    • Identified as the lo interface, indicating it’s a loopback interface.
    • Flags (LOOPBACK,UP,LOWER_UP) show it’s a loopback interface that’s active and operational.
    • MTU (Maximum Transmission Unit) is set to 65536 bytes, typical for loopback interfaces.
    • qdisc noqueue indicates no network traffic queuing, common for loopback.
    • state UNKNOWN is standard for loopback interfaces as they don’t have a physical link status.
    • Hardware (MAC) address and broadcast address are both all zeros, which is standard for loopback interfaces.
  2. Ethernet Interface (enp0s3):
    • Named enp0s3, following a predictable naming convention.
    • Flags (BROADCAST,MULTICAST,UP,LOWER_UP) indicate support for broadcasting and multicasting, and show the interface is active with an operational physical layer.
    • Standard MTU for Ethernet is 1500 bytes.
    • qdisc fq_codel is the queuing discipline, used for managing network traffic.
    • state UP shows the interface is ready for data transmission.
    • Hardware (MAC) address is specific to the Ethernet interface, and the broadcast address is the standard ff:ff:ff:ff:ff:ff.

Configuring Network Interfaces

You can configure network interfaces in various ways, such as assigning IP addresses, setting up routing, or changing the state (up or down).

To bring an interface up:

sudo ip link set eth0 up

To assign a temporary IP address with the ip command:

Whatever IP address you assign must fall within your networks subnet, if you’re unsure of what this means then run the `ip addr` command and copy the existing IP or modify only the last octet (last set of numbers)

sudo ip addr add 192.168.1.10/24 dev eth0

Here is a general rule of thumb. Notice the /24? That’s the IP in CIDR block notation and it means you can modify the last octet if you want to change the IP. Slash 24 is very common for home labs.