How to Create and Manage a Wi-Fi Hotspot in Linux Terminal Using nmcli

Sharing an active internet connection—such as a wired Ethernet connection or a 4G/5G mobile broadband modem—from a Linux computer to nearby mobile devices, test boards, or secondary laptops is frequently required in server rooms, field test environments, and home labs. While graphical desktop environments like GNOME and KDE provide one-click hotspot toggles, systems running minimal installations, embedded operating systems, or headless server instances must manage wireless access points directly through the command line. Using NetworkManager’s native command-line tool, nmcli, you can create, secure, and manage robust Wi-Fi hotspots with complete control over routing and encryption.

Following this command-line procedure allows you to configure WPA2-Personal wireless access points, inspect active client leases, and manage persistent wireless profiles directly from the Linux terminal.

Verifying Wireless Interface and Access Point Capabilities

Before creating a hotspot, verify that your wireless network card is recognised by the operating system and supports Access Point (AP) operational mode:

  1. List all physical and virtual network interfaces detected by NetworkManager:
nmcli device status
  1. Identify the name of your wireless interface (typically designated as wlan0, wlp2s0, or wlp3s0).
  2. Query the wireless regulatory subsystem using the iw utility to verify that the wireless chipset supports Master/AP mode:
iw list | grep "Supported interface modes" -A 8
  1. Confirm that AP appears within the list of supported modes. If your card only lists Client, Managed, or Monitor modes, the hardware cannot broadcast an access point.

Creating an Instant Wi-Fi Hotspot with a Single Command

NetworkManager includes a streamlined shortcut command that builds a temporary access point, assigns IP addresses, and binds routing automatically:

  1. Execute the hotspot initialization command, specifying your wireless interface, network name (SSID), and a secure pre-shared key:
nmcli device wifi hotspot ifname wlan0 ssid "LinuxHotspot" password "SecureKey2026!"
  1. NetworkManager performs several automated tasks in the background:
    • Creates a dedicated hotspot connection profile.
    • Initialises an internal DHCP server instance via dnsmasq-base.
    • Assigns the static gateway IP 10.42.0.1/24 to your wireless interface.
    • Configures iptables / nftables network address translation (NAT) to route traffic through your default internet connection.
  2. Connect your client phone or computer to the “LinuxHotspot” wireless network using the specified password to test internet reachability.

Building a Persistent, Customised Hotspot Connection Profile

If you require a permanent hotspot that can be toggled on demand without re-typing authentication credentials every session, build a dedicated connection profile:

  1. Create a new wireless connection profile configured for AP mode:
sudo nmcli connection add type wifi ifname wlan0 con-name "LabHotspot" autoconnect no ssid "LabHotspot"
  1. Configure the wireless band and channel parameters (e.g. 2.4 GHz band bg or 5 GHz band a):
sudo nmcli connection modify "LabHotspot" 802-11-wireless.mode ap 802-11-wireless.band bg
  1. Apply WPA-PSK security encryption:
sudo nmcli connection modify "LabHotspot" wifi-sec.key-mgmt wpa-psk
sudo nmcli connection modify "LabHotspot" wifi-sec.psk "EnterprisePasscode2026"
  1. Configure IPv4 sharing mode to activate the internal DHCP pool and disable IPv6 if not required:
sudo nmcli connection modify "LabHotspot" ipv4.method shared
sudo nmcli connection modify "LabHotspot" ipv6.method ignore

Enabling Kernel Packet Forwarding

To ensure incoming data packets from connected Wi-Fi clients are successfully forwarded out through your upstream Ethernet or mobile network interface, enable IPv4 packet forwarding in the Linux kernel:

  1. Enable forwarding immediately in the running kernel:
sudo sysctl -w net.ipv4.ip_forward=1
  1. To ensure this setting persists across system reboots, write the directive into a sysctl configuration file:
echo "net.ipv4.ip_forward = 1" | sudo tee /etc/sysctl.d/99-ip-forwarding.conf

Activating, Monitoring, and Disabling the Hotspot

Manage the lifecycle of your wireless hotspot directly through simple connection commands:

  1. Start the hotspot broadcast:
nmcli connection up "LabHotspot"
  1. To inspect IP addresses and MAC addresses assigned to connected client devices, inspect the active DHCP leases database:
cat /var/lib/misc/dnsmasq.leases
  1. When you finish sharing your connection, cleanly terminate the broadcast:
nmcli connection down "LabHotspot"

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.