0

I would like to make router from my Raspberry Pi 3B+ using built-in wifi.

After installing the OS, I made update, upgrade and installed packages: sudo apt update -y && sudo apt upgrade -y && sudo apt install dnsmasq hostapd rng-tools -y

I configured static IP by adding:

interface wlan0
static ip_address=192.168.130.13/24
static routers=192.168.130.1
static domain_name_servers=192.168.130.1

to /etc/dhcpcd.conf file.

Then I created /etc/hostapd/hostapd.conf file:

interface=wlan0
driver=nl80211
ssid=PI-AP
wpa=2
wpa_passphrase=raspberry
channel=6

and after running sudo hostapd /etc/hostapd/hostapd.conf ssid of this network should be visible on my phone, but its not. I only got this error:

random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: TDLS supported
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported cipher 00-0f-ac:6
nl80211: Using driver-based off-channel TX
nl80211: Supported vendor command: vendor_id=0x1018 subcmd=1
nl80211: Use separate P2P group interface (driver advertised support)
nl80211: Enable multi-channel concurrent (driver advertised support)
nl80211: use P2P_DEVICE support
nl80211: interface wlan0 in phy phy0
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Setup AP(wlan0) - device_ap_sme=0 use_monitor=1
nl80211: Create interface iftype 6 (MONITOR)
Failed to create interface mon.wlan0: -95 (Operation not supported)
nl80211: Driver does not support monitor interface type - try to run without it
nl80211: Enable Probe Request reporting nl_preq=0x191f688
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x191f688 match=
nl80211: Register frame command failed (type=64): ret=-22 (Invalid argument)
nl80211: Register frame match - hexdump(len=0): [NULL]
nl80211: Failed to enable Probe Request frame reporting in AP mode
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Add own interface ifindex 3 (ifidx_reason -1)
nl80211: if_indices[16]: 3(-1)
phy: phy0
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz 20 mBm
nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR)
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)
nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR)
nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR)
nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)
nl80211: 57240-63720 @ 2160 MHz 0 mBm
nl80211: Added 802.11b mode based on 802.11g information
Completing interface initialization
Mode: IEEE 802.11b  Channel: 6  Frequency: 2437 MHz
DFS 0 channels required radar detection
nl80211: Set freq 2437 (ht_enabled=0, vht_enabled=0, bandwidth=20 MHz, cf1=2437 MHz, cf2=0 MHz)
  * freq=2437
  * vht_enabled=0
  * ht_enabled=0
  * channel_type=0
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x0
RATE[3] rate=110 flags=0x0
hostapd_setup_bss(hapd=0x191ea48 (wlan0), first=1)
wlan0: Flushing old station entries
nl80211: flush -> DEL_STATION wlan0 (all)
nl80211: Station flush failed: ret=-14 (Bad address)
wlan0: Could not connect to kernel driver
wlan0: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlan0 ff:ff:ff:ff:ff:ff --> 0 (Success)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=0)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=1)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=2)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-22 Invalid argument)
Failed to clear default encryption keys (ifname=wlan0 keyidx=3)
Using interface wlan0 with hwaddr b8:27:eb:cb:9a:02 and ssid "PI-AP"
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=5):
     50 49 2d 41 50                                    PI-AP           
PSK (ASCII passphrase) - hexdump_ascii(len=9): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVED]
random: Got 20/20 bytes from /dev/random
GMK - hexdump(len=32): [REMOVED]
Key Counter - hexdump(len=32): [REMOVED]
WPA: Delay group state machine start until Beacon frames have been configured
nl80211: Set beacon (beacon_set=0)
nl80211: Beacon head - hexdump(len=52): 80 00 00 00 ff ff ff ff ff ff b8 27 eb cb 9a 02 b8 27 eb cb 9a 02 00 00 00 00 00 00 00 00 00 00 64 00 11 00 00 05 50 49 2d 41 50 01 04 82 84 0b 16 03 01 06
nl80211: Beacon tail - hexdump(len=28): 30 14 01 00 00 0f ac 02 01 00 00 0f ac 02 01 00 00 0f ac 02 00 00 7f 04 00 00 00 02
nl80211: ifindex=3
nl80211: beacon_int=100
nl80211: dtim_period=2
nl80211: ssid - hexdump_ascii(len=5):
     50 49 2d 41 50                                    PI-AP           
  * beacon_int=100
  * dtim_period=2
