How to Share Wi-Fi with Linux: A Setup Guide

Turning a laptop or Linux system into a hotspot isn't just a technical whim, but often a vital function. Situations vary: a hotel only charges for one device, but you need to connect your phone and tablet, or the company router suddenly breaks down and you urgently need to provide internet access to your colleagues. Linux distributions, thanks to their flexibility, allow you to implement this scenario as efficiently as possible, using the built-in capabilities of the kernel and network managers.

Unlike proprietary systems, here you have full control over the network creation process. You can customize WPA3 encryption, limit the number of connecting clients, or even run a hidden network without broadcasting the network name (SSID). However, despite the power of these tools, the setup process can seem confusing due to the abundance of methods, from graphical interfaces to the command line. We'll cover the most current and stable methods that work on modern distributions.

Before moving on to specific commands, it is important to understand that the success of the operation directly depends on your Wi-Fi adapterNot all network cards support Master Mode, which is necessary for signal distribution. Some older models can only operate in client mode, making it impossible to create an access point at the hardware level. Checking compatibility is the first and most important step, saving you hours of pointless configuration file debugging.

Checking access point mode support

First, you need to make sure your wireless interface is physically capable of working in Distributed mode. There's a utility for this in Linux. iw, which provides detailed information about driver and hardware capabilities. Running the check requires superuser privileges, as we access low-level hardware settings.

Run the command iw list in the terminal. The output will be voluminous, so it's best to filter it by finding the "Supported interface modes" section. If the word "AP" (Access Point), which means your card supports access point mode. It's also worth checking for 5 GHz support if you plan to create a high-speed network, although the 2.4 GHz band remains the only option for compatibility with older devices.

Sometimes a driver may report support for a mode, but it will operate unstable. This is especially common with some chips. Realtek And MediaTek, where proprietary drivers may conflict with the open-source kernel. In such cases, updating the kernel or replacing the driver with a more recent version from the manufacturer's repositories can help.

⚠️ Note: If the iw list command output doesn't show AP mode, software workarounds like hostapd are unlikely to help. In this case, the only solution is to purchase an external USB Wi-Fi adapter with guaranteed Linux support, such as one based on Atheros or Ralink chips.

Configuration via NetworkManager (GUI and CLI)

The easiest and most recommended way for most users of modern distributions (Ubuntu, Fedora, Mint, Debian) is to use NetworkManagerThis tool is already integrated into the system and manages connections, with a built-in hotspot feature. You don't need to install any additional software if you're using the standard desktop environment.

In the graphical interface, the process is trivial: click the network icon in the system tray and select "Wi-Fi Settings." The menu usually includes a "Use as Hotspot" button. The system will prompt you to set a network name (SSID) and password. Once activated, NetworkManager will automatically switch the adapter to the appropriate mode and start the DHCP server to distribute IP addresses.

For those who like terminal or server versions of OS, there is a utility nmcli (NetworkManager command line interface). It allows you to create connection profiles that are saved and automatically launched at system startup. This is ideal for headless servers, where there is no graphical interface.

☑️ Create an access point using nmcli

Completed: 0 / 4

When using the command line, it's important to set the security settings correctly. By default, NetworkManager may create an open network, which is insecure. Make sure you set the encryption method. wpa-psk and set a strong password. It's also worth remembering that when creating a new access point, the old internet connection (if it was via Wi-Fi) will be lost, as a single card cannot simultaneously receive and transmit a signal on the same frequency without special hardware support.

Parameter Description Example of meaning
con-name Connection profile name HomeHotspot
ssid Network name to search (SSID) MyLinuxWifi
802-11-wireless.mode Adapter operating mode ap
ipv4.method IP assignment method shared

Using Hostapd and Dnsmasq

If the standard system tools seem insufficiently flexible to you, or you are setting up a specialized device (for example, a Raspberry Pi in router mode), then the bundle hostapd And dnsmasq is the gold standard. Hostapd is responsible for creating an access point and managing clients, while dnsmasq handles DHCP server and DNS caching functions.

Installation of packages in Debian/Ubuntu is performed by the command sudo apt install hostapd dnsmasq. The hostapd configuration requires the creation of a file /etc/hostapd/hostapd.conf. It specifies the interface parameters, driver (usually nl80211), frequency channel, and WPA2 security parameters. This provides fine-grained control over network behavior, including setting VLAN prefixes and radius servers.

interface=wlan0

driver=nl80211

ssid=MyCustomNetwork

hw_mode=g

channel=6

wmm_enabled=0

macaddr_acl=0

auth_algs=1

ignore_broadcast_ssid=0

wpa=2

wpa_passphrase=StrongPassword123

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP

rsn_pairwise=CCMP

