Setting Hotspot on Ubuntu 22.04-based Embedded Device
In this article, we will explore the process of setting up a hotspot on an Ubuntu 22.04-based embedded device. This can be a useful feature for sharing an internet connection with other devices or creating a local network. However, we encountered an issue where clients connected to the hotspot were unable to access the internet.
Prerequisites
Before we begin, make sure you have the following:
- An Ubuntu 22.04-based embedded device
- An active internet connection on the device
Setting Up the Hotspot
To set up the hotspot, we will use the nmcli command, which is a part of the network-manager package. If you don't have it installed, you can install it using the following command:
sudo apt-get install network-manager
Once network-manager is installed, you can create a new hotspot using the following command:
sudo nmcli device wifi create hotspot ssid MyHotspot password MyPassword
Replace MyHotspot and MyPassword with the desired SSID and password for the hotspot.
Issue: Clients Cannot Connect to the Internet
After setting up the hotspot, we found that clients connected to the hotspot were unable to access the internet. We spent a lot of time trying to resolve this issue, but were unable to find a solution using nmcli.
Alternative Solution
As an alternative, we can set up the hotspot using the hostapd and dnsmasq packages. To install these packages, use the following commands:
sudo apt-get install hostapd dnsmasq
Next, we need to create a new configuration file for hostapd and dnsmasq. You can create a new file called hotspot.conf using your favorite text editor, and add the following contents:
# hotspot.conf
# Hostapd Configuration
interface=wlan0
driver=nl80211
ssid=MyHotspot
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
psk=MyPassword
# Dnsmasq Configuration
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.20,24h
dhcp-option=option:router,10.0.0.1
dhcp-option=option:dns,10.0.0.1
Replace MyHotspot and MyPassword with the desired SSID and password for the hotspot.
Next, we need to start the hostapd and dnsmasq services using the following commands:
sudo systemctl start hostapd
sudo systemctl start dnsmasq
You can check the status of the services using the following commands:
sudo
```