nl80211: hidden SSID not in use
nl80211: privacy=1
nl80211: auth_algs=0x3
nl80211: wpa_version=0x2
nl80211: key_mgmt_suites=0x2
nl80211: pairwise_ciphers=0x8
nl80211: group_cipher=0x8
nl80211: beacon_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: proberesp_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: assocresp_ies - hexdump(len=6): 7f 04 00 00 00 02
WPA: Start group state machine to set initial keys
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
GTK - hexdump(len=32): [REMOVED]
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=2 addr=0xd4108 key_idx=1 set_tx=1 seq_len=0 key_len=32
nl80211: KEY_DATA - hexdump(len=32): [REMOVED]
   broadcast key
nl80211: Set wlan0 operstate 0->1 (UP)
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
Failed to set TX queue parameters for queue 0.
Failed to set TX queue parameters for queue 1.
Failed to set TX queue parameters for queue 2.
Failed to set TX queue parameters for queue 3.
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
wlan0: Setup of interface done.
ctrl_iface not configured!
RTM_NEWLINK: ifi_index=3 ifname=wlan0 wext ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=5 linkmode=0 ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
nl80211: Set IF_OPER_UP again based on ifi_flags and expected operstate
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
nl80211: Drv Event 48 (NL80211_CMD_DISCONNECT) received for wlan0
nl80211: Disconnect event
wlan0: Event DEAUTH (12) received
hostapd_notif_disassoc: Skip event with no address
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: vlan_newlink(wlan0)
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 20 (NL80211_CMD_DEL_STATION) received for wlan0
nl80211: Delete station 74:da:38:0e:ce:19
wlan0: Event DISASSOC (1) received
wlan0: STA 74:da:38:0e:ce:19 IEEE 802.11: disassociated
Disassociation notification for unknown STA 74:da:38:0e:ce:19
nl80211: Drv Event 36 (NL80211_CMD_REG_CHANGE) received for wlan0
nl80211: Regulatory domain change
 * initiator=0
 * type=1
wlan0: Event CHANNEL_LIST_CHANGED (29) received
nl80211: Drv Event 36 (NL80211_CMD_REG_CHANGE) received for wlan0
nl80211: Regulatory domain change
 * initiator=1
 * type=0
 * alpha2=IE
wlan0: Event CHANNEL_LIST_CHANGED (29) received
nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0
wlan0: nl80211: Scan trigger
wlan0: Event SCAN_STARTED (48) received
Unknown event 48
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: vlan_newlink(wlan0)
nl80211: Drv Event 35 (NL80211_CMD_SCAN_ABORTED) received for wlan0
wlan0: nl80211: Scan aborted
nl80211: Scan probed for SSID ''
nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 5180 5200 5220 5240 5260 5280 5300 5320 5500 5520 5540 5560 5580 5600 5620 5640 5660 5680 5700
wlan0: Event SCAN_RESULTS (3) received
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=5 linkmode=0 ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
nl80211: Set IF_OPER_UP again based on ifi_flags and expected operstate
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
VLAN: vlan_newlink(wlan0)
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: vlan_newlink(wlan0)
nl80211: Drv Event 16 (NL80211_CMD_STOP_AP) received for wlan0
wlan0: Event INTERFACE_UNAVAILABLE (30) received
Interface wlan0 is unavailable -- stopped
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=2 linkmode=0 ifi_family=0 ifi_flags=0x1003 ([UP])
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x1003 ([UP])
VLAN: vlan_newlink(wlan0)
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=2 linkmode=0 ifi_family=0 ifi_flags=0x1003 ([UP])
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x1003 ([UP])
VLAN: vlan_newlink(wlan0)
nl80211: Drv Event 46 (NL80211_CMD_CONNECT) received for wlan0
nl80211: Connect event (status=0 ignore_next_local_disconnect=0)
nl80211: Associated on 2432 MHz
nl80211: Associated with 74:da:38:0e:ce:19
nl80211: Operating frequency for the associated BSS from scan results: 2432 MHz
wlan0: Event ASSOC (0) received
hostapd_notif_assoc: Skip event with no address
RTM_NEWLINK: ifi_index=3 ifname=wlan0 wext ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
nl80211: Set IF_OPER_UP again based on ifi_flags and expected operstate
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
RTM_NEWLINK: ifi_index=3 ifname=wlan0 wext ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
nl80211: Set IF_OPER_UP again based on ifi_flags and expected operstate
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
RTM_NEWLINK: ifi_index=3 ifname=wlan0 wext ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
nl80211: Set IF_OPER_UP again based on ifi_flags and expected operstate
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
RTM_NEWLINK: ifi_index=3 ifname=wlan0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
VLAN: vlan_newlink(wlan0)
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
VLAN: vlan_newlink(wlan0)
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])
VLAN: vlan_newlink(wlan0)
VLAN: RTM_NEWLINK: ifi_index=3 ifname=wlan0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
VLAN: vlan_newlink(wlan0)

