0

I'm trying to set up a AP by using hostapd and I was unable to even after following the tutorial notes step by step: After running hostapd with dnsmasq The AP gets advertised on the air, but attempting to connect one station to it , despite ackonwledging the handshake between the nodes I get the error

nl80211: Frame command failed: ret=-22 (Invalid argument) (freq=2432 wait=0)

Steps I followed

vim hostapd.conf
interface=wlan0
driver=nl80211
ssid=myhotspot
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=KeePGuessinG
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
vim /etc/dnsmasq.conf 
interface=wlan1
dhcp-range=192.168.0.50,192.168.0.150,12h
# Setup the interface
$ ip link set wlp5s0 down
$ ip addr flush dev wlp5s0
$ ip link set wlp5s0 up
$ ip addr add 10.0.0.1/24 dev wlan0
# start hostapd
$ sudo killall dnsmasq; dnsmasq
$ sudo hostapd

Then I attempt the connection from Client"A" and sudo systemctl status networkmanager

DHCPDISCOVER on wls1 to 255.255.255.255 port 67 interval 9
dhcp4 request timed out

On the server if I do sudo tcpdump -nnvv -i wlan1 port 67

02:45:38.207802 IP (tos 0x0, ttl 64, id 3994, offset 0, flags [none], proto UDP (17), length 368)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from 56:27:fc:a1:04:80, length 340, xid 0x30e4e005, secs 189, Flags [none] (0x0000)
          Client-Ethernet-Address 56:27:fc:a1:04:80
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Discover
            Client-ID Option 61, length 7: ether 56:27:fc:a1:04:80
            SLP-NA Option 80, length 0""
            NOAUTO Option 116, length 1: Y
            MSZ Option 57, length 2: 1472
            Vendor-Class Option 60, length 44: "dhcpcd-8.1.2:Linux-5.4.79-v7+:armv7l:BCM2835"
            Hostname Option 12, length 11: "raspberrypi"
            T145 Option 145, length 1: 1
            Parameter-Request Option 55, length 14:
              Subnet-Mask, Classless-Static-Route, Static-Route, Default-Gateway
              Domain-Name-Server, Hostname, Domain-Name, MTU
              BR, Lease-Time, Server-ID, RN
              RB, Option 119
nl80211: Frame command failed: ret=-22 (Invalid argument) (freq=2432 wait=0)
7
  • even after following the tutorial notes which tutorial? – Dirk Jan 13 at 5:10
  • last updated more than 2 years ago. I would suggest you try a more recent one first. Or maybe start off with the RPF documentation? – Dirk Jan 13 at 14:01
  • Ok it's solved , there were two issues on the dnsmasq service.1) The service was failing to initiate as the own initiation of dnsmasq created a process on top stepping on the same Ports (you just need to sudo kill <dnsmasqPID> and sudo systemctl restart dnsmasq . 2nd) I've got the IP range of /etc/dnsmasq.conf missconfigured . Now they are on the same subnet so dnsmasq.service works accordingly. Thanks – freddie_ventura Jan 13 at 14:13
  • The problem is still on , but I should re-write the question. Now I'm able to connect a station , but it doesn't last more than 3 minutes . hostapd suddenly bings the AP down , with the following error nl80211: Frame command failed: ret=-22 (Invalid argument) (freq=2437 wait=0) – freddie_ventura Jan 13 at 14:38
0

So mainly I was doing three things wrong in here, so in order for you to not to have the same mistakes here I disclose them:

1st) Double check the DHCP adress range lease on sudo vim /etc/dnsmasq.conf to be on the same subnet than the ip that you previously assign to your AP device (when you raise the interface) (remember than before activating hostapd you need to assign an ip with this line of commands):

sudo ip link set <devicename> down
sudo ip addr flush dev <devicename> 
sudo ip link set <devicename> up
sudo ip addr add 192.168.1.1/24 dev <devicename>

For this IP you should have

sudo vim /etc/dnsmasq.conf
interface=<devicename>
dhcp-range=192.168.1.50,192.168.1.150,12h

2nd) Dont start dnsmasq directly as a normal process but rely on it as a daemon, so anytime you have done a change on /etc/dnsmasq.conf just sudo systemctl restart dnsmasq , if you have any problems you should check the output of this daemon on sudo systemctl status dnsmasq

3rd) The important step I was missing!! . hostapd will have conflict with NetworkManager if this lastone is still managing the NIC , hostapd will initiate the AP but will drop the connection misteriously at 2 mins of having created it. Solution. Unmanage the NIC by NetworkManager , there are 2 ways of doing this:

  • nmcli: sudo nmcli device set ifname <devicename> managed no This solution will not be persistent
  • A persistant solution will be altering the NetworkManager.conf adding the following lines
sudo vim /etc/NetworkManager/NetworkManager.conf
[keyfile]
unmanaged-devices=interface-name:<devicename>

Then you should restart NetworkManager daemon sudo systemctl restart network-manager

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.