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
│
│
ROUTER
│
│ Ethernet
▼
UBUNTU SERVER
│
│ Wi-Fi Hotspot
▼
┌───────────────┐
│ Wi-Fi Users │
│ Phones/Laptop │
│ Tablets │
└───────────────┘
Identify Network Interfaces
ip link
# Alternative
ip addr
Look for the Ethernet and wireless interfaces. Common names are:
Wireless: wlan0
Modern Ubuntu installations may use names such as
enp0s3, enp2s0, or wlp3s0
instead of eth0 and wlan0.
Install Required Packages
sudo apt update
# Install NetworkManager and firewall tools
sudo apt install network-manager iptables -y
Enable NetworkManager:
sudo systemctl start NetworkManager
Create Wi-Fi Hotspot
First determine your wireless interface:
Example:
enp1s0 ethernet connected
wlp2s0 wifi disconnected
In this example:
enp1s0
# Hotspot interface
wlp2s0
Configure Wi-Fi
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:
Password: ChangeThisPassword123
Configure Hotspot IP Address
Give the hotspot its own private network. For example, use 10.10.10.1/24.
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
sudo sysctl -w net.ipv4.ip_forward=1
Make the setting permanent:
Add:
Apply the configuration:
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.
nmcli connection show
Configure Firewall
If UFW is enabled, make sure forwarding is allowed appropriately.
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.
Also make sure NetworkManager is enabled at boot:
Create Systemd Hotspot Service
A dedicated systemd service can ensure that the hotspot connection is activated after NetworkManager starts.
sudo nano /etc/systemd/system/ubuntu-hotspot.service
Add:
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:
Enable the service at boot:
Start it immediately:
Prevent the Server From Sleeping
For a dedicated hotspot server, configure systemd-logind so that the machine does not suspend when idle.
sudo nano /etc/systemd/logind.conf
Add or modify:
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
IdleAction=ignore
Restart logind:
For a server that should remain available continuously, also disable generic sleep targets:
Check Hotspot Status
nmcli device status
# Hotspot connection
nmcli connection show --active
Check Connected Users
View devices that have received addresses from the hotspot network:
You can also inspect the NetworkManager connection:
Test Internet Sharing
First test Internet connectivity from the Ubuntu server:
Then connect a phone or laptop to the hotspot and test:
Finally test DNS:
View Hotspot Logs
sudo journalctl -u NetworkManager -f
Check the hotspot service:
Restart Hotspot
sudo systemctl restart ubuntu-hotspot.service
Or restart the NetworkManager connection directly:
sudo nmcli connection up Ubuntu-Hotspot
Stop Hotspot
To start it again:
Test After Reboot
sudo reboot
After the server starts again, check:
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
│
│
ROUTER
│
│ Ethernet
▼
┌───────────────────────────┐
│ Ubuntu Server │
│ │
│ Ethernet: Internet │
│ Wi-Fi: 10.10.10.1/24 │
│ │
│ NetworkManager │
│ DHCP + NAT + Hotspot │
└─────────────┬─────────────┘
│
│ Wi-Fi
▼
┌───────────────┐
│ Users │
│ 10.10.10.x │
└───────────────┘