Table of Contents
Overview#
Ubuntu Server doesn’t include a GUI for network configuration. This guide covers setting up WiFi using netplan on Ubuntu 20.04 Server.
Netplan Configuration#
Edit Configuration File#
sudo vi /etc/netplan/50-cloud-init.yamlOr use nano:
sudo nano /etc/netplan/50-cloud-init.yamlConfiguration Structure#
network:
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
"YOUR_WIFI_NAME":
password: "YOUR_WIFI_PASSWORD"Critical Formatting Rules#
Indentation#
| Rule | Requirement |
|---|---|
| Use spaces | Never tabs |
| Indent level | 2 spaces per level |
| Alignment | wifis aligns with ethernets |
YAML Syntax#
- Colon after keys
- Quotes around SSID and password
- No trailing spaces
Example with Proper Indentation#
network:
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
"MyNetwork":
password: "MyPassword123"Apply Configuration#
Apply Changes#
sudo netplan applyVerify Connection#
ifconfigOr:
ip addr show wlan0Look for an IP address assigned to wlan0.
Troubleshooting#
Common Errors#
YAML syntax error:
Error in network definition: unknown key 'wlan0'Solution: Check indentation is correct.
Network not found:
# Scan for networks
sudo iwlist wlan0 scan | grep ESSIDVerify SSID matches exactly.
Debug Mode#
sudo netplan --debug applyShows detailed error messages.
Check Interface Status#
ip link show wlan0Should show UP state.
Static IP Configuration#
For fixed IP instead of DHCP:
network:
version: 2
wifis:
wlan0:
addresses:
- 192.168.0.4/24
gateway4: 192.168.0.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
access-points:
"MyNetwork":
password: "MyPassword123"Multiple Networks#
Configure backup networks:
network:
version: 2
wifis:
wlan0:
dhcp4: true
access-points:
"HomeNetwork":
password: "home123"
"LabNetwork":
password: "lab456"Connects to first available.
Security Considerations#
File Permissions#
The configuration contains passwords:
sudo chmod 600 /etc/netplan/50-cloud-init.yamlHidden Networks#
access-points:
"HiddenNetwork":
hidden: true
password: "secret"After Connection#
Verify Internet#
ping -c 3 google.comCheck DNS#
nslookup google.comGet IP Info#
hostname -I