买来一块108M的PCI无线网卡 型号为D-LINK DWLG520 , 是属于被Freebsd6.0支持的无线网卡,使用的是Atheros 5212芯片,支持HOSTAP模式(能让你的网卡作为AP使用的关键).
第一步,安装无线网卡硬件, 系统中已原有一块8139网卡 .
第二步,开机进入Freebsd 用Root登陆
#dmesg &line; more 没有发现任何无线设备,这这时想起没有把驱动编译到内核中当然不会发现这个设备啦
于是 #kldload if_ath ; (ath为被Freebsd定义的网卡驱动名字)
系统自动把另外两个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
这样就起用了网卡的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 &line; grep ath
ath_hal: 0.9.14.9 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413)
npx0: