Raspberry PI 3 or 4 with hostapd wifi AP and router for 4G dongle all in on



Treat WLAN0 uplink to either home WIFI or 4G phone as a nmcli interface but statically configure the hostapd interface as per below and you wont have as many issues with NetworkManager taking over hostapd interface! (You have been warned – I pulled my hair out for many months before realising this.

Predicatable names RPI – use them if you have multiple network USB interfaces that may conflict or if the names may flip flop e.g. wlan0/wlan1. This can break rpi routers or hostapd wifi APs.

1.)Change to predictable names :

——————————–

>>sudo raspi-config<<

Choose 2 – Network Options / Network Interface names / Predictable Names.

Reboot

2.)If you use nmcli (NetworkManager for everything except Hostapd because nmcli seems to break hostapd) then configure an exception for USB WIFI Dongle acting as hostapd WIFI AP:

———————————————————————————————————————————————————————————-

>>sudo cat /etc/NetworkManager/NetworkManager.conf<<

[main]

plugins=ifupdown,keyfile

[ifupdown]

managed=true

[keyfile]

unmanaged-devices=interface-name:wlx74da38d5bba6

3.)Configure DNSMASQ that is providing you with DHCP:

—————————————————–

sudo cat /etc/dnsmasq.conf

# Configuration file for dnsmasq. eth0:enxb827ebc61007 wlan1:wlx74da38d5bba6

#

domain=plcmanzdemo.onmicrosoft.com

dhcp-authoritative

dhcp-range=interface:wlx74da38d5bba6,192.168.70.100,192.168.70.199,255.255.255.0,1h

dhcp-range=interface:eth0,192.168.90.100,192.168.90.199,255.255.255.0,1h

#dhcp-host=00:28:f8:6b:19:ad,RPRMaf,192.168.77.10,24h

####dhcp-host=00-15-5D-0A-6B-0C,PLCM-OTD-SVR-QWNS,192.168.88.30,1440m

###———Cloud Relay – plcmanzdemo-cr-af————————###

#dhcp-host=00:15:5d:0a:c4:00,plcmanzdemo-cr-af.fullys.xyz,192.168.99.20,1h

###—————————————————————-###

dhcp-option=interface:eth0,3,192.168.90.1

dhcp-option=interface:wlx74da38d5bba6,3,192.168.70.1

#DNS Servers

dhcp-option=interface:eth0,6,208.67.222.222,208.67.220.220

dhcp-option=interface:wlx74da38d5bba6,6,208.67.222.222,208.67.220.220

#dhcp-option=6,192.168.99.80 NTP dhcp-option=42,asia.pool.ntp.org

#dhcp-option=42,202.65.114.202 dhcp-option=2,36000

###Option 66

#RPRM 10.X dhcp-option=66,”http://192.168.99.10/phoneservice/configfiles/&#8221; PDMS dhcp-option=interface:enxb827ebc61007,66,”https://t2212.pdms.plcm.cloud&#8221; dhcp-option=interface:enxb827ebc61007,160,”https://t2212.pdms.plcm.cloud&#8221;

#dhcp-option=interface:enxb827ebc61007,161,”https://t2212.pdms.plcm.cloud&#8221; dhcp-option=interface:enxb827ebc61007,66,”https://t95.pdms.plcm.cloud&#8221; dhcp-option=interface:enxb827ebc61007,160,”https://t95.pdms.plcm.cloud&#8221;

#dhcp-option=interface:enxb827ebc61007,161,”https://t95.pdms.plcm.cloud&#8221; dhcp-option=interface:enxb827ebc61007,66,https://plcmanzdemo-cr-af.fullys.xyz dhcp-option=interface:enxb827ebc61007,160,https://plcmanzdemo-cr-af.fullys.xyz

#dhcp-option=interface:enxb827ebc61007,161,https://plcmanzdemo-cr-af.fullys.xyz

###################HELP#########################################

#Automatic Configuration: DHCP Scope Option Polycom devices boot and examine DHCP options 66 and either option 160 (openSIP SKUs) or 161(Microsoft SKUs) for a string specifying the address of the provisioning server.

#

#Define this string in the format of https://pdms_tenant_address or https://user:password@pdms_tenant_address if the default PlcmSpIp was not configured for your tenant.

#

#domain-needed bogus-priv

###domain=fullys.xyz

expand-hosts

###local=/fullys.xyz/

listen-address=127.0.0.1

listen-address=192.168.70.1

