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.yaml

Or use nano:

sudo nano /etc/netplan/50-cloud-init.yaml

Configuration 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
#

RuleRequirement
Use spacesNever tabs
Indent level2 spaces per level
Alignmentwifis 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 apply

Verify Connection
#

ifconfig

Or:

ip addr show wlan0

Look 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 ESSID

Verify SSID matches exactly.

Debug Mode
#

sudo netplan --debug apply

Shows detailed error messages.

Check Interface Status
#

ip link show wlan0

Should 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.yaml

Hidden Networks
#

access-points:
  "HiddenNetwork":
    hidden: true
    password: "secret"

After Connection
#

Verify Internet
#

ping -c 3 google.com

Check DNS
#

nslookup google.com

Get IP Info
#

hostname -I