linux下手动设置无线网络链接

默认分类 · 2013-11-24

由于种种原因,不能使用network manager,改用手动设置linux无线链接

1、设置/etc/wpa_supplicant.conf

# See /usr/doc/wpa_supplicant-0.6.9/wpa_supplicant.conf.sample
# for many more options that you can use in this file.

# This line enables the use of wpa_cli which is used by rc.wireless
# if possible (to check for successful association)
ctrl_interface=/var/run/wpa_supplicant
# By default, only root (group 0) may use wpa_cli
ctrl_interface_group=0
eapol_version=1
ap_scan=1
fast_reauth=1
#country=US

# WPA protected network, supply your own ESSID and WPAPSK here:
network={
  scan_ssid=0
#下面是无线路由器名称
  ssid="TP-LINK_59A1CA"
  proto=WPA RSN
  key_mgmt=WPA-PSK
  pairwise=CCMP TKIP
  group=CCMP TKIP WEP104 WEP40
#下面是密码
  psk="123456uy"
  priority=10
}

# Plaintext connection (no WPA, no IEEE 802.1X),
# nice for hotel/airport types of WiFi network.
network={
  key_mgmt=NONE
  priority=0
}

2、用脚本

#!/bin/bash
ifconfig wlan0 192.168.1.103/24
route add default gw 192.168.1.1
echo -ne "\nnameserver 114.114.114.114" | sudo tee -a /etc/resolv.conf
echo -ne "\nnameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf&
linux
Theme Jasmine by Kent Liao