Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WPS on OpenWRT -- Enabling Wi-Fi Protected Setup on OpenWRT
##
## WPS on OpenWRT
## This script enables Wi-Fi Protected Setup on OpenWRT.
##
## Resources
## http://wiki.openwrt.org/doc/uci/wireless#wps.options
##
#Install the full wpad package
opkg update
opkg remove wpad-mini
opkg install wpad hostapd-utils
#Enable WPS on the Wifi network interface.
# Notes:
# * The network interface should be configured to support WPA2-PSK
# * This script assumes the last interface is the one used for WPS, hence using @wifi-iface[-1]
# * You can view all the wireless interfaces by issuing the following command and getting the index of the correct one
# uci show wireless
uci set wireless.@wifi-iface[-1].wps_pushbutton=1
#The following are all optional
uci set wireless.@wifi-iface[-1].wps_device_name="OpenWRT AP"
uci set wireless.@wifi-iface[-1].wps_manufacturer="openwrt.org"
##
## Save Changes & Reboot
##
uci commit
#reboot # based on comments, reboot is no longer required.
##
## Run WPS
##
hostapd_cli -p /var/run/hostapd-phy0 wps_pbc
@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Oct 7, 2016

When we use our gateway as a client, should not we need to change /etc/config/wireless mode and /etc/config/network options too?

@etskinner

This comment has been minimized.

Copy link

@etskinner etskinner commented Feb 15, 2018

Worked great on Archer C7 v2.0, thanks. It did show up with error 'Failed to connect to hostapd - wpa_ctrl_open: No such file or directory' during the script, but the button still worked fine.

@ThomasCr

This comment has been minimized.

Copy link

@ThomasCr ThomasCr commented Feb 8, 2019

@etskinner:
you may try
hostapd_cli -i wlan0 wps_pbc
and
hostapd_cli -i wlan0 wps_get_status

@bam80

This comment has been minimized.

Copy link

@bam80 bam80 commented Jul 16, 2019

@alghanmi no need to reboot

@sordfish

This comment has been minimized.

Copy link

@sordfish sordfish commented Apr 5, 2020

helpful thanks, I restarted the radio in luci rather than reboot and that worked fine.

@alghanmi

This comment has been minimized.

Copy link
Owner Author

@alghanmi alghanmi commented Apr 16, 2020

Thanks! I updated the script

@NovaViper

This comment has been minimized.

Copy link

@NovaViper NovaViper commented May 27, 2020

@etskinner:
you may try
hostapd_cli -i wlan0 wps_pbc
and
hostapd_cli -i wlan0 wps_get_status

I'm having the same issue on my TPLink Archer 1750 A7, neither of those commands work for me, I just get "UNKNOWN COMMAND" when I run them

@proycon

This comment has been minimized.

Copy link

@proycon proycon commented Jul 13, 2020

@NovaViper First restart the radio device or reboot, that should fix it. I had the same issue

@JardaG

This comment has been minimized.

Copy link

@JardaG JardaG commented Aug 17, 2020

What do you think about adding this line?
opkg remove wpad-basic
I have OpenWrt 19.07 @ TP-Link Archer C7 v2 and wpad-mini is not installed there, but wpad-basic is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.