Skip to content

Instantly share code, notes, and snippets.

@narate
Last active November 13, 2025 14:38
Show Gist options
  • Select an option

  • Save narate/d3f001c97e1c981a59f94cd76f041140 to your computer and use it in GitHub Desktop.

Select an option

Save narate/d3f001c97e1c981a59f94cd76f041140 to your computer and use it in GitHub Desktop.
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"
nmcli con up Hostspot

Note

If after reboot nmcli con up Hotspot doesn't work

Use this command instead to start Hotspot

UUID=$(grep uuid /etc/NetworkManager/system-connections/Hotspot | cut -d= -f2)
nmcli con up uuid $UUID
@ConzZah
Copy link

ConzZah commented Mar 16, 2025

for those who can create their hotspot but don't have internet through it:
symlink iptables to /sbin/iptables
and it should work.

@Ingenium-LiDAR
Copy link

Whenever I try the first line, I get
Error: Failed to add 'Hostspot' connection: failure adding connection: keyfile writer produces an invalid connection: cannot access file: No such file or directory
I'm on Ubuntu Core. Any help would be much appreciated.

@TriMoon
Copy link

TriMoon commented Aug 24, 2025

Maybe the connection name should be "Hotspot" instead of "Hostspot"

@ConzZah
Copy link

ConzZah commented Sep 17, 2025

i made a tool to set up a hotspot automatically
pls try it, review the code and create issues.
i'd like feedback, since this is a passion project of mine
https://github.com/conzzah/hsm

hsm

@mymirai-nikki
Copy link

mymirai-nikki commented Nov 13, 2025

I tried nmcli dev wifi hotspot but it didn't provide Internet connection.

is it possible to replicate Windows' hotspot behavior? where the hotspot has internet connection from the same wireless network card that being used as hotspot as well.

I'm looking for networkmanager-only solution to avoid installing another dependency.

EDIT:
problem solved, thanks to this comment, I ended up using create_ap from linux-wifi-hotspot instead of networkmanager' nmcli.

I just need to specify the channel

create_ap -c <channel-number> <iface-name-for-hotspot> <iface-name-for-internet-source> <ssid-name> <password>

the appropriate channel number can be found by:

iw dev <iface-name-for-hotspot> info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment