Testing WiFi Router Features on RPi with OpenWrt

In continuation of the previous article, Raspberry Pi with OpenWrt as Wireless Router, we can explore more of OpenWrt wireless configuration through the command line with its configuration utility called UCI (Unified Configuration Interface) to configure the OpenWrt access point. We can do a basic smoke test of the new router.

Validation on Raspberry Pi

The OpenWrt on RPi can be validated for various networking and WiFi features to use it as a router.

Radio Enablement

  • Verify the 2.4G radio got enabled by giving the following command

root@OpenWrt:~# iw dev
phy#0
        Interface phy0-ap0
                ifindex 3
                wdev 0x1
                addr d8:3a:dd:3e:c8:3c
                type AP
                channel 36 (5180 MHz), width: 80 MHz, center1: 5210 MHz
  • In case the radio is not enabled, we can enable the radio.

root@OpenWrt:~# uci set wireless.radio0.disabled='0'
root@OpenWrt:~# uci commit wireless
root@OpenWrt:~# wifi reload
root@OpenWrt:~# iw dev
phy#0
        Interface phy0-ap0
                ifindex 3
                wdev 0x1
                addr da:3a:dd:3e:c8:3d
                ssid R_OpenWrt
                type AP
                channel 36 (5180 MHz), width: 80 MHz, center1: 5210 MHz
                txpower 31.00 dBm
root@OpenWrt:~#

Verify AP Configuration Changes

  • Verify whether the SSID could be configured

root@OpenWrt:~# uci set wireless.default_radio0.ssid='openwrt_zilogic'
root@OpenWrt:~# uci commit wireless
root@OpenWrt:~# wifi reload
root@OpenWrt:~# iw dev
phy#0
        Interface phy0-ap0
                ifindex 3
                wdev 0x1
                addr da:3a:dd:3e:c8:3d
                ssid openwrt_zilogic
                type AP
                channel 36 (5180 MHz), width: 80 MHz, center1: 5210 MHz
                txpower 31.00 dBm
  • Verify whether the STA could authenticate with new key change

root@OpenWrt:~# uci set wireless.default_radio0.encryption='wpa2-psk'
root@OpenWrt:~# uci set wireless.default_radio0.key='1234567890'
root@OpenWrt:~# uci commit wireless
root@OpenWrt:~# wifi
root@OpenWrt:~# iw dev
phy#0
        Interface phy0-ap0
                ifindex 3
                wdev 0x1
                addr da:3a:dd:3e:c8:3d
                ssid openwrt_zilogic
                type AP
                channel 149 (5745 MHz), width: 80 MHz, center1: 5775 MHz
                txpower 31.00 dBm
  • Verify whether the STA could connect with new channel change

root@OpenWrt:~# uci set wireless.radio0.channel='48'
root@OpenWrt:~# uci commit wireless
root@OpenWrt:~# wifi reload
root@OpenWrt:~# iw dev
phy#0
        Interface phy0-ap0
                ifindex 3
                wdev 0x1
                addr da:3a:dd:3e:c8:3d
                ssid openwrt_zilogic
                type AP
                channel 48 (5240 MHz), width: 80 MHz, center1: 5210 MHz
                txpower 31.00 dBm
  • Verify whether the STA could connect with modified bandwidth

root@OpenWrt:~# uci set wireless.radio0.htmode='HT20'
root@OpenWrt:~# uci commit wireless
root@OpenWrt:~# wifi reload
root@OpenWrt:~# iw dev
phy#0
        Interface phy0-ap0
                ifindex 3
                wdev 0x1
                addr da:3a:dd:3e:c8:3d
                ssid openwrt_zilogic
                type AP
                channel 149 (5745 MHz), width: 20 MHz, center1: 5745 MHz
                txpower 31.00 dBm

Verify Client Connectivity

  • Verify whether the AP could list associated client

