hostapd实现WIFI 热点(AP)


分类: Linux桌面系统   12304人阅读  评论(4)  收藏  举报

目录(?)[+]

在UBUNTU系统或者其他类似linux系统上,使用hostapd,可以实现WIFI的无线接入热点(AP)
以便提供给其他需要无线接入联网的设备,如笔记本,手机实现无线上网功能。也即是无线路由的功能。
什么是hostapd
hostapd 是用户控件的守护进程用于无线接入点(AP)和授权服务器(authentication servers).
她实现了IEEE802.11的AP管理,IEEE802.1X/WPA/WPA2/EAP授权,RADIUS 客户端,EAP服务器和RADIUS 授权服务器,目前最新版本支持Linux系统(HOST AP,madwifi,mac80211-based驱动)和FreeBSD(net80211)。
hostapd设计为一个守护程序(进程),后台运行,进行一些相关控制授权的操作。属于一个开源项目。
相关链接:
http://w1.fi/hostapd/
http://linuxwireless.org/en/users/Documentation/hostapd

查看自己的无线网卡信息:

[cpp]  view plain copy
  1. wsn@wsn-laptop:~$ hwinfo --netcard  
  2. ...  
  3. 28: PCI e00.0: 0282 WLAN controller  
  4.   [Created at pci.318]  
  5.   UDI: /org/freedesktop/Hal/devices/pci_14e4_4315  
  6.   Unique ID: y9sn.reAAs+k0MA5  
  7.   Parent ID: hoOk.F8Gordq8HH2  
  8.   SysFS ID: /devices/pci0000:00/0000:00:1c.2/0000:0e:00.0  
  9.   SysFS BusID: 0000:0e:00.0  
  10.   Hardware Class: network  
  11.   Model: "Dell Wireless 1397 WLAN Mini-Card"  
  12.   Vendor: pci 0x14e4 "Broadcom"  
  13.   Device: pci 0x4315 "BCM4312 802.11b/g"  
  14.   SubVendor: pci 0x1028 "Dell"  
  15.   SubDevice: pci 0x000c "Wireless 1397 WLAN Mini-Card"  
  16.   Revision: 0x01  
  17.   Driver: "b43-pci-bridge"  
  18.   Driver Modules: "ssb"  
  19.   Device File: wlan0  
  20.   Features: WLAN  
  21.   Memory Range: 0xf3000000-0xf3003fff (rw,non-prefetchable)  
  22.   IRQ: 18 (557260 events)  
  23.   HW Address: 00:22:5f:85:e7:a7  
  24.   Link detected: yes  
  25.   WLAN channels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  
  26.   WLAN frequencies: 2.412 2.417 2.422 2.427 2.432 2.437 2.442 2.447 2.452 2.457 2.462 2.467 2.472 2.484  
  27.   WLAN encryption modes: WEP40 WEP104 TKIP CCMP  
  28.   WLAN authentication modes: open sharedkey wpa-psk wpa-eap  
  29.   Module Alias: "pci:v000014E4d00004315sv00001028sd0000000Cbc02sc80i00"  
  30.   Driver Info #0:  
  31.     Driver Status: ssb is active  
  32.     Driver Activation Cmd: "modprobe ssb"  
  33.   Config Status: cfg=new, avail=yes, need=no, active=unknown  
  34.   Attached to: #16 (PCI bridge)  

Ubuntu下,如何获取hostapd?

1. 终端输入命
[cpp]  view plain copy
  1. sudo apt-get install hostapd  
2. 最新版本可以通过git命令
[cpp]  view plain copy
  1. sudo apt-get install git-core  
  2. git clone git://w1.fi/srv/git/hostap.git  
3. 选择自己所需版本
[cpp]  view plain copy
  1. http://w1.fi/hostapd/  

如何使用hostapd

将获取到的包解压,进入hostapd.
[cpp]  view plain copy
  1. tar xzvf hostapd-x.y.z.tar.gz  
  2. cd hostapd-x.y.z/hostapd  
复制一份默认的配置文件
[cpp]  view plain copy
  1. cp defconfig .config  
编辑.config文件,找到
#CONFIG_DRIVER_NL80211=y
修改为
CONFIG——DIRVIERNL80211
最后编译:
sudo make
如果编译报错,原因多是libnl库出错,通过安装或升级libnl库即可
该库主要提供基于LINUX内核的netlink protocol相关APs函数。
这里下载获取,要求版本0.8以上
[cpp]  view plain copy
  1. http://www.infradead.org/~tgr/libnl/  
如果还出错,那么需要安装libssl-dev:
该库提供ssl开发库
[cpp]  view plain copy
  1. sudo apt-get install libssl-dev  
编译好后,得到hostapd执行文件
如何使用hostapd?
hostapd的功能,也就是笔记本通过有线网口介入,hostapd利用笔记本的无线网卡,实现无线路由。
编辑hostapd.conf文件
可以根据自己的网卡,参照这里
[cpp]  view plain copy
  1. http://linuxwireless.org/en/users/Documentation/hostap  
一个简单的配置文件:
[cpp]  view plain copy
  1. interface=wlan0  
  2. bridge=br0  
  3. driver=nl80211  
  4. ssid=ssa  
  5. hw_mode=g  
  6. channel=11  
  7. dtim_period=1  
  8. rts_threshold=2347  
  9. fragm_threshold=2346  
  10. auth_algs=3  
  11. wpa=1  
  12. wpa_passphrase=12345678  
  13. wpa_key_mgmt=WPA-PSK  
  14. wpa_pairwise=TKIP CCMP  
  15. rsn_pairwise=CCMP  
搭建网桥:
[cpp]  view plain copy
  1. sudo apt-get install bridge-utils  
建立网桥:
[cpp]  view plain copy
  1. sudo brctl adbr br0  
  2. sudo ifconfig br0 192.168.2.236 netmask 255.255.255.0  
  3. sudo route add default gw 192.168.2.254  
连接网桥两端:
[cpp]  view plain copy
  1. sudo brctl addif br0 eth0  
  2. sudo brctl addif br0 wlan0  
最后:
[cpp]  view plain copy
  1. sudo ./hostapd hostapd.conf  
如果一切顺利,将在终端看到一下类似字样:
[cpp]  view plain copy
  1. root@wsn-laptop:/home/wsn/Desktop/hostapd-0.7.3/hostapd# ./hostapd hostapd.conf   
  2. Configuration file: hostapd.conf  
  3. Using interface wlan0 with hwaddr 00:22:5f:85:e7:a7 and ssid 'ubuntu-502d'  
android手机打开wifi并且设置静态ip
如ip:192.168.3.75 
掩码: 255.255.255.0  
网管: 192.168.3.1

即可以连接到名为ubuntu-502的无线热点了。
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值