Openwrt - WiFi

最後更新: 2020-03-06

目錄

  • 重建設定檔
  • wifi 指令
  • 設定 WPA2
  • iw 指令
  • WPA-Enterprise
  • hostapd

重建設定檔

 

wifi detect > /etc/config/wireless

 


wifi 指令

 

wifi           # 它本身就有 up 及 restart 的意思, 它會重讀設定檔, 並 up 所有 wifi interface

在執行中的 interface 會有:

...
... device wlan0 left promiscuous mode
... br-lan: port 2(wlan0) entered disabled state
...
... device wlan0 entered promiscuous mode
... br-lan: port 2(wlan0) entered blocking state
... br-lan: port 2(wlan0) entered forwarding state
...

wifi down                     # down 所有 radios

wifi down wlan0           # 只 down wlan0

wifi up wlan0

 


設定 WPA2

 

  1. uci set wireless.@wifi-iface[0].encryption=psk2
  2. uci set wireless.@wifi-iface[0].key="your_password"
  3. uci set wireless.radio0.disabled=0
  4. uci commit wireless
  5. wifi

設定檔:

/etc/config/wireless

# package 'wireless'

config 'wifi-device' 'radio0'
        option 'type' 'mac80211'
        option 'channel' '11'
        option 'macaddr' 'f8:d1:11:??:??:??'
        option 'hwmode' '11ng'
        option 'htmode' 'HT20'
        list 'ht_capab' 'SHORT-GI-20'
        list 'ht_capab' 'SHORT-GI-40'
        list 'ht_capab' 'RX-STBC1'
        list 'ht_capab' 'DSSS_CCK-40'
        option 'disabled' '0'

config 'wifi-iface'
        option 'device' 'radio0'
        option 'network' 'lan'
        option 'mode' 'ap'
        option 'ssid' 'MY-AP'
        option 'encryption' 'psk2'  <-- 支援選項 none, wep, psk, psk2 
        option 'key' 'mypw'

mode:

  • ap
  • sta
  • adhoc
  • wds
  • mesh (802.11s)

其他可能用到的設定:

  • maxassoc         限制 client 數量
  • macaddr           自定 MAC
  • isolate             isolate 每一個 client
  • hidden             hidden SSID

P.S.

修改完設定後, 除了要 commit, 還要 wifi 一下

 


iw 指令

 

iwinfo

wlan0     ESSID: "home"
          Access Point: E8:94:F6:?:?:?
          Mode: Master  Channel: 1 (2.412 GHz)
          Tx-Power: 14 dBm  Link Quality: 67/70
          Signal: -43 dBm  Noise: -84 dBm
          Bit Rate: 44.8 MBit/s
          Encryption: WPA2 PSK (CCMP)
          Type: nl80211  HW Mode(s): 802.11bgn
          Hardware: unknown [Generic MAC80211]
          TX power offset: unknown
          Frequency offset: unknown
          Supports VAPs: yes  PHY name: phy0

iw

link

 


wpad

 

Default 只安裝了:

  • wpad-mini

而沒有安工具:

  • wpa-cli

Program:

  • /usr/sbin/hostapd -> wpad
  • /usr/sbin/wpa_supplicant -> wpad

Proccess:

4048 root      1424 S    hostapd -P /var/run/wifi-phy0.pid -B /var/run/hostapd-phy0.conf

 


WPA-Enterprise

 

  1. root@OpenWrt:~# uci set wireless.@wifi-iface[0].encryption=wpa2
  2. root@OpenWrt:~# uci set wireless.@wifi-iface[0].key="shared_secret"
  3. root@OpenWrt:~# uci set wireless.@wifi-iface[0].server=192.168.1.200
  4. root@OpenWrt:~# uci set wireless.@wifi-iface[0].port=1812
  5. root@OpenWrt:~# uci commit wireless
  6. root@OpenWrt:~# wifi

P.S.

軟件包 wpad-mini 是不支援 WPA Enterprise 的 !!

 


hostapd

 

Proccess

  722 admin     2044 S    hostapd -d -B /etc/Wireless/conf/hostapd_ath0.conf -P /var/run/hostapd_ath0.pid -e /var/run/entropy_ath0.bin
  788 admin     2044 S    hostapd -d -B /etc/Wireless/conf/hostapd_ath1.conf -P /var/run/hostapd_ath1.pid -e /var/run/entropy_ath1.bin
  821 admin     2044 S    hostapd -d -B /etc/Wireless/conf/hostapd_ath001.conf -P /var/run/hostapd_ath001.pid -e /var/run/entropy_ath001.bin

hostapd (host access point daemon)

It is a user space daemon software enabling a network interface card to act as an access point and authentication server.

hostapd [-hdBKtv] [-P <PID file>] <configuration file(s)>

  • -d    Show more debug messages.
  • -B    Run daemon in the background.
  • -P <PID file>

 


 

Creative Commons license icon Creative Commons license icon Creative Commons license icon