Welcome to the first installment of Linux Networking Mastery, a hands-on blog series that will guide you from the basics all the way to advanced configurations. Whether you're a system administrator, developer, DevOps engineer, or just curious about how Linux handles networking, this series will give you practical, command-line-focused knowledge you can apply immediately.
In this opening post, we'll lay the foundation by exploring how Linux thinks about networking. We'll map the classic OSI model to real Linux components, introduce the core tools you'll use every day, and run through basic commands to inspect and test your network. Future posts will build directly on these concepts, so take time to try the examples on your own machine.
The Linux Network Stack: OSI Model in Practice
The OSI 7-layer model is a useful framework, but Linux implements networking in a more pragmatic, layered way inside the kernel. Here's how the layers roughly map:
- Layer 1 (Physical): Hardware – your Ethernet card, Wi-Fi chipset, or virtual interface.
- Layer 2 (Data Link): Device drivers and kernel modules handle MAC addresses, Ethernet frames, ARP, etc. Tools like
ip linkoperate here. - Layer 3 (Network): The IPv4/IPv6 stack in the kernel. Routing, fragmentation, and the
ip addrandip routecommands live here. - Layer 4 (Transport): TCP, UDP, SCTP, etc. Connection tracking (conntrack) and tools like
ssgive visibility. - Layers 5–7 (Session, Presentation, Application): Mostly userspace. Sockets are the API applications use to talk to the kernel's transport layer.
The key takeaway: almost everything you do as an administrator happens at Layers 2–4 via the ip command suite and netfilter (firewalls). Understanding this stack helps you troubleshoot systematically—from "is the cable plugged in?" to "why is this TCP connection stalling?"
Core Components You'll Encounter
Network Interfaces
These are the logical representations of your hardware (or virtual) devices:eth0,enp0s3,wlan0,lo(loopback), etc. Modern Linux uses predictable naming (e.g.,enp0s3for PCI devices).IP Addresses and Subnets
IPv4 (e.g., 192.168.1.100/24) or IPv6 (e.g., 2001:db8::1/64). Addresses are bound to interfaces.Routing Table
Tells the kernel where to send packets that aren't local.Sockets
The interface between applications and the kernel network stack. Tools likessandnetstatshow active sockets.Namespaces
A modern Linux feature that lets you isolate network stacks (used heavily in containers).
Essential Commands: Getting Started
Let's jump into the terminal. All examples assume a typical desktop or server installation (Ubuntu, Fedora, Arch, etc.).
1. List Network Interfaces
ip link show
Sample output (truncated):
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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:12:34:56 brd ff:ff:ff:ff:ff:ff
lois the loopback interface (always 127.0.0.1).enp0s3is a physical Ethernet interface (your naming may differ).- Flags like
UPandLOWER_UPtell you administrative and physical status.
Legacy alternative (still works on most systems):
ifconfig -a
2. Show IP Addresses
ip addr show
Or the shorter:
ip a
Sample:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 192.168.1.42/24 brd 192.168.1.255 scope global dynamic enp0s3
valid_lft 86399sec preferred_lft 86399sec
inet6 fe80::a00:27ff:fe12:3456/64 scope link
valid_lft forever preferred_lft forever
Here you see:
- IPv4 address with /24 subnet mask
- Broadcast address
- Link-local IPv6 address (always present)
3. View the Routing Table
ip route show
Typical output on a home network:
default via 192.168.1.1 dev enp0s3 proto dhcp metric 100
192.168.1.0/24 dev enp0s3 proto kernel scope link src 192.168.1.42 metric 100
- The
defaultroute points to your gateway (router). - The local subnet route is directly connected.
4. Basic Connectivity Testing
ping 8.8.8.8 # Google's public DNS – tests IP connectivity
ping google.com # Tests DNS resolution as well
For IPv6:
ping -6 ipv6.google.com
Traceroute (install traceroute if needed):
traceroute 8.8.8.8
Distribution-Specific Notes
Linux distributions handle networking differently under the hood:
Debian/Ubuntu family
Traditionally used/etc/network/interfaces, now moving to Netplan (YAML-based, backend can be NetworkManager or systemd-networkd).RHEL/CentOS/Fedora family
Default to NetworkManager (controlled vianmclior GUI). Older systems used network-scripts; newer ones support systemd-networkd.Arch, Gentoo, etc.
Often rely on whatever you configure manually—systemd-networkd,netctl, or openrc scripts.
In later posts we'll dive deep into each configuration method, but for now, just know that the ip commands work the same everywhere.
Quick Hands-On Exercise
- Run
ip link showand identify your main interface. - Run
ip addr show <interface>on that interface. - Run
ip route showand note your default gateway. - Ping your gateway, then an external address like 1.1.1.1.
If anything looks wrong, you're already practicing troubleshooting!
What's Next?
In Part 2, we'll take full control of interfaces: bringing them up/down, assigning static IPs manually, and configuring persistent settings across major distros.