Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Linux / Turn Linux Computer into Wi-Fi Access Point (Hotspot)

June 7, 2023 LinuxUbuntu

Turn Linux Computer into Wi-Fi Access Point (Hotspot)

In this article, we will show how to create a Wi-Fi access point (Software AP) on any computer or laptop running Linux and equipped with a wireless adapter. You can use this access point (hotspot) to create a wireless local network in a small office or at home, or to share mobile Internet with other devices. In this example, we are using a laptop running the latest version of Ubuntu.

Contents:
  • How to Create Wi-Fi Hotspot from Ubuntu GUI?
  • Configure Wireless Access Point with Network Manager (nmcli) on Linux
  • Using Hostapd to Set Up a Virtual WiFi Access Point on Linux

First, make sure that your wireless Wi-Fi module supports an Access Point (AP) mode. To do it, install iw package:

$ sudo apt install iw

The iw tool is used to configure wireless interfaces (nl80211 driver) from the command prompt. It supports all new drivers recently added to the Linux kernel. The old iwconfig tool, which uses the Wireless Extensions interface, is deprecated, so it is strongly recommended that you use iw and nl80211 instead.

Run the command below:

$ iw list

iw: check supported wireless inerface modes

In the Supported interface modes section, look for

  • AP
  • AP/VLAN

It means that your Wi-Fi adapter supports operation in the access point mode.

How to Create Wi-Fi Hotspot from Ubuntu GUI?

On Ubuntu 20.04 LTS and newer with GNOME (3.28+), you can run a wireless access point from the graphic interface. This is the easiest method for the average user.

Click the network connection icon and select Turn On Wi-Fi Hotspot in the Wi-Fi settings.

Wi-Fi settings in Gnome on Ubuntu

Turn On Wi-Fi Hotspot on Ubuntu

Enter the access point name and connection key (password)

Set the SSID (name) and the password for the Wireless Access Point

You should see a message that your access point is active. The same window contains a QR code to connect to your Wi-Fi access point.

generate wi-fi qr code on linux

Configure Wireless Access Point with Network Manager (nmcli) on Linux

Network Manager can be used to manage network connections in most modern Linux distros (Ubuntu, Debian, Mint, Fedora, CentOS, etc.). In this example, we will show how to create a software access point on Linux using the Network Manager and nmcli command line tool.

First, you need to find out the name of your wireless adapter in the system.

$ nmcli d

get wireless adapter name on ubuntu linux

In our example, the name of the Wi-Fi adapter is wlp4s0b1.

If dnsmasq (a light-weight DHCP/DNS server) is installed on your computer, you must disable it. It will conflict with the dnsmasq plugin in the NetworkManager.

To create an access point on the wlp4s0b1 interface with the network name (SSID) WOSHubWiFi and a network key (password) MaxPass21, run the commands below:

# nmcli con add type wifi ifname wlp4s0b1 mode ap con-name MyHomeWiFI ssid WOSHubWiFi
# nmcli con modify MyHomeWiFI 802-11-wireless.band bg
# nmcli con modify MyHomeWiFI 802-11-wireless.channel 1
# nmcli con modify MyHomeWiFI 802-11-wireless-security.key-mgmt wpa-psk
# nmcli con modify MyHomeWiFI 802-11-wireless-security.proto rsn
# nmcli con modify MyHomeWiFI 802-11-wireless-security.group ccmp
# nmcli con modify MyHomeWiFI 802-11-wireless-security.pairwise ccmp
# nmcli con modify MyHomeWiFI 802-11-wireless-security.psk MaxPass21
# nmcli con modify MyHomeWiFI ipv4.method shared

Start your hotspot:
# nmcli con up WOSHubWiFi

Use nmcli on ubuntu to start wireless hotspot

If you want the access point to operate at 5GHz and use a higher channel, change the corresponding commands to:

# nmcli con modify MyHomeWiFI 802-11-wireless.band a
# nmcli con modify MyHomeWiFI 802-11-wireless.channel 35

By default, the built-in DHCP server in the NetworkManager assigns IP addresses to clients from the 10.42.0.x/24 range (and the 10.24.0.1 is the address of your hotspot interface). You can change the DCHP range:

# nmcli con modify MyHomeWiFI ipv4.addr 192.168.31.1/24

