Linux › Section I · Your network and its configuration › Topic I.6

Ethernet and kernel network interfaces

IP addresses and routes are software ideas, but every packet must finally leave through real hardware. The Linux kernel joins the two through network interfaces, and learning to read their names and states tells you at a glance whether a problem is in the cable or in the configuration.

Ethernet underneath

The internet layer runs on almost any hardware, which is one reason it succeeded. To talk to another machine, though, a host still needs a physical network, and the most common wired one is Ethernet; Wi-Fi (802.11) is a separate link protocol that Linux presents in much the same way. Every Ethernet device has a 48-bit Media Access Control (MAC) address, and data crosses the link in frames that carry a source and destination MAC address. The Networking topic Switched LANs: MAC addresses, ARP, switches, and VLANs covers the frame format and how switches forward frames; this topic looks at how Linux presents that hardware.

Frames stay on their own network

An Ethernet frame cannot leave the physical network it was sent on. If a Linux machine has two network cards on two separate Ethernet networks, a frame arriving on one is not passed to the other, unless you join them into a bridge, a software switch. Normally each Ethernet network is also one IP subnet, and moving data between them is the internet layer's job: a router takes the datagram out of the incoming frame and wraps it in a new frame for the next network. That is why a datagram keeps its IP addresses end to end, while the MAC addresses change at every router.

Kernel network interfaces

The kernel links the hardware side and the IP side through a network interface, a named object that a driver creates for each network device. When you configure an interface, you attach IP addresses and routes to it, and the driver handles the frames. Not every interface is hardware. lo, the loopback interface, is purely software and is usually interface number 1. Bridges such as br0, virtual Ethernet pairs used by containers, VPN tunnels such as wg0 or tun0, and docker0 are virtual interfaces that the kernel treats in much the same way. ip link lists them all.

Predictable interface names

The kernel first names Ethernet devices eth0, eth1 and so on in the order it finds them, which can change when hardware is added. On most systemd distributions udev then renames them using stable facts about the hardware, giving predictable network interface names. The name starts with a type prefix: en for Ethernet, wl for wireless LAN and ww for mobile broadband. Then comes a location, tried in this order by default: an onboard index from the firmware (o, as in eno1), a hotplug slot number (s, as in ens1) or the PCI path (p for bus, s for slot, optionally f for function, as in enp3s0). The topic udev explains the renaming rules.

Worked example: decoding names

Decode four interface names. 1. enp3s0: en means Ethernet; p3s0 means PCI bus 3, slot 0, a card or chip on the PCI bus. 2. wlp2s0: wl means a wireless LAN device at PCI bus 2, slot 0. 3. eno1: an Ethernet device the firmware reports as onboard device 1, typical of servers. 4. enp0s31f6: Ethernet at PCI bus 0, slot 31, function 6, common for chipsets that build Ethernet into the main board. Check: each name begins with a type prefix and then gives a location, so the name will not change at the next boot unless the hardware moves. A name such as enx followed by 12 hexadecimal digits is built from the MAC address instead.

Reading ip link

ip link show prints each interface's link-layer state. An illustrative healthy entry: 2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500, a queueing setting, then state UP, then link/ether 02:00:00:00:00:21 brd ff:ff:ff:ff:ff:ff. The number is the interface index. Inside the angle brackets, UP means an administrator or network manager has enabled the interface, and LOWER_UP means the physical link has a signal. mtu is the largest datagram the link carries, 1,500 bytes on standard Ethernet. state is the operational state, and link/ether gives the MAC address, with the broadcast MAC after brd. ip -br link prints one line per interface.

Worked example: is it the cable?

A desktop has no network. ip link shows 2: enp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 ... state DOWN. 1. UP is present, so the interface is enabled in software. 2. LOWER_UP is missing and NO-CARRIER is shown, so the card sees no link signal. 3. state DOWN agrees: the link is not working. 4. The cause is physical: a loose or faulty cable, a dead switch port or a switch that is off. Configuring addresses will not help until the carrier returns. Check: had the brackets shown only <BROADCAST,MULTICAST> without UP, the interface would merely be disabled, fixed with ip link set enp3s0 up as root.

Hardware details: ethtool and statistics

ip concentrates on the software layers, so for the hardware itself use ethtool. ethtool enp3s0 prints the current settings, including the negotiated speed, such as 1000Mb/s, the duplex mode and Link detected: yes or no. ethtool -i enp3s0 names the driver and firmware, and ethtool -S enp3s0 dumps the card's own counters. Changing settings with ethtool -s needs root and is rarely necessary, because Ethernet negotiates automatically. For traffic counts, ip -s link shows bytes, packets, errors and dropped packets for each direction; rising error counts suggest a bad cable. The same facts appear as files under /sys/class/net/.

Common mistakes to avoid

First, expecting every machine to have eth0; most systemd distributions use predictable names such as enp3s0, so check with ip link. Second, reading UP as proof the link works; UP means enabled, and LOWER_UP means a carrier is present. Third, assuming a frame can pass between two Ethernet networks without a bridge or router. Fourth, troubleshooting addresses and routes while NO-CARRIER is showing; fix the physical link first. Fifth, confusing the interface index number with the name. Sixth, thinking a MAC address is global like an IP address; it matters only on its own link, and Wi-Fi often randomises it.

Key takeaways

Ethernet devices have 48-bit MAC addresses and exchange frames that never leave their own physical network; routers move datagrams between networks in new frames. The kernel represents each device as a network interface, alongside virtual ones such as lo, bridges and VPN tunnels. Predictable names combine a type prefix (en, wl, ww) with a location (o, s or p...s...f), replacing eth0. ip link shows the index, flags (UP enabled, LOWER_UP carrier, NO-CARRIER no signal), mtu, state and MAC address. ethtool reports speed, duplex and drivers, and ip -s link counts packets and errors.

Flashcards

Flashcard

MAC address

48-bit hardware address of an Ethernet or Wi-Fi interface

Shown after link/ether.

Test your understanding

Question 1 of 5

What does the interface name wlp2s0 tell you?

Question 2 of 5

ip link shows <NO-CARRIER,BROADCAST,MULTICAST,UP> ... state DOWN for enp3s0. What is the most likely fix?

Question 3 of 5

A Linux host has two network cards on two separate Ethernet networks, with no bridge configured. What happens to a frame that arrives on one card?

Question 4 of 5

Which command shows the negotiated speed and duplex of an Ethernet card?

Question 5 of 5

In ip link output, what is the difference between UP and LOWER_UP?

← Previous topicNext topic →