How to Create Wi-Fi Hotspot on Linux

In this article,we will show you How to Create WiFi Hotspot on Linux(Ubuntu/Debian/Fedora/CentOS/Arch) Linux machine using nmcli command line network management tool. This method works for many Linux distributions.

The nmcli (NetworkManager Command Line Interface) command-line utility is used for controlling NetworkManager and reporting network status. You can use nmcli to create, display, edit, delete, activate, and deactivate network connections, and to control and display network device status.

Create Wi-Fi Hotspot On Linux

Step 1: Identify WiFi network device

First,Get a name of the Wi-Fi network interface, type the following command:

ip link show

Output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether e8:6a:64:86:44:cc brd ff:ff:ff:ff:ff:ff
3: wlp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 20:79:18:5e:4b:60 brd ff:ff:ff:ff:ff:ff
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:8e:f6:e5 brd ff:ff:ff:ff:ff:ff
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:8e:f6:e5 brd ff:ff:ff:ff:ff:ff
6: br1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:bd:90:53 brd ff:ff:ff:ff:ff:ff
7: br1-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master br1 state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:bd:90:53 brd ff:ff:ff:ff:ff:ff

My device is named wlp6s0, this will surely vary from machine to machine. If it is working, the following command should give you output.

iw list

Step 2: Create a new hotspot

Create a network profile for your Hotspot.

$ IFNAME="wlp6s0"
$ CON_NAME="myhotspot"
$ nmcli con add type wifi ifname $IFNAME con-name $CON_NAME autoconnect yes ssid $CON_NAME

Step 3: Set connection Method

Set the connection method as shared.

$ nmcli con modify $CON_NAME 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared

Step 4: Set Hotspot password

We don’t want our hotspot open to the public, so let’s set a passphrase for it.

nmcli con modify $CON_NAME wifi-sec.key-mgmt wpa-psk
nmcli con modify $CON_NAME wifi-sec.psk "MyStrongHotspotPass"

Bring up the connection when done.

$ nmcli con up $CON_NAME

Output:

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)

Check a detailed connection information.

$ nmcli connection show $CON_NAME

Step 5: Confirm IP information.

Check interface and ip information.

nmcli connection show

Output:

NAME                     UUID                                  TYPE      DEVICE    
Hostspot                 ad31dc08-9175-4fe2-85e3-9f33324e1447  wifi      wlp6s0    

$ ip ad show wlp6s0
3: wlp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 20:79:18:5e:4b:60 brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.1/24 brd 10.42.0.255 scope global noprefixroute wlp6s0
       valid_lft forever preferred_lft forever
    inet6 fe80::a119:b393:761c:d740/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

You can now scan Wireless connection from your end devices and connect to it.

Conclusion

In this tutorial, you’ve learned how to create wifi hotspot on linux.try it now!

Leave a Reply

Your email address will not be published. Required fields are marked *