网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > Linux
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 49.87.50.117
Old 2015-07-02, 11:58 AM
Kaelyn Kaelyn is offline
初级会员
 
Join Date: 2008-03-20
Posts: 2
Kaelyn 现在声名狼藉
Default Centos 使用wifi

Linux里面有两套管理网络连接的方案:

1) NetworkManager
2) /etc/network/interfaces(/etc/init.d/networking)

两套方案是冲突的,不能同时共存。

第一套方案使用于有桌面的环境,特别是笔记本,搬来搬去,网络连接情况随时会变的,
缺点是不能保存无线接入点的信息及密码。

第二个方案适用于那些几乎不需要手动连接的场合。

本文讨论第二个方案。即使用wpa_supplicant管理无线网络。这个方案的原理是系统启
动一个服务进程wpa_supplicant, 用以实现无线接口和ap之间的物理链接, 这样newwork
进程就可以管理有线网络那样管理无线网络了。

1. 关闭NetworkManager

#先关闭NetworkManager,它和手动设置冲突:
service NetworkManager stop
chkconfig --list | grep Net

#第二种方法,在开机启动的时候设置NetworkManager不运行
chkconfig --level 2345 NetworkManager off

#第三种方法,直接删除,这个最省事。以后用的时候也可以再安装回来:
yum remove NetworkManager

2. 用wpa_supplicant管理无线网线

wpa_supplicant是一个服务进程,可以和wpa_cli配合使用交互式的无线ap。不过本文讨
论的是使用配置文件自动连接。

wpa_supplicant是这个样子的,首先在/etc/init.d/wpa_supplicant 有这么个启动控制
脚本,然后有/etc/sysconfig/wpa_supplicant 这个全局配置文件,最后有还有
/etc/wpa_supplicant/wpa_supplicant.conf这个默认配置文件。

#通常系统已经安装了, 如果没有就安装一下
yum install wpa_supplicant

#设置在开机时执行的服务, 确保network和wpa_supplicant在开机的时候被启动而
#NetworkManager不被启动
#chkconfig NetworkManager off
#chkconfig network on
chkconfig wpa_supplicant on
chkconfig --list wpa_supplicant

#配置wpa_supplicant服务启动的参数,可以在/etc/init.d/wpasupplicant里配,当然
最好是编辑它的配置文件
vim /etc/sysconfig/wpa_supplicant
|# Use the flag "-i" before each of your interfaces, like so:
|# INTERFACES="-ieth1 -iwlan0"
|INTERFACES="-iwlan0"
|
|# Use the flag "-D" before each driver, like so:
|# DRIVERS="-Dwext"
|DRIVERS="-Dwext"

#如果你需要新增或编辑 wifi ap(接入点),请改动 wpa_supplilcant.conf
vim /etc/wpa_supplicant/wpa_supplicant.conf
|ctrl_interface=/var/run/wpa_supplicant
|ctrl_interface_group=wheel
|network={
| ssid="ap_name"
| psk="password"
| #psk=c0f293f6e1c21bd99d5764a565f9708e187da6972bc96dc5f1c69a35211a3116
|}

3. 配置无线网卡

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

#在 /etc/sysconfig/network-scripts 内有数个描述网络界面的文件,例如
#ifcfg-eth0(大概是你的以太网络),及一个名叫 ifcfg-wlan0 或 ifcfg-eth1 的文
#件,用来描述你的无线网络。
vim /etc/sysconfig/network-scripts/ifcfg-wlan0
|DEVICE=wlan0
|ESSID="linker_1"
|TYPE=Wireless
|BOOTPROTO=static
|IPADDR=192.168.0.201
|NETMASK=255.255.255.0
|GATEWAY=192.168.0.1
|IPV6INIT=no
|NAME="System wlan0"
|ONBOOT=yes
|WPA=yes

#杳看当前可用的无线接入点(ap)
iwlist wlan0 scan

#如果是用DHCP获取IP的,那么用dhclient或dhcpcd获取ip
#dhcpcd wlan0
dhclient wlan0

#为了防止没有无线的情况下dhcp hung在那里,需要做一些工作:
todo

[参考资料]
[1] WPA Supplicant (简体中文), https://wiki.archlinux.org/index.php/WPA_Supplicant_%28%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%29#Configuration_file
Jump to: navigation, search
[1] CentOS 6.4 无线上网设置, http://www.vfeelit.com/504.html
[2] 不依赖 NetworkManager 启用 wpa_supplicant,更新版, http://wiki.centos.org/zh/HowTos/Laptops/WpaSupplicant
[3] Linux 手动无线网卡 WiFi 配置, http://www.jiangmiao.org/blog/1781.html
[4] wpa_supplicant无线网络配置, http://blog.csdn.net/lushengchu_luis/article/details/8807354
[5] linux命令iwconfig配置wlan的使用方法, http://xiaoyao5353.blog.163.com/blog/static/206811114201278761418/
[7] Example wpa_supplicant configuration file, http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=wpa_supplicant/wpa_supplicant.conf
[8] 停用NetworkManager, http://chinesefys.blog.51cto.com/3072467/818652
[9] linux下无线网路连接管理利器---wpa_supplicant的使用, http://itxx.sinaapp.com/blog/content/107
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
centos 7 u盘安装 Aditya Linux 0 2015-06-28 12:18 PM
centos 6.3安装问题总结 topvip Linux 0 2014-03-04 07:38 AM
ssh远程关机 CentOS admin Linux 0 2012-04-24 08:27 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:43 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.