Chinaunix首页 | 论坛 | 博客
  • 博客访问: 58674
  • 博文数量: 15
  • 博客积分: 695
  • 博客等级: 上士
  • 技术积分: 190
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-16 14:21
文章分类

全部博文(15)

文章存档

2008年(14)

2007年(1)

我的朋友
最近访客

分类: BSD

2008-02-02 09:36:37

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

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

第二步,开机进入Freebsd 用Root登陆
#dmesg &line; more  没有发现任何无线设备,这这时想起没有把驱动编译到内核中当然不会发现这个设备啦

于是 #kldload if_ath ; (ath为被Freebsd定义的网卡驱动名字)
当然 要开机自动加载的话,请修改 /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 &line;  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       i386

至此,  消除了原来会出现在控制台的2个严重影响ap稳定性的下列错误
ath0: device timeout
ath0: stuck beacon; resetting (bmiss count 4)


<最后修改于 15.12.2005 >

阅读(1711) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~