Configuration of a wifi client in openWrt
For working with wifi in openWrt there is a script /sbin/wifi. The file /etc/config/wireless is responsible for wifi configuration.
The the configuration file can be created by default having run the following:
wifi detect > /etc/config/wireless
It will look as follows:
config wifi-device radio0 option type mac80211 option channel 11 option hwmode 11g option path 'pci0000:00/0000:00:1c.2/0000:05:00.0' # REMOVE THIS LINE TO ENABLE WIFI: option disabled 1 config wifi-iface option device radio0 option network lan option mode ap option ssid OpenWrt option encryption none
Let's change it under our configuration.
The file /etc/config/wireless is for open network:
config wifi-device radio0 option type mac80211 option channel 'auto' option hwmode 11g option path 'pci0000:00/0000:00:1c.2/0000:05:00.0' option disabled 0 config wifi-iface option device radio0 option network wwan option mode sta option ssid testwifi option encryption none
The file /etc/config/wireless is for encrypted network:
config wifi-device 'radio0' option type 'mac80211' option channel '6' option hwmode '11ng' option path 'pci0000:00/0000:00:1c.2/0000:05:00.0' option disabled '0' config wifi-iface option device 'radio0' option network 'wwan' option mode 'sta' option ssid 'testwifi' option encryption 'psk2' option key '1234567890'
sta — is a client mode; ap — is an access point mode
For automatic receiving the address via dhcp it is necessary to create the interface in file/etc/config/network:
config interface wwan option proto 'dhcp'
Let's run the following commands for applying of new settings:
At the stage of OpenWrt configuration wpa-supplicant is to be selected, in the different way wifi will not be linked up by the script openWrt /sbin/wifi:
Network: <*> wpa-supplicant
The running of «wifi down» makes wifi disable and results in missing of interface wlan0.
The running of «wifi up» links up the interface wlan0 and the network is connected.
By successful completing of operation there will be approximately the following log on the screen:
wifi up Successfully initialized wpa_supplicant [ 10.975345] iwl3945 0000:05:00.0: loaded firmware version 184.108.40.206 [ 14.670591] wlan0: authenticate with bc:ae:c5:c3:ab:d5 [ 14.673644] wlan0: send auth to bc:ae:c5:c3:ab:d5 (try 1/3) [ 14.675760] wlan0: authenticated [ 14.676031] iwl3945 0000:05:00.0: wlan0: disabling HT as WMM/QoS is not supported by the AP [ 14.676335] iwl3945 0000:05:00.0: wlan0: disabling VHT as WMM/QoS is not supported by the AP [ 14.680246] wlan0: associate with bc:ae:c5:c3:ab:d5 (try 1/3) [ 14.682727] wlan0: RX AssocResp from bc:ae:c5:c3:ab:d5 (capab=0x401 status=0 aid=1) [ 14.684368] wlan0: associated
Error introducing is possible (if there is no wpa-supplicant) :
wifi up command failed: Device or resource busy (-16)
It is possible to be connected to the network in a manual mode by the following command:
iw dev wlan0 connect -w testwifi