listen-address=192.168.90.1

#bind-interfaces

###——–Log DHCP————###

log-facility=/var/log/dnsmasq/dnsmasq-dhcp.log

log-dhcp

log-queries

###—–Look in /var/lib/misc/dnsmasq.leases —–###

4.)Configure hostapd config file and check after reboot:

——————————————————–

>>sudo cat /etc/hostapd/hostapd.conf<<

interface=wlx74da38d5bba6

driver=nl80211

country_code=AU

#ctrl_interface=/var/run/hostapd

#ctrl_interface_group=0

ssid=ssid-name

wpa=3

wpa_key_mgmt=WPA-PSK

#wmm_enabled=1

wpa_pairwise=TKIP

rsn_pairwise=CCMP

wpa_passphrase=password

macaddr_acl=0

auth_algs=3

ignore_broadcast_ssid=0

ht_capab=[GF][RX-STBC1][HT40+][SHORT-GI-20][SHORT-GI-40][MAX-AMSDU-7935][DSSS_CCK40][MAX-AMSDU-3839]

disassoc_low_ack=0

#logger_syslog=-1

#logger_syslog_level=4

#logger_stdout=-1

#logger_stdout_level=4

hw_mode=a

ieee80211n=1

require_ht=1

ieee80211ac=1

require_vht=1

ieee80211d=0

ieee80211h=0

vht_capab=[SHORT-GI-80][HTC-VHT][MAX-AMSDU-7935][MAX-MPDU-11454][SU-BEAMFORMEE][MAX-AMSDU-3839]

vht_oper_chwidth=1

#channel=36

#vht_oper_centr_freq_seg0_idx=42

channel=36

vht_oper_centr_freq_seg0_idx=42

ap_isolate=0

5.)Make sure the USB WIFI dongle hostapd interface is configured under /etc/network/interfaces:

———————————————————————————————–

>>sudo cat /etc/network/interfaces<<

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd

# For static IP, consult /etc/dhcpcd.conf and ‘man dhcpcd.conf’

# Include files from /etc/network/interfaces.d:

#source-directory /etc/network/interfaces.d

auto wlx74da38d5bba6

iface wlx74da38d5bba6 inet static

address 192.168.70.1

netmask 255.255.255.0

6.)Reboot RPI router and check iwconfig and ifconfig:

—————————————————–

>>ifconfig<<

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 192.168.90.1 netmask 255.255.255.0 broadcast 192.168.90.255

ether dc:a6:32:0d:f0:37 txqueuelen 1000 (Ethernet)

RX packets 31 bytes 2472 (2.4 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 40 bytes 3151 (3.0 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536

inet 127.0.0.1 netmask 255.0.0.0

loop txqueuelen 1000 (Local Loopback)

RX packets 10 bytes 781 (781.0 B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 10 bytes 781 (781.0 B)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 10.88.10.24 netmask 255.255.255.0 broadcast 10.88.10.255

ether dc:a6:32:0d:f0:39 txqueuelen 1000 (Ethernet)

RX packets 1261 bytes 246874 (241.0 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 451 bytes 133911 (130.7 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlx74da38d5bba6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 192.168.70.1 netmask 255.255.255.0 broadcast 192.168.70.255

ether 74:da:38:d5:bb:a6 txqueuelen 1000 (Ethernet)

RX packets 0 bytes 0 (0.0 B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 0 bytes 0 (0.0 B)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

>>iwconfig<<

eth0 no wireless extensions.

wlx74da38d5bba6 IEEE 802.11AC ESSID:”polydemowifi” Nickname:”<WIFI@REALTEK>”

Mode:Master Frequency:5.18 GHz Access Point: 74:DA:38:D5:BB:A6

Bit Rate:434 Mb/s Sensitivity:0/0

Retry:off RTS thr:off Fragment thr:off

Power Management:off

Link Quality:0 Signal level:0 Noise level:0

Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0

Tx excessive retries:0 Invalid misc:0 Missed beacon:0

lo no wireless extensions.

wlan0 IEEE 802.11 ESSID:”AJLJFWIFI-5G”

Mode:Managed Frequency:5.26 GHz Access Point: 00:90:4C:0E:51:23

Bit Rate=200 Mb/s Tx-Power=31 dBm

Retry short limit:7 RTS thr:off Fragment thr:off

Power Management:on

Link Quality=55/70 Signal level=-55 dBm

Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0

Tx excessive retries:0 Invalid misc:0 Missed beacon:0