By Hafiz Ali | Linux System Administrator with 8+ years experience managing Ubuntu servers and VPN infrastructure. Certified RHCE and Ubuntu Server Specialist.
đ Ubuntu Network Configuration Guide: Complete 2025 Tutorial
đ Last updated: December 2024 | Tested on Ubuntu 22.04 LTS and 24.04 LTS
`Proper network configuration is essential for Ubuntu server administration. This comprehensive guide covers everything from basic Netplan setup to advanced networking scenarios, helping you master Ubuntu’s modern networking stack.
đ Quick Configuration Methods
| Method | Best For | Difficulty | Ubuntu Version |
|---|---|---|---|
| đ Netplan (YAML) | Modern servers | đĸ Easy | 18.04+ |
| âī¸ NetworkManager | Desktops/laptops | đĸ Easy | All versions |
| đ§ Systemd-networkd | Advanced users | đĄ Medium | 16.04+ |
| đ Legacy ifupdown | Older systems | đĄ Medium | 14.04 and earlier |
đ Current Network Status Check
Before making changes, check your current network configuration:
# View all network interfaces
ip addr show
# Check routing table
ip route show
# Test DNS resolution
nslookup google.com
# Check network manager status
systemctl status NetworkManager
# View Netplan configuration
ls -la /etc/netplan/
đ Method 1: Netplan Configuration (Recommended)
Netplan is Ubuntu’s default network configuration tool since 18.04, using YAML files for declarative network setup.
đ Netplan File Locations
# Main Netplan directory
/etc/netplan/
# Common configuration files
/etc/netplan/01-netcfg.yaml
/etc/netplan/50-cloud-init.yaml
/etc/netplan/99-config.yaml
đ ī¸ Basic Static IP Configuration
# Create or edit Netplan configuration
sudo nano /etc/netplan/01-netcfg.yaml
Add this configuration for a static IP address:
network:
version: 2
renderer: networkd
ethernets:
ens33:
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
optional: true
đ Apply Netplan Configuration
# Test configuration (dry run)
sudo netplan try
# Apply configuration immediately
sudo netplan apply
# Generate backend configuration
sudo netplan generate
# Debug Netplan issues
sudo netplan --debug apply
đ§ Method 2: NetworkManager (Desktop/Server)
NetworkManager provides dynamic network control and is ideal for systems with changing network environments.
đĨī¸ GUI Configuration (Ubuntu Desktop)
- īŋŊī¸ Click network icon in system tray
- âī¸ Select Wired Settings or Network Settings
- đ§ Choose your network interface
- đĄ Configure IPv4/IPv6 settings as needed
- đž Click Apply to save changes
â¨ī¸ Command Line Configuration
# List all connections
nmcli connection show
# View device status
nmcli device status
# Create a new static connection
nmcli connection add type ethernet con-name static-eth0 ifname eth0 ip4 192.168.1.100/24 gw4 192.168.1.1
# Configure DNS
nmcli connection modify static-eth0 ipv4.dns "8.8.8.8,8.8.4.4"
# Activate the connection
nmcli connection up static-eth0
⥠Advanced Network Scenarios
đ Network Bonding (Link Aggregation)
# Netplan bonding configuration
network:
version: 2
renderer: networkd
bonds:
bond0:
interfaces: [ens33, ens34]
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
parameters:
mode: 802.3ad
lacp-rate: fast
mii-monitor-interval: 100
đ Network Bridging
# Netplan bridge configuration
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
bridges:
br0:
interfaces: [ens33]
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
parameters:
stp: true
forward-delay: 4
đĄ VLAN Configuration
# Netplan VLAN configuration
network:
version: 2
renderer: networkd
vlans:
ens33.100:
id: 100
link: ens33
addresses: [192.168.100.100/24]
gateway4: 192.168.100.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
đ§ Essential Network Commands
đ Monitoring & Diagnostics
# Real-time network traffic
sudo nethogs
# Bandwidth monitoring
sudo iftop
# Network statistics
ss -tuln
netstat -tuln
# Interface statistics
ip -s link
# Continuous ping with timestamp
ping -D 8.8.8.8
đ ī¸ Troubleshooting Commands
# Check network connectivity
ping -c 4 google.com
# Trace network path
traceroute google.com
# DNS resolution test
dig google.com
nslookup google.com
# Check specific port connectivity
telnet google.com 80
nc -zv google.com 443
# View network manager logs
journalctl -u NetworkManager -f
đ¨ Common Network Issues & Solutions
â “Network Unreachable” Error
# Check gateway configuration
ip route show
# Verify interface status
ip addr show
# Restart networking
sudo netplan apply
# OR
sudo systemctl restart systemd-networkd
đ DNS Resolution Problems
# Check current DNS settings
systemd-resolve --status
# Test DNS resolution
nslookup google.com
# Flush DNS cache
sudo systemd-resolve --flush-caches
# Use alternative DNS temporarily
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf
â ī¸ Interface Not Found
# List all network interfaces
ip link show
# Check if interface is up
ip link set ens33 up
# Scan for hardware changes
sudo lshw -class network
# Reload kernel modules
sudo modprobe -r e1000
sudo modprobe e1000
đĄī¸ Network Security Configuration
đ Firewall Setup with UFW
# Enable UFW firewall
sudo ufw enable
# Allow SSH access
sudo ufw allow ssh
# Allow specific ports
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Allow from specific IP
sudo ufw allow from 192.168.1.0/24
# View firewall status
sudo ufw status verbose
đ Secure Remote Access
# For OpenVPN access (if using our VPN guides)
sudo ufw allow 1194/udp
# For WireGuard access
sudo ufw allow 51820/udp
# Limit SSH access to specific network
sudo ufw allow from 192.168.1.0/24 to any port 22
âī¸ Cloud & Virtualization Notes
đŠī¸ Cloud-Init Integration
# Cloud-init network configuration (usually in /etc/cloud/cloud.cfg.d/)
network:
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
đĨī¸ Virtual Machine Networking
- đ NAT: Default for most VMs, shares host IP
- đ Bridged: VM gets own IP on physical network
- đ Host-only: Network between host and VMs only
- đ Internal: Isolated network between VMs only
đ Best Practices Checklist
- â Always backup original config files before changes
- â Use Netplan for Ubuntu 18.04+ servers
- â
Test configurations with
netplan trybefore applying - â Document changes in your configuration management system
- â Monitor network metrics for performance and security
- â Use descriptive names for network interfaces and connections
- â Implement firewall rules following least privilege principle
â Frequently Asked Questions
đ§ Should I use Netplan or NetworkManager?
Netplan: Best for servers, cloud environments, and reproducible configurations.
NetworkManager: Best for desktops, laptops, and systems with changing network conditions.
đ How do I reset network configuration?
# Reset Netplan to DHCP
sudo tee /etc/netplan/01-netcfg.yaml << EOF
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: true
EOF
sudo netplan apply
đ My changes aren’t applying. What’s wrong?
Common issues include:
- â YAML syntax errors (check indentation)
- â Wrong interface name (use
ip link show) - â Conflicting configuration files
- â Network manager conflicts
đ Related Ubuntu Guides
- đ ī¸ Common APT Errors and How to Fix Them
- ⥠OpenVPN Server Setup on Ubuntu
- đ WireGuard VPN Setup on Ubuntu
- đ§ Browse All Ubuntu Troubleshooting Guides
đ Ready to Master Ubuntu Networking?
Our complete Ubuntu Troubleshooting category has everything you need for enterprise-grade server administration.
