Sharing the Internet from a laptop or PC Ubuntu — a problem users face in situations where they don't have a router at hand but need to connect a smartphone, tablet, or other computer to the network. Unlike Windows, where the "Mobile Hotspot" function is built into the system, in Ubuntu This process requires manual configuration via the terminal or graphical utilities. But don't be alarmed: with the right approach, distributing Wi-Fi With Ubuntu 22.04 LTS or 24.04 LTS It can be done in 5-10 minutes, even without deep knowledge of Linux.
In this article we will look at three proven methods: the classic one hostapd And dnsmasq, simplified with nmcli (built-in network manager), as well as a graphical method through GNOME Network ManagerWe'll pay special attention to common errors—for example, when an access point is created, but devices don't connect, or the upload speed drops to zero. You'll also learn how to check the compatibility of your Wi-Fi adapter with the regime AP (Access Point) and what to do if the driver does not support this function.
Before you begin, make sure your laptop is connected to the internet via Ethernet or USB modem — You can only share a connection that is already active. If you are using Ubuntu Server without a graphical interface, focus on the first method. For desktop versions with GNOME or KDE All three options will do.
1. Checking the compatibility of the Wi-Fi adapter with the access point mode
Not all wireless adapters support operation in this mode. Access Point (AP)If your adapter is not compatible, distribute Wi-Fi If this doesn't work, the system will either return an error, or the access point will be visible, but devices won't be able to connect. To avoid wasting time, first check the capabilities of your equipment.
Open Terminal (Ctrl+Alt+T) and run the command:
iw list | grep -A 10 "Supported interface modes"
Look for the line in the output * APIf it is, your adapter supports sharing. If not, try updating the driver or using an external one. USB Wi-Fi adapter (for example, chip-based models Ralink RT5370 or Atheros AR9271 usually work without problems).
- ✅ Supported by: lines
APorP2P-client, P2P-GOin the conclusion. - ❌ Not supported: absent
AP, onlymanagedormonitor. - 🔄 Solution for unaccompanied adapters: purchase of an external module (from TP-Link, D-Link with support
AP-mode).
⚠️ Attention: On some laptops (for example, with adapters Broadcom) modeAPmay be blocked by proprietary drivers. Before setting up, remove them and install open-source alternatives viasudo apt install firmware-b43-installer(For Broadcom).
2. Method 1: Sharing Wi-Fi via hostapd and dnsmasq (universal method)
This method works on most Linux distributions and is considered the most reliable. We'll use two daemons: hostapd to create an access point and dnsmasq to distribute IP addresses to connected devices. The entire process will take about 15 minutes but requires permissions. sudo.
First, install the required packages:
sudo apt update
sudo apt install hostapd dnsmasq
Next, stop the services to configure them manually:
sudo systemctl stop hostapd
sudo systemctl stop dnsmasq
Now create a configuration file for hostapdOpen it in a text editor:
sudo nano /etc/hostapd/hostapd.conf
Insert the following template, replacing YourSSID And YourPassword to the desired network name and password:
interface=wlan0driver=nl80211
ssid=YourSSID
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=YourPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Save the file (Ctrl+O, then Ctrl+X) and specify its path in the service settings:
sudo nano /etc/default/hostapd
Find the line #DAEMON_CONF and replace it with:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Now set it up dnsmasq. Open the configuration file:
sudo nano /etc/dnsmasq.conf
Add the following lines to the end (replace wlan0 to your interface, if it is different):
interface=wlan0
dhcp-range=192.168.100.100,192.168.100.200,255.255.255.0,24h
All that remains is to set it up IP forwarding (forwarding traffic between interfaces). Open the file sysctl.conf:
sudo nano /etc/sysctl.conf
Uncomment or add the line:
net.ipv4.ip_forward=1
Apply changes:
sudo sysctl -p
Finally, add the rules iptables to forward traffic (replace eth0 to your network interface with the Internet, for example, enp3s0):
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
Start services:
sudo systemctl start hostapd
sudo systemctl start dnsmasq
Done! The hotspot should appear in the list of available networks. Connect to it from another device and test internet access.
Ping to 8.8.8.8 from a connected device|Download speed (speedtest.net)|Connection stability (no interruptions)|Access to local resources (if needed)
-->
⚠️ Attention: If the access point does not work after rebooting, the rulesiptablesare reset. To save them, install the packageiptables-persistent:sudo apt install iptables-persistent
sudo netfilter-persistent save
3. Method 2: Quick distribution via nmcli (for Ubuntu with NetworkManager)
If the first method seemed too complicated, use the built-in tool NetworkManager — nmcliThis method is simpler, but may not work on server versions. Ubuntu No graphical interface. The main advantage is that you don't need to edit configuration files manually.
First check your name Wi-Fi adapter:
ip a
Usually it is wlan0, wlp3s0 or something similar. Next, create a new access point:
sudo nmcli dev wifi hotspot ifname wlan0 ssid MyHotspot password "12345678"
Replace wlan0, MyHotspot And 12345678 to your values. If the command runs without errors, the access point is already active!
To share the Internet, turn on IP forwarding (as in the first method) and add a rule iptables:
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Check that the devices can connect. If you need to disable the hotspot, run:
sudo nmcli dev disconnect wlan0
- ⚡ Advantages of the method: quick setup, no need to manually edit configs.
- ⚠️ Restrictions: may not work on older versions NetworkManager (up to 1.4).
- 🔄 Alternative: If
nmclidoes not supporthotspot, usenmtui(text interface).
4. Method 3: Graphical interface (for GNOME/KDE)
The easiest way for users Ubuntu Desktop - using a graphical interface Network ManagerIt does not require knowledge of commands and is suitable for one-time distribution. Wi-Fi.
Open the network menu in the upper right corner of the screen (icon Wi-Fi or Ethernet). Select Network settings (or Edit Connections (in the English version). In the window that opens, click Add (Add) and select Wi-Fi.
Fill in the fields:
- 📛 Connection name: arbitrary (for example,
Ubuntu-Hotspot). - 🔗 SSID: your network name (will be displayed on devices).
- 🔐 Security mode: select
WPA & WPA2 Personal. - 🔑 Password: at least 8 characters.
- 📡 Mode:
Access Point.
After saving, go to the tab IPv4 and install:
- 🔄 Method:
Shared to other computers. - 📌 Address: leave
10.42.0.1(default).
Save the settings and activate the connection. Your hotspot should now be visible to other devices. If you're not getting internet, check that your primary connection settings (e.g., Ethernet) the parameter is enabled Allow other users to use this connection.
⚠️ Attention: In some versions GNOME (for example, in Ubuntu 24.04) optionShared to other computersmay be missing. In this case, usenmcli(method 2) or customizednsmasqmanually.
5. Common mistakes and their solutions
Even with proper setup, problems can still arise. We've compiled the most common errors and how to fix them.
| Problem | Possible cause | Solution |
|---|---|---|
| The access point is not visible on devices | Incorrect channel or mode hw_mode |
Change the channel to 6 or 11 hostapd.conf or install hw_mode=g instead of hw_mode=a |
| The devices connect, but there is no internet. | IP forwarding or rules are not configured iptables |
Check it out sysctl net.ipv4.ip_forward (should return 1) and restart iptables |
Error Failed to enable hotspot mode V nmcli |
The adapter driver does not support AP-mode |
Update the driver or use an external adapter (see section 1) |
| Low upload speed (less than 1 Mbps) | Channel congestion or weak signal | Change the channel to a less busy one (use sudo iwlist wlan0 scan for analysis) |
| The access point turns off after rebooting. | Services hostapd/dnsmasq not added to startup |
Do it sudo systemctl enable hostapd dnsmasq |
If your problem is not described in the table, check the system service logs:
journalctl -u hostapd -u dnsmasq --no-pager -n 50
Please note the lines with error or failed - They will point to the root of the problem.
What to do if the adapter does not support AP mode?
If your built-in Wi-Fi adapter does not support access point mode, you have three options:
1. Buy an external USB adapter (we recommend models with chips) Ralink RT5370 or Atheros AR9271, they usually work "out of the box").
2. Use Bluetooth sharing (through bluetoothctl), but the speed will be lower.
3. Set up distribution via Ethernet (if you only need to connect one computer).
6. Optimizing connection speed and stability
By default the access point is on Ubuntu It may perform slower than your router. This is due to driver limitations and default settings. Here are some ways to improve performance:
- 📶 Channel selection: Use commands
sudo iwlist wlan0 scan | grep Channelto find the least loaded channel.hostapd.confset it in the parameterchannel. - 🔗 Mode
hw_mode: If your adapter supports802.11n(5 GHz), installhw_mode=aAndieee80211n=1in the confighostapd. - 🔋 Energy Saving: Disable power saving for your Wi-Fi adapter:
sudo iwconfig wlan0 power off - 🛡️ Encryption: Use
WPA2-PSK(instead ofWPA+WPA2) for less load on the processor.
Critical setting for older adapters: If the upload speed does not exceed 54 Mbps, add hostapd.conf line wmm_enabled=0This will disable the Quality of Service (QoS) control mechanism, which can slow down performance on weak hardware.
To check your current speed, use nload:
sudo apt install nload
nload wlan0
If the speed is below 10 Mbps when connecting one device, the problem is most likely in the driver or channel settings.
7. Security: How to protect your access point
Distribution Wi-Fi Using a laptop is convenient, but not secure. By default, such a network is more vulnerable than a router, as it often uses weak passwords or outdated encryption protocols. Follow these recommendations to minimize the risks:
- 🔐 Complex password: Use a combination of 12+ characters with numbers, letters, and special characters. Avoid simple passwords like
12345678. - 🔄 Changing your password regularly: If you frequently share Wi-Fi in public places, change your password every few days.
- 🚫 MAC filtering: IN
hostapd.confadd a linemacaddr_acl=1and specify the allowed MAC addresses viaaccept_mac_file=/etc/hostapd/hostapd.accept. - 🛡️ Disabling WPS: Make sure there is no line in the config
wps_state=2- This protocol is vulnerable to hacking.
To check who is connected to your network, use:
sudo arp-scan --interface=wlan0 --localnet
If you see unfamiliar devices, change the password immediately and restart the access point.
⚠️ Attention: Never share Wi-Fi from your laptop on networks with sensitive data (such as corporate or banking networks). For such situations, use a separate router with a guest network.
FAQ: Frequently asked questions about sharing Wi-Fi with Ubuntu
Is it possible to distribute Wi-Fi if the Internet is connected via a USB modem (3G/4G)?
Yes, but you need to configure traffic forwarding correctly. In the commands iptables replace eth0 to the modem interface (for example, wwan0 or ttyUSB0). Also, make sure that your modem allows data sharing (some operators block this functionality).
Why did my access point stop working after updating Ubuntu?
Updates may replace configuration files hostapd or dnsmasq to default. Check if your settings have been reset and, if necessary, repeat the steps in Section 2. Also, after major updates (for example, from 22.04 to 24.04), you may need to reinstall packages.
How to share Wi-Fi from Ubuntu on a virtual machine?
Virtual machines (for example, in VirtualBox or VMware) usually don't have direct access to the host's Wi-Fi adapter. To share the network, set up Bridged Networking for the virtual adapter and use one of the described methods inside the VM. An alternative is distribution via Ethernet (if the guest OS has access to the physical network).
Is it possible to share Wi-Fi and be connected to another network at the same time?
Technically yes, but it requires support. 4addr-mode your adapter. Check the command output. iw phy0 info | grep "device supports" - if there is * AP/VLAN, then it's possible. The setup is complex and beyond the scope of this article. It's easier to use two Wi-Fi adapters: one for connection and one for sharing.
How to limit the speed for connected devices?
To limit speed, use tc (Traffic Control). For example, to limit the download to 5 Mbps for a device with IP 192.168.100.100, execute:
sudo tc qdisc add dev wlan0 root handle 1: htb default 30sudo tc class add dev wlan0 parent 1: classid 1:10 htb rate 5mbit
sudo tc filter add dev wlan0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.100.100 flowid 1:10
These rules will reset after a reboot. For permanent restrictions, add them to the startup script.