How can I create a Wi-Fi hotspot with the command line tool nmcli and share/bridge the ethernet internet connection with the wireless access point? Furthermore, how can I start this automatically at boot?

Is this possible with nmcli?


You can create a hotspot with:

nmcli dev wifi hotspot ifname wlp4s0 ssid test password "test1234"
| improve this answer | |
  • 1
    Simplest answer, yet so effective. Thank you. – oidualc Apr 27 '18 at 9:31
  • 1
    Thank you so much for this answer, amazingly simple and works great. – Guido Sep 15 '18 at 9:55
  • does this do ip forwarding via a (cabled?) connection? – Frederick Nord Jun 25 '19 at 12:51
  • > does this do ip forwarding via a (cabled?) connection? - Yes – Michael Nikitochkin Mar 25 at 20:02
  • It does not completely answer the question. – BuZZ-dEE Apr 24 at 21:43

On a Centos 7 it looks like this.

Check if AP is possible at all:

iw list | less

and search for "AP" among supported interface modes.

Browse your devices to find the name:

nmcli d

And setup and start your hotspot.

Mind that wifi-device, connection-name and hotspot-ssid are specific to your system.

nmcli c add type wifi ifname wifi-device con-name connection-name autoconnect no ssid hotspot-ssid
nmcli connection modify connection-name 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli connection modify connection-name wifi-sec.key-mgmt wpa-psk
nmcli connection modify connection-name wifi-sec.psk "le password"
nmcli connection up connection-name

Check also:

| improve this answer | |

I created a Hotspot with the GNOME Network-Manager. The problem was, that I can not configure the SSID and password in GUI. If you create the Hotspot with the Network-Manager GUI, it creates the file /etc/NetworkManager/system-connections/Hotspot. In that file it is possible to edit the SSID and the password.

sudo vim /etc/NetworkManager/system-connections/Hotspot

The content of the file looks like this:






I changed the ssid and the psk properties to my needs. To enable autostart you have to set the parameter autoconnect to true. Then I restarted my computer because the command: sudo systemctl restart NetworkManager for network restart seems not to work correctly, because in the Network-Manager GUI:

wireless settings gone

I have no wireless network settings anymore and also the following command worked not before the restart. After restart you can use the nmcli command to start the access point.

nmcli con up Hotspot ifname YOUR_WIFI_INTERFACE

YOUR_WIFI_INTERFACE you can find out with the command iwconfig.

I used Antergos / Arch Linux for the above solution and found the hint to this at the ask.fedoraproject.org site.

| improve this answer | |

I know this is an old question, but thought I would add my comments as this may help someone in the future.

The whole process is just three commands as @Dzik has correctly mentioned.

nmcli connection add type wifi ifname wlan0 con-name local-ap autoconnect yes ssid test-ap mode ap
nmcli connection modify con-name 802-11-wireless.mode ap 802-11-wireless-security.key-mgmt wpa-psk ipv4.method shared 802-11-wireless-security.psk 'PASSWORD'
nmcli connection up con-name

This will start an AP for you.

To verify, we can use:

nmcli dev wifi list
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.