Soft WPS with OpenWRT

作者: lesca 分类: Tutorials 发布时间: 2014-02-23 21:00

Purpose

When I use WPS, I find it easy to set up but not safe enough! If someone is able to touch the router, he/she may connect to the network without permission.
So why not disable the WPS button? I did some research to find a way to initiate WPS with command. It means If I agree someone or some device to connect to my network, I should just do some types on my computer…

I happen to have an old ZTE H618B which already installed Tomato DualWAN, and I happen to find a openwrt firmware for this device. So, my experiment bengins…

Install OpenWRT

Device: ZTE H618B
Firmware: openwrt-brcm47xx-squashfs.trx

Install WPAD package

As the default package wpad-mini is not enough to make WPS function well, it is necessary to remove it and install wpad which was called wpad-full.

opkg remove wpad-mini
opkg update 
opkg install wpad

The offical document suggest to install hostapd-utils, but I find it is already the latest version in my firmware, so I skip it.

Set up WPS function

After the package installed, it is time to configure the wireless configuration file located at /etc/config/wireless:

config wifi-device 'radio0'
        option type 'mac80211'
        option channel '11'
        option macaddr '00:90:4c:c1:04:51'
        option hwmode '11g'
        option txpower '20'
        option country '00'

config wifi-iface
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'psk2+ccmp'
        option key 'password'
        option 'wps_pushbutton' '1'

Just add option 'wps_pushbutton' '1' under config wifi-iface section, then type wifi to apply wireless configuration changes.

Command

If you have only one radio device, the initial command should be like this: (which is my case)

hostapd_cli -p /var/run/hostapd-phy0 wps_pbc

If your device has more than one radio device, you should write some codes as below:

for dir in /var/run/hostapd-*; do
   [ -d "$dir" ] || continue
   hostapd_cli -p "$dir" wps_pbc
done

The option wps_pbc indicates you pushed the WPS button, it is short for “push-button configuration”
-p points to the path includes wlan0 device.

Test

It works for me finally! My device connected to my router when I runs the command:

hostapd_cli -p /var/run/hostapd-phy0 wps_pbc
Selected interface 'wlan0'
OK

References:

[1] Netgear WNDR3700 and WNDR37AV – WPS button

版权声明

本文出自 Lesca 技术宅,转载时请注明出处及相应链接。

本文永久链接: https://www.lesca.cn/archives/soft-wps-with-openwrt.html

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!