@EDIT

After fresh installation of Raspbian Stretch with desktop (version November 2018), using my laptop I created empty file called ssh and file called wpa_supplicant.conf on the boot partition:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=IE

network={
    ssid="My SSID"
    psk="My WiFi Password"
    key_mgmt=WPA-PSK
}

Then I added following lines at the end of the /etc/dhcpcd.conf file to configure my static IP address:

interface wlan0
static ip_address=192.168.130.13/24
static routers=192.168.130.13.1
static domain_name_servers=192.168.130.1

Then I connected to my Pi using ssh and executed following commands:

passwd
sudo apt update -y && sudo apt ugrade -y && sudo apt install hostapd rng-tools -y

Nextly according to instructions from: Access point as WiFi repeater, optional with bridge

I executed following commands:

sudo systemctl stop hostapd
sudo systemctl mask networking.service
sudo systemctl mask dhcpcd.service
sudo sudo mv /etc/network/interfaces /etc/network/interfaces~
sudo sed -i '1i resolvconf=NO' /etc/resolvconf.conf
sudo systemctl enable systemd-networkd.service
sudo systemctl enable systemd-resolved.service
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

Then I created file /etc/hostapd/hostapd.conf:

interface=ap0
driver=nl80211
ssid=SSID
country_code=DE
hw_mode=g
channel=1
auth_algs=1
wpa=2
wpa_passphrase=PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

and I executed this command: sudo chmod 600 /etc/hostapd/hostapd.conf

Then I changed #DAEMON_CONF="" to DAEMON_CONF="/etc/hostapd/hostapd.conf" in /etc/default/hostapd and # Should-Start: $network to ## Should-Start: $network in /etc/init.d/hostapd.

Then I executed following command: sudo systemctl edit hostapd.service and I pasted this:

[Unit]
Wants=wpa_supplicant@wlan0.service

[Service]
ExecStartPre=/sbin/iw dev wlan0 interface add ap0 type __ap
ExecStopPost=-/sbin/iw dev ap0 del

Then I created file /etc/wpa_supplicant/wpa_supplicant-wlan0.conf:

country=IE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="My SSID"
    psk="My WiFi Password"
}

and executed following commands:

chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
systemctl disable wpa_supplicant.service
systemctl enable wpa_supplicant@wlan0.service

Nextly I executed this command: sudo systemctl edit wpa_supplicant@wlan0.service and pasted following lines:

[Unit]
BindsTo=hostapd.service
After=hostapd.service

[Service]
ExecStartPost=/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
ExecStopPost=-/sbin/iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE

Then I created /etc/systemd/network/08-wlan0.network file:

[Match]
Name=wlan0
[Network]
IPForward=yes
DHCP=yes
Address=192.168.130.13/24
Gateway=192.168.130.1

Nextly I add bridge=br0 at the end of /etc/hostapd/hostapd.conf file.

Then I executed following command: sudo systemctl edit wpa_supplicant@wlan0.service and my file looks as follows:

[Unit]
BindsTo=hostapd.service
After=hostapd.service
Wants=ap-bring-up.service
Before=ap-bring-up.service

[Service]
ExecStartPost=/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
ExecStopPost=-/sbin/iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE
ExecStopPost=-/bin/ip link set ap0 up

Then I executed following command: sudo systemctl --force --full edit ap-bring-up.service and pasted these lines:

[Unit]
Description=Bring up wifi interface ap0
Requisite=hostapd.service

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-networkd-wait-online --interface=wlan0 --timeout=60 --quiet
ExecStartPost=/bin/ip link set ap0 up

Finally I created following files:

/etc/systemd/network/02-br0.netdev

[NetDev]
Name=br0
Kind=bridge

/etc/systemd/network/04-eth0.network

[Match]
Name=eth0
[Network]
Bridge=br0

/etc/systemd/network/16-br0_up.network

[Match]
Name=br0
[Network]
Address=192.168.13.1/24
DHCPServer=yes

and I rebooted my Pi and after that it I still can't see the SSID of wifi and Pi is not connecting to my home wifi anymore.

Your Answer

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

Browse other questions tagged or ask your own question.