Ubuntu Server Wi-Fi Hotspot Guide

This guide configures an Ubuntu Server computer with two network interfaces:

  • Ethernet: receives Internet from the router.
  • Wi-Fi: creates a wireless hotspot for other users.

The Ubuntu server acts as a router, sharing the Ethernet Internet connection with devices connected to the Wi-Fi hotspot.

Network Topology

# Internet sharing structure

INTERNET
   │
   │
ROUTER
   │
   │ Ethernet
   ▼
UBUNTU SERVER
   │
   │ Wi-Fi Hotspot
   ▼
┌───────────────┐
│ Wi-Fi Users │
│ Phones/Laptop │
│ Tablets │
└───────────────┘

Identify Network Interfaces

# Display network interfaces
ip link

# Alternative
ip addr

Look for the Ethernet and wireless interfaces. Common names are:

Ethernet: enp1s0
Wireless: wlan0

Modern Ubuntu installations may use names such as enp0s3, enp2s0, or wlp3s0 instead of eth0 and wlan0.

Install Required Packages

# Update package list
sudo apt update

# Install NetworkManager and firewall tools
sudo apt install network-manager iptables -y

Enable NetworkManager:

sudo systemctl enable NetworkManager
sudo systemctl start NetworkManager

Create Wi-Fi Hotspot

First determine your wireless interface:

nmcli device status

Example:

DEVICE TYPE STATE
enp1s0 ethernet connected
wlp2s0 wifi disconnected

In this example:

# Internet interface
enp1s0

# Hotspot interface
wlp2s0

Configure Wi-Fi

# Create hotspot
sudo nmcli device wifi hotspot \
ifname wlp2s0 \
con-name Ubuntu-Hotspot \
ssid Ubuntu-Hotspot \
password "ChangeThisPassword123"

Change the SSID and password to your preferred values.

Example:

SSID: AMUCTA_WIFI
Password: ChangeThisPassword123

Configure Hotspot IP Address

Give the hotspot its own private network. For example, use 10.10.10.1/24.

# Configure hotspot IPv4 address
sudo nmcli connection modify Ubuntu-Hotspot \
ipv4.method shared \
ipv4.addresses 10.10.10.1/24

NetworkManager's shared mode provides DHCP and performs IPv4 Internet sharing for clients connected through the hotspot.

Enable IP Forwarding

# Enable IPv4 forwarding immediately
sudo sysctl -w net.ipv4.ip_forward=1

Make the setting permanent:

sudo nano /etc/sysctl.d/99-hotspot.conf

Add:

net.ipv4.ip_forward=1

Apply the configuration:

sudo sysctl --system

Configure NAT

If NetworkManager's ipv4.method shared is being used, NetworkManager handles the normal IPv4 masquerading required for Internet sharing.

Therefore, do not add a second manual NAT rule unless you have a specific reason to use your own firewall/routing configuration.

# Check NetworkManager connections
nmcli connection show

Configure Firewall

If UFW is enabled, make sure forwarding is allowed appropriately.

# Check firewall status
sudo ufw status

For a simple NetworkManager shared hotspot, test the hotspot before adding restrictive firewall rules. This makes troubleshooting easier.

Enable Hotspot Automatically

Configure the NetworkManager connection to start automatically.

sudo nmcli connection modify Ubuntu-Hotspot connection.autoconnect yes

Also make sure NetworkManager is enabled at boot:

sudo systemctl enable NetworkManager

Create Systemd Hotspot Service

A dedicated systemd service can ensure that the hotspot connection is activated after NetworkManager starts.

# Create service
sudo nano /etc/systemd/system/ubuntu-hotspot.service

Add:

[Unit]
Description=Ubuntu Wi-Fi Hotspot
Wants=NetworkManager.service
After=NetworkManager.service network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/nmcli connection up Ubuntu-Hotspot
ExecStop=/usr/bin/nmcli connection down Ubuntu-Hotspot
RemainAfterExit=yes
Restart=on-failure

[Install]
WantedBy=multi-user.target

Reload systemd:

sudo systemctl daemon-reload

Enable the service at boot:

sudo systemctl enable ubuntu-hotspot.service

Start it immediately:

sudo systemctl start ubuntu-hotspot.service

Prevent the Server From Sleeping

For a dedicated hotspot server, configure systemd-logind so that the machine does not suspend when idle.

# Edit logind configuration
sudo nano /etc/systemd/logind.conf

Add or modify:

HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
IdleAction=ignore

Restart logind:

sudo systemctl restart systemd-logind

For a server that should remain available continuously, also disable generic sleep targets:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Check Hotspot Status

# NetworkManager device status
nmcli device status

# Hotspot connection
nmcli connection show --active

Check Connected Users

View devices that have received addresses from the hotspot network:

ip neigh

You can also inspect the NetworkManager connection:

nmcli connection show Ubuntu-Hotspot

Test Internet Sharing

First test Internet connectivity from the Ubuntu server:

ping -c 4 8.8.8.8

Then connect a phone or laptop to the hotspot and test:

ping 8.8.8.8

Finally test DNS:

ping google.com

View Hotspot Logs

# NetworkManager logs
sudo journalctl -u NetworkManager -f

Check the hotspot service:

sudo journalctl -u ubuntu-hotspot.service

Restart Hotspot

# Restart systemd hotspot service
sudo systemctl restart ubuntu-hotspot.service

Or restart the NetworkManager connection directly:

sudo nmcli connection down Ubuntu-Hotspot
sudo nmcli connection up Ubuntu-Hotspot

Stop Hotspot

sudo systemctl stop ubuntu-hotspot.service

To start it again:

sudo systemctl start ubuntu-hotspot.service

Test After Reboot

# Reboot server
sudo reboot

After the server starts again, check:

nmcli device status

nmcli connection show --active

sudo systemctl status ubuntu-hotspot.service

The wireless interface should be running the hotspot automatically, without requiring a desktop login.

Final Network Configuration

INTERNET
  │
  │
ROUTER
  │
  │ Ethernet
  ▼
┌───────────────────────────┐
│ Ubuntu Server │
│ │
│ Ethernet: Internet │
│ Wi-Fi: 10.10.10.1/24 │
│ │
│ NetworkManager │
│ DHCP + NAT + Hotspot │
└─────────────┬─────────────┘
│
│ Wi-Fi
▼
┌───────────────┐
│ Users │
│ 10.10.10.x │
└───────────────┘