有線網路
編輯 /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
或
auto eth0
iface eth0 inet static
address 192.168.1.2
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255
dns-nameservers 8.8.8.8
無線網路
確認硬體資訊
dmesg | more | grep usb
[3.876812] usb 1-1.3.1: new high-speed USB device number 5 using dwc_otg
[3.998040] usb 1-1.3.1: New USB device found, idVendor=0bda, idProduct=8176
[4.020708] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[4.045639] usb 1-1.3.1: Product: 802.11n WLAN Adapter
或
lsusb
Bus 001 Device 005: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
查看目前無線網路設定
iwconfig wlan0
wlan0 unassociated Nickname:"<WIFI@REALTEK>"
Mode:Managed Frequency=2.462 GHz Access Point: Not-Associated
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
掃描無線網路
iwlist wlan0 scan
Cell 11 - Address: 18:64:72:D6:E6:E2
ESSID:"KXXX-AXXXX"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.462 GHz (Channel 11)
Encryption key:on
Bit Rates:144 Mb/s
Extra:rsn_ie=30140100000fac040100000fac040100000fac012800
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : 802.1x
Quality=72/100 Signal level=75/100
掃描結果
IE: IEEE 802.11i/WPA2 Version 1
表示加密方式為 WPA2,所對應的欄位 proto。
RSN:WPA(2)
WPA:WPA(1)
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
表示 WPA2 使用 AES 加密方式,所對應的欄位 pairwise。
CCMP:AES cipher,WPA(2)
TKIP:TKIP cipher,WPA(1)
Authentication Suites (1) : PSK
表示使用 pre-shared key 做鑑別,所對應的欄位為 key_mgmt。
WPA-PSK:Authentication via pre-shared key
WPA-EAP:Authentication via enterprise authentication server。
停用 wlan0 網卡
ifdown wlan0
啟用 wlan0 網卡
ifup wlan0
將原來讀取 wpa_supplicant.conf 的程序 wpa_supplicant 殺掉
kill -9 $(ps -ef | grep wpa | awk '{print $2}')
重新執行 wpa_supplicant,並讀取 wpa_supplicant.conf 設定
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
-B 表示以 daemon 方式在背景執行。
-i 表示指定介面(interface)名稱。
-c 表示設定檔路徑。
我的設定檔的內容
Authentication:WPA2-Enterprise(EAP)
Encryption:CCMP
EAP method:PEAP
/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="KXXX-AXXXX"
proto=RSN
key_mgmt=WPA-EAP
pairwise=CCMP
auth_alg=OPEN
eap=PEAP
identity="XXXXXXXXXX"
password="XXXXXX"
}
執行 DHCP 用戶端,取得 IP
dhclient