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: First, make sure that your wireless Wi-Fi module supports an Access Point (AP) mode. To do it, install iw package:
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:
In the Supported interface modes section, look for
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. Enter the access point name and connection key (password) 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. Configure Wireless Access Point with Network Manager (nmcli) on LinuxNetwork 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.
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:
If you want the access point to operate at 5GHz and use a higher channel, change the corresponding commands to:
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:
To disable the access point, run this command:
For complete removal of software hotspot on Linux:
Using Hostapd to Set Up a Virtual WiFi Access Point on LinuxA popular tool for creating a Wi-Fi access point on Linux computers is the hostapd package. Install it:
Copy the original configuration file (/etc/hostapd/hostapd.conf). Add the following configuration to 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:
Then specify the path to your configuration file in the DAEMON_CONF parameter of /etc/default/hostapd file:
DAEMON_CONF="/etc/hostapd/hostapd.conf" 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:
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:
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:
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:
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.
|
|