Ubuntu 22.04 configure Access Point by shell commands
with NMCLI command line you can create your own access point with a few commands :
1 2 3 4 5 6 |
nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid MioSSID nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234" nmcli con modify Hostspot ipv4.method manual ipv4.addresses 192.168.42.1/24 nmcli con up Hostspot |
make sure with “nmcli connection show” that you haven’t left halfway configurations or double configurations, in case you can remove them with “nmcli connection delete Hostspot”
The only flaw of nmcli is that it does not have a specific command to directly set the DHCP service that supports the newly configured AP and to do this you need to install and configure a service that takes care of this, such as “dnsmasq”:
1 |
sudo apt install dnsmasq |
edit the configuration file “dnsmasq.conf”
1 |
sudo nano /etc/dnsmasq.conf |
personalli i modified only some lines in the configuration file:
1 2 3 |
Port=5353 interface=wlo1 dhcp-range=192.168.42.100,192.168.42.200,12h |
restart service:
1 |
sudo service dnsmasq restart |
check WiFi state:
1 |
iw dev |
reboot your system and check it all