root@OpenWrt:/# iwinfo phy0-ap0 assoclist
FC:77:74:F5:90:29  unknown / unknown (SNR 0)  13000 ms ago
        RX: 6.0 MBit/s                                   474 Pkts.
        TX: 6.0 MBit/s                                 69265 Pkts.
        expected throughput: unknown
  • Verify whether the STA is connected to AP’s network

root@OpenWrt:/# arp -a
IP address       HW type     Flags       HW address            Mask     Device
192.168.1.205    0x1         0x2         fc:77:74:f5:90:29     *        br-lan
172.16.0.84      0x1         0x2         78:8c:77:a2:38:29     *        eth0
172.16.0.1       0x1         0x2         14:eb:b6:cf:8e:7b     *        eth0

root@OpenWrt:/# cat tmp/dhcp.leases
1744838469 f8:9e:94:12:ca:00 192.168.1.100 ZS-LT-6HMTQL3 01:f8:9e:94:12:ca:00
1744835902 aa:27:58:57:bf:1c 192.168.1.139 * 01:aa:27:58:57:bf:1c
1744841560 fc:77:74:f5:90:29 192.168.1.205 ZS-DT-HWGS6T2 01:fc:77:74:f5:90:29
  • Verify whether AP could communicate to the client.

root@OpenWrt:/# ping -c 2 192.168.1.205
PING 192.168.1.205 (192.168.1.205): 56 data bytes
64 bytes from 192.168.1.205: seq=0 ttl=64 time=112.532 ms
64 bytes from 192.168.1.205: seq=1 ttl=64 time=136.220 ms

--- 192.168.1.205 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 112.532/124.376/136.220 ms

Linux Client as a STA

We can use a Linux laptop as an STA to further test the access point.

  • Verify whether the Linux STA could associate to the AP

Linux$ iw dev wlo1 link
Connected to d8:3a:dd:3e:c8:3c (on wlo1)
        SSID: openwrt_zilogic
        freq: 5765
        RX: 42035 bytes (212 packets)
        TX: 29759 bytes (177 packets)
        signal: -30 dBm
        rx bitrate: 390.0 MBit/s VHT-MCS 9 80MHz VHT-NSS 1
        bss flags:      short-slot-time
        dtim period:    2
        beacon int:     100
  • Verify whether the Linux STA could get IP connectivity to the AP

Linux$ ifconfig wlo1
wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.205  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fd61:e81:aee1:0:23d3:a1f3:6a1e:ae3d  prefixlen 64  scopeid 0x0<global>
        inet6 fd61:e81:aee1::d16  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::c1e6:c2ec:8a6:22ea  prefixlen 64  scopeid 0x20<link>
        inet6 fd61:e81:aee1:0:d87e:7db0:bc0e:8fa8  prefixlen 64  scopeid 0x0<global>
        ether fc:77:74:f5:90:29  txqueuelen 1000  (Ethernet)
        RX packets 1276  bytes 196006 (196.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2193  bytes 366661 (366.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • Verify whether the Linux STA could reach internet through AP

Linux$ traceroute -i wlo1 -n google.com
traceroute to google.com (216.58.196.174), 30 hops max, 60 byte packets
 1  192.168.1.1  4.265 ms  4.163 ms  4.688 ms
 2  172.16.0.1  4.674 ms  4.988 ms  5.063 ms
 3  49.207.180.1  8.788 ms  8.881 ms  8.851 ms
 4  * * *
 5  * * *
 6  72.14.212.80  8.710 ms  6.382 ms  6.331 ms
 7  * * *
 8  142.251.55.234  7.213 ms 142.251.55.244  6.826 ms 142.251.55.62  3.690 ms
 9  216.239.43.239  3.656 ms  3.768 ms 216.239.43.235  3.780 ms
10  216.58.196.174  3.754 ms  2.932 ms 142.250.62.67  51.105 ms

Conclusion

Through the above testing, we were able to utilize RPi as a basic WiFi Router. It is also possible to explore further networking and Wi-Fi features on this device, enabling it to function as a fully-fledged router.