红联Linux门户
Linux帮助

Freebsd中拿无线网卡当AP 用

发布时间:2006-05-27 09:56:11来源:红联作者:yo
买来一块108M的PCI无线网卡 型号为D-LINK DWLG520 , 是属于被Freebsd6.0支持的无线网卡,使用的是Atheros 5212芯片,支持HOSTAP模式(能让你的网卡作为AP使用的关键).
第一步,安装无线网卡硬件, 系统中已原有一块8139网卡
第二步,开机进入Freebsd 用Root登陆
#dmesg | more 没有发现任何无线设备,这这时想起没有把驱动编译到内核中当然不会发现这个设备啦
于是执行(注:ath为被Freebsd定义的网卡驱动名字):
#kldload if_ath ;
if_ath_load="YES"
系统自动把另外两个ath的.ko模块也加载到内核中了
再执行ifconfig命令,发现多了一个ath0的设备
ath0: flags=8943 mtu 1500
ether 00:03:2f:12:34:56
于是运行
#ifconfig ath0 inet ssid 108m mode 11g mediaopt hostap up
ifconfig_ath0="inet ssid 108m mode 11g mediaopt hostap"
这样就起用了网卡的ap模式
这时ifconfig ath0 看看
ath0: flags=8943 mtu 1500
ether 00:03:2f:12:34:56
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
status: associated
ssid 108m channel 1 bssid 00:03:2f:12:34:56
authmode OPEN privacy OFF txpowmax 36 protmode CTS dtimperiod 1
bintval 100
此时用一台笔记本电脑的无线网卡就能发现一个108M的无线网络接入点了,但是只能还连接到AP自身而已,
如果笔记本电脑需要访问有线以太网络,还是把ath0 和另外的一块8139网卡桥接起来方便
如何桥接??
Freebsd的网桥实现有两种完全不同的方式
一种是传统的实现 freebsd 很早的版本就有的.
#kldload bridge
#sysctl net.link.ether.bridge.enable=1
这时提示:
rl0: promiscuous mode enabled
ath0: promiscuous mode enabled
bridge_load="YES"
net.link.ether.bridge.enable=1
第二种网桥是Freebsd6.0 新从netbsd中引入的 if_bridge ;
Freebsd官方说以后的版本中要用if_bridge淘汰上面的bridge方式.
内核中要有
device if_bridge
device wlan
device ath
device ath_hal
device ath_rate_onoe
然后重新编译,安装内核 后reboot 系统中就多了一个ath0的设备
# dmesg | grep ath
ath_hal: 0.9.14.9 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413)
npx0: on motherboard
ath0: mem 0xec000000-0xec00ffff irq 11 at device 10.0 on pci1
ath0: Ethernet address: 00:03:2f:12:34:56
ath0: mac 5.6 phy 4.1 radio 1.7
然后开始使用桥
#ifconfig bridge0 create
#ifconfig bridge0
bridge0: flags=8041 mtu 1500
ether ac:de:48:0f:a6:16
priority 32768 hellotime 2 fwddelay 15 maxage 20
(注:删除bridge0接口 用 #ifconfig bridge0 destroy)
然后加入网桥的成员
#ifconfig bridge0 addm rl0 addm ath0
(注:删除网桥成员rl0用 #ifconfig bridge0 deletem rl0)
同样提示:
rl0: promiscuous mode enabled
ath0: promiscuous mode enabled
#ifconfig bridge0 bridge0: flags=8041 mtu 1500 ether ac:de:48:0f:a6:16 priority 32768 hellotime 2 fwddelay 15 maxage 20 member: ath0 flags=3 member: rl0 flags=3
让上面的设置开机自动生效
ifconfig_ath0="inet ssid 108m mode 11g mediaopt hostap" cloned_interfaces="bridge0" ifconfig_bridge0="addm rl0 addm ath0 "
注:本人现使用第二种方式
补充三点:
net.link.ether.inet.log_arp_movements=0
net.link.ether.inet.log_arp_wrong_iface=0
避免过多arp警告之类的信息出现在控制台
三、发现使用第二种网桥后,无线网卡客户端无法PPPoE拨号,似乎pppoe数据包无法通过网桥,经实际测试,用第一种网桥方式,无线网卡客户端可以pppoE拨号 (ADSL猫是通过Switch与BSD的rl0网卡连接的),根据需要自己选择哪种方式吧!
至此大功告成!! 用你笔记本的无线网卡连接上尽情使用吧 :)
12月15日 重要更新(大大提高了AP的稳定性)
请把你的系统源代码更新到最新6.0stable,我是更新到12月15日 ,因为 Freebsd的开发者sam对ath的流量算法sample进行了较大改进, 所以请把ath的控制部分,由onoe 改为sample方式
相关内核配置如下
device ath
device ath_hal
#device ath_rate_onoe
device ath_rate_sample
device wlan
#uname -a
至此, 消除了原来会出现在控制台的2个严重影响ap稳定性的下列错误
ath0: device timeout
ath0: stuck beacon; resetting (bmiss count 4)
文章评论

共有 0 条评论