To disable the access point, run this command:

# nmcli con down MyHomeWiFI

For complete removal of software hotspot on Linux:

# nmcli con delete MyHomeWiFI

Using Hostapd to Set Up a Virtual WiFi Access Point on Linux

A popular tool for creating a Wi-Fi access point on Linux computers is the hostapd package. Install it:

$ sudo apt install hostapd

Copy the original configuration file (/etc/hostapd/hostapd.conf). Add the following configuration to hostapd.conf:

$ sudo nano /etc/hostapd/hostapd.conf

interface= wlp4s0b1
# The nl80211 driver is suitable for most Wi-Fi adapters
driver=nl80211
# Your access point name
ssid=MyHomeAP
# The number of your Wi-Fi channel (1 to 13)
channel=11
#Select a mode for your access point (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g)
hw_mode=g
# 1=wpa, 2=wep, 3=both
auth_algs=1
# Allow connections from all MAC addresses except those in the blacklist
macaddr_acl=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
#Set a password for your access point
wpa_passphrase=MyPass321
If you want to use 802.11 n mode, make the changes below:

ieee80211n=1
ht_capab=[HT40-][SHORT-GI-40]

Unmask the hostpad service:

$ sudo systemctl unmask hostapd

Then specify the path to your configuration file in the DAEMON_CONF parameter of /etc/default/hostapd file:

$ sudo nano /etc/default/hostapd

DAEMON_CONF="/etc/hostapd/hostapd.conf"

configure hostapd on linux

Then configure your wireless network interface. Set a static IP address, DNS, mode, and other options. Edit the /etc/network/interfaces file and add the following:

# nano /etc/network/interfaces

auto wlp3s0
iface wlp3s0 inet static
address 10.10.0.1
netmask 255.255.255.0

You will also need it to prevent NetworkManager from interfering with the Wi-Fi interface. After saving the settings, restart your computer.

Then you just have to configure a DHCP server that will assign IP addresses to the devices connecting to your Linux access point. In our example, we will use a light-weight dnsmasq:

$ sudo apt install dnsmasq

Edit dnsmasq.conf. Specify that dnsmasq will run on the wlp4s0b1 interface and assign IP addresses from the 10.10.0.x range. In the simplest case, you may have the following configuration:

$ sudo nano /etc/dnsmasq/dnsmasq.conf

interface=wlp4s0b1
dhcp-range=10.10.0.2,10.10.0.100,12h
#Set DNS servers
server=/www.google.com/8.8.8.8
The DHCP range IP addresses must belong to the same network as your WLAN adapter.

In order for your Linux host can route packets between the Wi-Fi clients and an external Internet connection, you need to enable the routing and add the corresponding rule to iptables:

sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o enp3s0 -j MASQUERADE
You can also use the bridge interface to provide Internet access to clients from your local network (we will leave this out to keep the article short).

Start these services:

# systemctl start dnsmasq.service
# systemctl start hosapd

Now you can connect to your access point from any client, check that it has received an IP address from the specified DHCP range and that it can access the Internet.

Find out how to set up a Wi-Fi access point on a Windows computer.

1 comment
2
Facebook Twitter Google + Pinterest
previous post
Updating PowerShell Version on Windows
next post
Running Simple HTTP Web Server Using PowerShell

Related Reading

How to Increase Size of Disk Partition in...

October 5, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Fixing ‘The Network Path Was Not Found’ 0x80070035...

August 30, 2023

How to Install and Configure Ansible on Linux

August 27, 2023

Monitoring Domain Name Expiration Date with Zabbix

August 14, 2023

1 comment

Merlin September 20, 2023 - 11:26 am

Thanks a lot for this post.
Do you know what are the pros/cons using hostapd vs networkManager ?
or do you have any documentation highlighting this diffrences ?

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fixing ‘The Network Path Was Not Found’ 0x80070035 Error Code on Windows
  • Recovering Files from BitLocker Encrypted Drive
  • How to Access VMFS Datastore from Linux, Windows, or ESXi
  • Using iPerf to Test Network Speed and Bandwidth
  • Installing an Open Source KMS Server (Vlmcsd) on Linux
  • Monitoring Domain Name Expiration Date with Zabbix
  • How to Enable Two-Factor Authentication (2FA) for SSH on Linux
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top