Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15104357
  • 博文数量: 7460
  • 博客积分: 10434
  • 博客等级: 上将
  • 技术积分: 78178
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-02 22:54
文章分类

全部博文(7460)

文章存档

2011年(1)

2009年(669)

2008年(6790)

分类: BSD

2008-03-19 18:04:17

买来一块108M的PCI无线网卡 型号为D-LINK DWLG520 , 是属于被Freebsd6.0支持的无线网卡,使用的是Atheros 5212芯片,支持HOSTAP模式(能让你的网卡作为AP使用的关键).

第一步,安装无线网卡硬件, 系统中已原有一块8139网卡

第二步,开机进入Freebsd 用Root登陆

#dmesg | more 没有发现任何无线设备,这这时想起没有把驱动编译到内核中当然不会发现这个设备啦

于是执行(注:ath为被Freebsd定义的网卡驱动名字):



#kldload if_ath ;


当然 要开机自动加载的话,请修改 /boot/loader.conf 加上



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


如果要让设置开机自动生效 编辑/etc/rc.conf文件 加入



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
#sysctl net.link.ether.bridge.config=rl0,ath0



这时提示:


rl0: promiscuous mode enabled
ath0: promiscuous mode enabled


如果要开机自动生效 请修改 /boot/loader.conf


bridge_load="YES"


然后在 /etc/sysctl.conf 中设置


net.link.ether.bridge.enable=1
net.link.ether.bridge.config=rl0,ath0


第二种网桥是Freebsd6.0 新从netbsd中引入的 if_bridge ;

Freebsd官方说以后的版本中要用if_bridge淘汰上面的bridge方式.

为了方便, 干脆把 ath驱动和 if_bridge 都编译到内核中, 这样就不用 kldload,也不用修改loader.conf了

内核中要有



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 "
注:本人现使用第二种方式

补充三点:

一、如果你要在 网桥中的无线网卡ath0设置ip 或者bridge0接口设置IP 并且要使用与系统原有8139网卡相同的网段 请使用 255.255.255.255的掩码来设置IP地址,如安装了isc-dhcpd v3的dhcp服务软件后,这样做是推荐的,因为默认的isc-dhcp服务启动时检查每个接口IP,接口IP与dhcpd.conf 设置的动态分配ip不在同网段时,则服务不监听此接口

二、如果你在上面的接口设置了与8139网卡同网段的IP地址 请把/etc/sysctl.conf 中把下列参数设置为0



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

FreeBSD xxx.com 6.0-STABLE FreeBSD 6.0-STABLE #2: Thu Dec 15 10:04:54 CST 2005 root@xxx.com:/usr/obj/usr/src/sys/file5 i386



至此, 消除了原来会出现在控制台的2个严重影响ap稳定性的下列错误


ath0: device timeout
ath0: stuck beacon; resetting (bmiss count 4)
阅读(587) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~