After setting up hostapd, you need to configure dnsmasq to distribute addresses. In the file /etc/dnsmasq.conf You need to disable DNS caching (if not needed) and specify the range of IP addresses to be issued. It is also critically important to configure IP-tables (or nftables) for forwarding traffic (NAT) from the created Wi-Fi network to the main interface with Internet access.

Why might hostapd fail to start?

A common cause is a conflict with the network manager (NetworkManager or systemd-networkd). They are attempting to manage the wlan0 interface simultaneously. Solution: add the "unmanaged-devices" rule to the NetworkManager configuration for your interface or completely disable Wi-Fi management in NM.

Compatibility and driver issues

The world of Linux drivers is diverse, and Wi-Fi issues are a classic. Most often, difficulties arise with adapters that require proprietary "blob" drivers. Symbolic links, monitor modes, and access point modes can conflict. If you see the error "nl80211: Could not configure driver mode," this almost always indicates that the driver doesn't support switching to AP mode.

Particular attention should be paid to chips Broadcom and some models RealtekThey often require manual installation of drivers from the repository. dkms. For example, a package rtl8812au-dkms Often necessary for USB dongles. Without the correct driver, the card may be detected by the system but will not be able to initiate master mode.

Another nuance is regulatory restrictions. Different countries allow different frequencies and power levels. Linux strictly adheres to region settings (country code). If your adapter is locked to a region where channel 13 is prohibited, and you try to run an access point on it, the network will simply not work. You can check and set the region using the command iw reg set RU (or US, DE, etc.).

⚠️ Note: Network configuration interfaces and package names may vary depending on your distribution version and desktop environment. Always check your distribution's official documentation (Arch Wiki, Ubuntu Server Guide) for up-to-date package names, as configuration methods may be updated.

📊 Which Wi-Fi sharing method do you prefer to use?
Built-in NetworkManager (GUI)
nmcli command line
Hostapd + Dnsmasq
I'm just buying a router.

Network Address Translation (NAT)

Creating a network isn't enough; you need to provide access to the global network. This is achieved using the NAT (Network Address Translation) mechanism. In Linux, this is handled by the kernel and a utility. iptables (or its modern replacement nftables). The idea is simple: packets from connected clients must be rewritten so that to the outside world they appear to be coming from your main interface.

If you are using NetworkManager with the method ipv4.method shared, the system will automatically configure all the necessary forwarding rules. However, if you configure it manually via hostapd, you'll have to do it yourself. The command looks something like this: iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE, Where eth0 — this is your interface with the Internet (wired or other Wi-Fi).

Don't forget to enable IP packet forwarding in the kernel. Parameter net.ipv4.ip_forward should be set to 1. This can be done temporarily with the command sysctl -w net.ipv4.ip_forward=1 or permanently, by writing the value in /etc/sysctl.confWithout this step, traffic will reach the gateway but will not be transmitted further.

Network diagnostics and security

After launching the access point, it is important to ensure its functionality and security. Use utilities iw dev wlan0 station dump to view connected clients and signal strength. This will help you determine if there are coverage issues or channel congestion. If clients are dropping, it might be worth switching to a less congested channel.

Security issues here are just as pressing as with regular routers. WEP is long outdated and can be hacked in minutes. At a minimum— WPA2-PSK, and ideally - WPA3, if your equipment and clients support it. It's also a good idea to disable WPS, as this protocol often contains vulnerabilities.

Advanced users will appreciate the MAC address filtering capabilities. While MAC addresses can be spoofed, this creates an additional barrier to unauthorized access. In hostapd, this is implemented via a file. hostapd.accept or hostapd.deny, where the addresses of permitted devices are entered.

In conclusion, Wi-Fi sharing on Linux is a powerful tool that turns your computer into a versatile network hub. Whether it's a temporary solution for the office or a permanent smart home setup, Linux provides all the necessary tools to accomplish these tasks.

Is it possible to share Wi-Fi if the laptop is connected to the Internet via Wi-Fi?

Technically, a single physical Wi-Fi card can't simultaneously receive and transmit a signal on the same frequency. However, modern drivers and cards support interface virtualization. You can create a virtual access point, but this often results in a significant speed drop (up to 50% or more) because the card operates in time-sharing mode. It's more reliable to use Ethernet for input and Wi-Fi for distribution.

Why don't phones see the created network?

A common cause is a frequency band mismatch. If you've created a network only in the 5 GHz band, older devices won't see it. Also, check the channel: some devices (especially Android) ignore channels above 11 in the 2.4 GHz band if the region is configured incorrectly. Try hard-coding channels 1-6.

How can I make the access point turn on automatically?

When using NetworkManager, the profile is saved and should connect automatically. For hostapd, you need to add the service to systemd (usually hostapd.service) and make sure it is enabled with the command systemctl enable hostapdIt is also necessary to configure dnsmasq to start and apply iptables rules at system startup.