Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@mp3butcher

This comment has been minimized.

Copy link

commented Dec 10, 2017

very usefull

@roncapat

This comment has been minimized.

Copy link

commented Aug 9, 2018

Thanks! Flawless

@ansarid

This comment has been minimized.

Copy link

commented Sep 15, 2018

How would I enable DCHP leasing on this hotspot?

@ryan4volts

This comment has been minimized.

Copy link

commented Mar 11, 2019

FYI for everyone who reads things "Hostspot" is in original notes and "Hotspot" in the Note. Host vs Hot

@WallBreakerX

This comment has been minimized.

Copy link

commented Mar 27, 2019

Help a lot!

@muelli

This comment has been minimized.

Copy link

commented Jun 25, 2019

does this do IP forwarding automatically?

@sevillaarvin

This comment has been minimized.

Copy link

commented Aug 12, 2019

Found this: https://unix.stackexchange.com/questions/234552/create-wireless-access-point-and-share-internet-connection-with-nmcli

nmcli dev wifi hotspot ifname wlp4s0 ssid test password "test1234"

@AugustoCiuffoletti

This comment has been minimized.

Copy link

commented Sep 4, 2019

I'm configuring a Raspberry PI with a UMTS dongle as a standalone AP for an IoT application using the last release of Raspian (Buster light) updated. After successfully configuring the dongle (ping www.example.com successful), I tried configuring the AP, but your script fails at the very last step:

augusto@raspberrypi:~ $ sudo nmcli con up  Hotspot
[sudo] password for augusto: 
Error: Connection activation failed: No suitable device found for this connection (device eth0 not available because profile is not compatible with device (mismatching interface name)).

Maybe the following helps (with fake ssid and psk):

augusto@raspberrypi:~ $ nmcli connection show
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  2514808d-1a55-3af8-8bbf-572d9619769a  ethernet  eth0   
Hotspot            9db27d3b-a22b-4bd9-9e32-fc256963e5d2  wifi      --     
augusto@raspberrypi:~ $ sudo cat /etc/NetworkManager/system-connections/Hotspot.nmconnection
[connection]
id=Hotspot
uuid=9db27d3b-a22b-4bd9-9e32-fc256963e5d2
type=wifi
interface-name=wlan0
permissions=

[wifi]
band=bg
mac-address-blacklist=
mode=ap
ssid=myap

[wifi-security]
key-mgmt=wpa-psk
psk=1234

[ipv4]
dns-search=
method=shared

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
augusto@raspberrypi:~ $ ifconfig wlan0
wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 6a:99:14:b9:f7:df  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


Any help? Thank you!

@AugustoCiuffoletti

This comment has been minimized.

Copy link

commented Sep 5, 2019

I fixed my problem: network-manager was interfering with the native network management. The fix consisted of purging the openresolv and dhcpdc5 packages:

#  apt purge openresolv dhcpcd5

which after all looks quite obvious :-)
All is fine now with Narate solution, while sevillaarvin's one gives incomplete results.
I have posted a complete solution for the RPi as a mobile hotspot as a gist, giving credits to your one. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.