Understanding Linux networking is essential for anyone running a home server, troubleshooting connectivity issues, or managing a Linux system beyond basic desktop use. This guide explains how Linux networking works, how to manage connections, and how to solve the most common problems you will encounter.
How Linux networking works
Linux uses a layered networking stack similar to other operating systems, but exposes more control to the user than Windows or macOS. At the core is the kernel’s networking subsystem, which manages network interfaces — the hardware (or virtual) devices that connect to networks.
NetworkManager is the service that manages network connections on most desktop Linux distributions (Ubuntu, Fedora, Mint). It handles connecting to Wi-Fi, managing Ethernet connections, and maintaining VPN connections. NetworkManager has both a graphical interface (the network icon in your desktop’s status area) and a command-line interface (nmcli).
systemd-networkd is an alternative used on some server distributions and minimal installations. It is simpler than NetworkManager and well suited for systems with fixed network configurations.
Understanding which service manages your network helps you use the right tools when configuring or troubleshooting.
Network interface names on modern Linux systems follow a predictable naming scheme:
enp3s0— a wired Ethernet interface (en = Ethernet, p3 = PCI bus 3, s0 = slot 0)wlp2s0— a wireless interface (wl = wireless LAN)lo— the loopback interface (127.0.0.1, for local communication only)
The older names (eth0, wlan0) are still used on some systems, particularly Raspberry Pi.
Connecting to Wi-Fi
Graphical method (recommended for desktop users):
Click the network icon in your desktop’s status bar or system tray, select your Wi-Fi network from the list, and enter the password. NetworkManager remembers the connection and reconnects automatically.
Terminal method with nmcli:
List available Wi-Fi networks:
nmcli dev wifi list
Connect to a network:
nmcli dev wifi connect "MyNetwork" password "MyPassword"
List all saved connections:
nmcli connection show
Disconnect from a network:
nmcli dev disconnect wlp2s0
Reconnect to a saved connection:
nmcli connection up "MyNetwork"
For hidden networks (networks that don’t broadcast their name):
nmcli dev wifi connect "HiddenSSID" password "password" hidden yes
Terminal method for systems without NetworkManager (minimal servers):
On systems using wpa_supplicant directly:
sudo wpa_passphrase "MyNetwork" "MyPassword" | sudo tee /etc/wpa_supplicant.conf
sudo wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant.conf
sudo dhclient wlp2s0
Checking your network status
Show IP addresses for all interfaces:
ip addr show
# or the shorter form:
ip a
Look for lines like inet 192.168.1.105/24 — this shows your local IP address and subnet mask.
Show just the local IP addresses:
hostname -I
Show your public IP (as seen from the internet):
curl ifconfig.me
# or
curl icanhazip.com
Check the routing table (how traffic is directed):
ip route show
The line starting with default via shows your default gateway — your router’s IP address. All traffic to the internet goes through this gateway.
Check if a specific interface is up:
ip link show wlp2s0
Look for UP in the output to confirm the interface is active.
Check active network connections:
ss -tulnp
This shows all listening sockets and established connections — useful for seeing what services are listening for network traffic.
Setting a static IP address
For most desktop users, DHCP (automatic IP assignment by your router) is the right choice. Your router assigns an IP address automatically when you connect, and everything works without configuration.
For servers — especially home servers running Jellyfin, Samba, or a web server — a static IP ensures other devices can always reach your server at the same address.
The recommended method for home servers is DHCP reservation in your router:
- Log into your router’s web interface (usually at 192.168.1.1 or 192.168.0.1)
- Find the DHCP settings or “IP reservation” section
- Assign a fixed IP to your server’s MAC address
This keeps the static IP configuration in your router (one central place) rather than on the server, making it easier to manage.
Setting a static IP on Linux with nmcli:
Find your connection name:
nmcli connection show
Set a static IP (replace MyConnection with your connection name and the IP with your desired address):
nmcli connection modify MyConnection \
ipv4.method manual \
ipv4.addresses 192.168.1.100/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns "1.1.1.1 8.8.8.8"
nmcli connection up MyConnection
Setting a static IP with Netplan (Ubuntu Server 20.04 and later):
Netplan is the network configuration system used on Ubuntu Server. Find your configuration file:
ls /etc/netplan/
Edit it:
sudo nano /etc/netplan/01-netcfg.yaml
For a static IP on an Ethernet interface:
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
dhcp4: false
Apply the configuration:
sudo netplan apply
Configuring DNS
DNS (Domain Name System) translates domain names like google.com into IP addresses. Without DNS, you would need to remember IP addresses for every website.
Check your current DNS servers:
systemd-resolve --status | grep "DNS Servers"
# or
cat /etc/resolv.conf
Change DNS with nmcli:
nmcli connection modify MyConnection ipv4.dns "1.1.1.1 8.8.8.8"
nmcli connection up MyConnection
Change DNS for systemd-resolved (system-wide, persistent):
sudo nano /etc/systemd/resolved.conf
Add under the [Resolve] section:
[Resolve]
DNS=1.1.1.1 8.8.8.8
FallbackDNS=9.9.9.9
Restart the service:
sudo systemctl restart systemd-resolved
Test DNS resolution:
nslookup google.com
dig google.com
resolvectl query google.com # using systemd-resolved directly
Add local hostname overrides in /etc/hosts:
sudo nano /etc/hosts
Add entries like:
192.168.1.100 myserver
192.168.1.101 nas
After saving, you can access these devices by name: ssh myserver instead of ssh 192.168.1.100.
Understanding network interfaces
Each network interface in Linux has a name that describes its type and location. You interact with interfaces using the ip command.
Bring an interface up or down:
sudo ip link set enp3s0 up
sudo ip link set enp3s0 down
Manually assign an IP to an interface (temporary, lost on reboot):
sudo ip addr add 192.168.1.200/24 dev enp3s0
sudo ip route add default via 192.168.1.1 dev enp3s0
View hardware information about network interfaces:
lspci | grep -i network # PCI network cards
lsusb | grep -i network # USB network adapters
ip link show # all interfaces with MAC addresses
Check interface statistics (bytes sent/received, errors):
ip -s link show enp3s0
cat /proc/net/dev
Troubleshooting network problems
When networking does not work, follow this diagnostic sequence from the bottom up:
Step 1: Is the physical connection active?
ip link show
All active interfaces show UP. If your Ethernet interface shows DOWN, check the cable or try sudo ip link set enp3s0 up.
Step 2: Do you have an IP address?
ip addr show
If no IP is shown for your interface, DHCP may have failed. Try requesting a new address:
sudo dhclient enp3s0 # request DHCP address
Step 3: Can you reach your router?
ping 192.168.1.1 # replace with your router's IP
If this fails but you have an IP, the problem is between you and your router — check cables, Wi-Fi signal strength, or router settings.
Step 4: Can you reach the internet by IP?
ping 8.8.8.8 # Google's DNS server
If this works but the next step fails, the problem is DNS.
Step 5: Does DNS work?
ping google.com
nslookup google.com
If ping by IP works but ping by name fails, configure different DNS servers (try 1.1.1.1 or 8.8.8.8).
Step 6: Is the firewall blocking something?
sudo ufw status
Check whether UFW rules are unexpectedly blocking the connection you need.
Useful networking commands
Test latency and packet loss:
ping -c 10 google.com # 10 packets to measure loss
traceroute google.com # show each hop to a destination
mtr google.com # combined ping + traceroute (interactive)
Scan open ports on your local machine:
sudo nmap -sT localhost
Test a specific port:
nc -zv 192.168.1.100 22 # test if SSH port 22 is open
Download a file for network speed testing:
curl -o /dev/null https://speed.hetzner.de/100MB.bin
Show network bandwidth usage in real time:
sudo apt install iftop
sudo iftop -i enp3s0
Configuring a firewall for networking
For guidance on configuring UFW to allow or block specific network ports, see our dedicated guide on Linux security basics. The firewall configuration directly affects which network connections succeed and which are rejected.
In short: enable UFW with sudo ufw enable, allow services you need with sudo ufw allow [service], and default to blocking everything else. This is especially important for any Linux machine connected directly to the internet, such as a VPS or a home server with port forwarding enabled.
Remote access with SSH
SSH (Secure Shell) lets you connect to any Linux machine on your network (or the internet) from any other computer. It is the standard tool for remote server management.
Connect to a remote machine:
ssh username@192.168.1.100 # local network
ssh username@server.example.com # remote server
Copy files over SSH:
scp localfile.txt username@192.168.1.100:/home/username/
scp username@192.168.1.100:/home/username/remotefile.txt .
Mount a remote filesystem over SSH (SSHFS):
sudo apt install sshfs
mkdir ~/remote-mount
sshfs username@192.168.1.100:/home/username ~/remote-mount
This mounts the remote home directory as if it were a local folder. Files are accessed over SSH in real time.
Understanding Linux networking opens the door to running your own services, managing remote systems, and building more sophisticated home lab setups. Once the fundamentals are solid, exploring how to set up a Linux home server shows how to put these networking skills into practical use.