Gentoo 無線網絡配置 wpa_supplicant

安裝

安裝net-wireless/wpa_supplicant

emerge --ask wpa_supplicant 

啓動網絡

  • 爲wpa_supplicant添加無線接口
    wpa_supplicant.conf文件中添加
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
  • 初始化wpa_supplicant環境
wpa_supplicant -d -Dnl80211 -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

參數:

-B - Fork into background.
-c filename - Path to configuration file.
-d increase debugging verbosity
-i interface - Interface to listen on.
-D driver - Optionally specify the driver to be used. 

For a list of supported drivers see the output of wpa_supplicant -h.

nl80211 is the current standard, but not all wireless chip’s modules support it.wext is currently deprecated, but still widely supported.
- 查看wpa_supplicant進程

ps -aux | grep wpa
root      1841  0.0  0.2   6168  2920 ?        Ss   09:10   0:00 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 
root      2122  0.0  0.0   2780   728 pts/0    S+   09:25   0:00 grep --colour=auto wpa

配置

  • Set for Gentoo net.* scrips,tell the network script to use wpa_supplicant.
    File/etc/conf.d/net
modules_wlan0="wpa_supplicant"
# 因爲wpa_supplicant還不能很好的自動偵測驅動,所以需要我們爲其指定正在使用的驅動。
wpa_supplicant_wlan0="-Dnl80211"
config_wlan0="dhcp"
  • Set for dhcpcd,no special setup is needed.Do not add wpa_supplicant to any runlevel. It will be controlled by dhcpcd.

配置文件/etc/wpa_supplicant/wpa_supplicant.conf

# Allow users in the 'wheel' group to control wpa_supplicant
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
# Make this file writable for wpa_gui
update_config=1
#自動掃描AP(也就是可以上的無線網絡熱點)
ap_scan=1   
# 簡單的情形:WPA-PSk密碼驗證方式,PSK是ASCII密碼短語,所有合法的加密方式都允許連接
network={
  ssid="simple"
  psk="very secret passphrase"
  # 優先級越高,就能越早匹配到。
  priority=5
}

To allow unprivileged users to control the connection using wpa_gui / wpa_cli, make sure GROUP=wheel and update_config=1.

也可以使用wpa_passphrase命令添加無線熱點

wpa_passphrase [ ssid ] [ passphrase ] >> /etc/wpa_supplicant/wpa_supplicant.conf

上面這條命令可以自動生成一段配置,我們將它輸出添加到 wpa_supplicant 的默認配置文件裏面。

wpa_cli

運行wpa_cli時可能會出現如下的錯誤:
Could not connect to wpa_supplicant - re-trying
這個錯誤可能是因爲你的wpa_supplicant進程沒有啓動起來造成的。

wpa_cli
> scan
> scan_results
> add_network
0
> set_network 0 ssid "MYSSID"
> set_network 0 psk "passphrase"
> enable_network 0
> save_config
OK
dhcpcd interface

設置、獲取IP

自動獲取

dhcpcd wlan0

手動設置

ifconfig wlan0 192.168.1.11 broadcast 192.168.1.255 netmask 255.255.255.0

告知Gentoo RC系統網卡名字

cd /etc/init.d
ln -s net.lo net.wlan0
#start and stop it using the following commands:
/etc/init.d/net.eth0 start
/etc/init.d/net.eth0 stop
#開機啓動
rc-update add wlan0 default
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章