CentOS 6.4 无线上网设置

来源:互联网 发布:下载百度壁纸软件 编辑:程序博客网 时间:2024/05/21 09:51

CentOS采用的内核通常比较保守,支持的硬件也有一定程度的滞后,比如对无线网卡的支持。如果没有无线网卡的驱动,可以尝试升级内核完成。如果最新内核没有包含你网卡的驱动,就需要手动安装了。

如果要确认是否无线网卡是否被驱动了,可以使用:

[root@vfeelit ~]# iwconfiglo        no wireless extensions.wlan0     IEEE 802.11bgn  ESSID:"ap_283303695"            Mode:Managed  Frequency:2.462 GHz  Access Point: 6C:E8:73:46:EF:7A             Bit Rate=121.5 Mb/s   Tx-Power=14 dBm             Retry  long limit:7   RTS thr:off   Fragment thr:off          Encryption key:off          Power Management:off          Link Quality=70/70  Signal level=-18 dBm            Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0          Tx excessive retries:0  Invalid misc:68   Missed beacon:0

必须出现wlan这样的接口(也可能是其它名字),如果没有说明没有无线网卡,或无线网卡没有被驱动(就是没有驱动程序)。

先关闭NetworkManager,它和手动设置冲突:

[root@vfeelit ~]# service NetworkManager stop[root@vfeelit ~]# chkconfig --list | grep NetNetworkManager 0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭[root@vfeelit ~]# chkconfig --level 2345 NetworkManager off

建立配置文件

#/etc/sysconfig/network-scripts/ifcfg-wlan0DEVICE=wlan0ESSID="ap_283303695"TYPE=WirelessBOOTPROTO=staticIPADDR=192.168.1.100NETMASK=255.255.255.0GATEWAY=192.168.1.1IPV6INIT=noONBOOT=yes

这里跟配置有线网卡差不多,不过要注意DEVICE要指定iwconfig显示的无线网卡名,TYPE要设置为Wireless,用ESSID指定接入名称。如果采用WEP密码验证,这里还要使用KEY指定密码(当前采用WPA-PSK/WPA2-PSK验证,所以这里不需要指定KEY)。

之后重启网络:

[root@vfeelit network-scripts]# ifconfig wlan0wlan0     Link encap:Ethernet  HWaddr 00:26:C7:32:CE:D2            inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0          inet6 addr: fe80::226:c7ff:fe32:ced2/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:3306 errors:0 dropped:0 overruns:0 frame:0          TX packets:396 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000           RX bytes:312460 (305.1 KiB)  TX bytes:54709 (53.4 KiB)

IP地址等信息已经分配,不过这时还没有连接上无线网络,那是因为无线接入需要密码验证。由于这里采用了WPA-PSK/WPA2-PSK验证,所以需要使用另一个工具。

[root@vfeelit network-scripts]# yum install wpa_supplicantwpa_supplicant-0.7.3-4.el6_3.x86_64

wpa_supplicant可能已经安装。接下来:

wpa_passphrase [ESSID] [密码] >> /etc/wpa_supplicant/wpa_supplicant.conf## vi /etc/wpa_supplicant/wpa_supplicant.confctrl_interface=/var/run/wpa_supplicantctrl_interface_group=wheelnetwork={        ssid="ap_283303695"        #psk="s15889660090"        psk=c0f293f6e1c21bd99d5764a565f9708e187da6972bc96dc5f1c69a35211a3116}

实际上往/etc/wpa_supplicant/wpa_supplicant.conf添加了network块。然后运行wpa_supplicant:

wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf

如果希望这个程序在后台显示,需要用以下命令:

wpa_supplicant -B -Dwext -iwlan0 -c/etc/wpa_supplicant.conf  #B表示后台运行#可以用wpa_supplicant -h查看基本用法:drivers:  wext = Linux wireless extensions (generic)  nl80211 = Linux nl80211/cfg80211  wired = Wired Ethernet driveroptions:  -B = run daemon in the background  -D = driver name (can be multiple drivers: nl80211,wext)  -c = Configuration file  -f = log output to debug file instead of stdout

之后应该就可以连接上无线网络了。

iwconfig命令可以用来设置网线网卡的信息,比如essid,key等,参考:

[root@vfeelit network-scripts]# iwconfig -hUsage: iwconfig [interface]                interface essid {NNN|any|on|off}                interface mode {managed|ad-hoc|master|...}                interface freq N.NNN[k|M|G]                interface channel N                interface bit {N[k|M|G]|auto|fixed}                interface rate {N[k|M|G]|auto|fixed}                interface enc {NNNN-NNNN|off}                interface key {NNNN-NNNN|off}                interface power {period N|timeout N|saving N|off}                interface nickname NNN                interface nwid {NN|on|off}                interface ap {N|off|auto}                interface txpower {NmW|NdBm|off|auto}                interface sens N                interface retry {limit N|lifetime N}                interface rts {N|auto|fixed|off}                interface frag {N|auto|fixed|off}                interface modulation {11g|11a|CCK|OFDMg|...}                interface commit        Check man pages for more details.

一般,直接运行iwconfig查看是否有无线网卡(比如wlan0),然后启动这个网卡:

ifconfig wlan0 up

然后可以用这个无线网卡搜索无线网络:

[root@vfeelit network-scripts]# iwlist wlan0 scanwlan0     Scan completed :          Cell 01 - Address: 6C:E8:73:46:EF:7A                    Channel:11                    Frequency:2.462 GHz (Channel 11)                    Quality=70/70  Signal level=-19 dBm                      Encryption key:on                    ESSID:"ap_283303695"                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s                              9 Mb/s; 12 Mb/s; 18 Mb/s                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s                    Mode:Master                    Extra:tsf=00000001a5e4b17c                    Extra: Last beacon: 95ms ago                    IE: WPA Version 1                        Group Cipher : TKIP                        Pairwise Ciphers (2) : TKIP CCMP                        Authentication Suites (1) : PSK                    IE: IEEE 802.11i/WPA2 Version 1                        Group Cipher : TKIP                        Pairwise Ciphers (2) : TKIP CCMP                        Authentication Suites (1) : PSK

找到需要接入的无线网络,获取Address、Channel、Frequency、Encryption key、ESSID、Mode和加密方式(以上是使用wpa)。

然后可以使用iwconfig设置相关参数(也可以写入配置文件中去),比如:

iwconfig wlan0 essid "ap_283303695"iwconfig wlan0 key s15889660090   ##使用wep验证时有效iwconfig wlan0 ap auto##用ifconfig设置IPifconfig wlan0 192.168.1.100 netmask 255.255.255.0 gw 192.168.1.1##确认已经添加了默认路由route -n

这些信息可以保持到ifcfg-wlan0中去。

如果采用wpa验证,还需要运行wpa命令来管理无线密码。

永久链接: http://www.vfeelit.com/504.html

0 0
原创粉丝点击