FreeBSD 7.1 Release下使用 Intel 4965AGN Intel Wireless WiFi Link 4965AGN的方法[原创分享]
发到CU上的文章地址 http://bbs3.chinaunix.net/thread-1394888-1-1.html

我的BLOG上的记录  
感谢zhpalt的热心帮助,以下文档比较粗糙,以后慢慢添加修改,路由那块只懂点最基本的用法,还有待修改

1. 参考网址
http://www.mavetju.org/mail/view ... ware&id=2730092   介绍iwn使用的文章

trying iwn driver from
http://perforce.freebsd.org/file ... ot/user/benjsc/iwn/

http://perforce.freebsd.org/depo ... /iwn&HIDEDEL=NO iwn代码所在地

http://blog.disarm.jp/?p=51 日文的文档
[url] http://www.freebsd.org/doc/zh_CN ... twork-wireless.html[/url] 官方手册无线网络部分
2. 代码下载
首先通过P4fetch.rb下载这个ruby脚本
在运行过程中出现找不到 hpricot 模块

[Copy to clipboard] [ - ]CODE:[axlrose@mybsd iwn] $ pkgsearch hpricot
/usr/ports/www/rubygem-hpricot


[Copy to clipboard] [ - ]CODE:function pkg-get() {  
#因为习惯于普通用户模式下操作,所以比较常用sudo命令来操作
sudo sh -c "PKGDIR=/usr/mypkgs/ PACKAGEROOT=ftp://ftp2.jp.freebsd.org pkg_add -rvK $@"
}


[Copy to clipboard] [ - ]CODE:pkg-get   rubygem-hpricot   下载并保存到 /usr/mypkgs目录
使用正宗方式 pkg_add -r rubygem-hpricot


[Copy to clipboard] [ - ]CODE:./P4fetch.rb --depot //depot/user/benjsc/ --repo iwn
3. 代码编译

[Copy to clipboard] [ - ]CODE:# cd iwn/iwn
# cd sys/modules/iwnfw
# make
# make install

cd sys/modules/iwn
make
mkae install
4. 安装后的加载与配置

[Copy to clipboard] [ - ]CODE:/boot/loader.conf
legal.intel_iwn.license_ack=1

kenv legal.intel_iwn.license_ack=1
kldload if_iwn
安装后的测试

[Copy to clipboard] [ - ]CODE:[axlrose@mybsd ~] $ pciconf -lv|grep 4965AGN
device     = 'Intel 4965AGN Intel   Wireless WiFi Link 4965AGN'

[axlrose@mybsd ~] $ sudo dmesg |grep iwn|head -n 10
iwn0: error, INTR=82000000<SW_ERROR,RX_INTR> STATUS=0x10000
iwn0: iwn_config: could not set power mode, error 35
iwn0: link state changed to UP
iwn0: link state changed to DOWN
iwn0: device timeout
iwn0: link state changed to UP
arp: 192.168.1.1 is on em0 but got reply from 00:1c:10:55:0a:c9 on iwn0
arp: 192.168.1.1 is on em0 but got reply from 00:1c:10:55:0a:c9 on iwn0
arp: 192.168.1.1 is on em0 but got reply from 00:1c:10:55:0a:c9 on iwn0
arp: 192.168.1.1 is on em0 but got reply from 00:1c:10:55:0a:c9 on iwn0



[axlrose@mybsd ~] $ sudo ifconfig
em0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=19b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4>
ether 00:1e:37:d0:d9:5d
inet 192.168.2.10 netmask 0xffffff00 broadcast 192.168.2.255
media: Ethernet autoselect
status: no carrier
iwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:1f:3b:94:50:a9
inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255
inet 192.168.1.8 netmask 0xffffff00 broadcast 192.168.1.255
media: IEEE 802.11 Wireless Ethernet autoselect (OFDM/54Mbps)
status: associated
ssid home channel 6 (2437 Mhz 11g) bssid 00:1c:10:55:0a:cb
authmode WPA2/802.11i privacy ON deftxkey UNDEF TKIP 3:128-bit
txpower 50 bmiss 10 scanvalid 60 protmode CTS roaming MANUAL
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
--------------------------------
以下是我的/boot/loader.conf 与无线相关的模块加载配置

[Copy to clipboard] [ - ]CODE:if_iwn_load="YES"
legal.intel_iwn.license_ack=1
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
wlan_scan_ap_load="YES"
wlan_scan_sta_load="YES"
--------------------------------
5. 使用 wpa_supplicant 的配置方法
以下是我的连接无线网络的脚本, 是跟据以前linux下的脚本修改的,目前路由那块还在改进,以下方法有问题

[Copy to clipboard] [ - ]CODE:$ cat connet_home.sh
#!/usr/local/bin/bash
#!/bin/bash
#===============================================================================
WLAN_DEV="iwn0"
LAN_DEV=em0
IP=192.168.1.8
GW=192.168.1.1
ROUTE=192.168.1.1
BASE_DIR="."
CFG_FILE=wpa_supplicant_home_cfg.conf
#${BASE_DIR}/del_eth0_route.sh

sudo ifconfig $LAN_DEV down
#sudo ip r d   default dev eth0
sudo route del default
sudo route del 192.168.1.0/24
sudo route flush
sudo ifconfig ${WALN_DEV} down
sudo ifconfig ${WALN_DEV} up

if [ `pidof wpa_supplicant|wc -w` -eq 0 ] ; then
echo "wpa no running"
else
sudo killall -9 wpa_supplicant
fi

sudo wpa_supplicant -dd -i ${WLAN_DEV} -c ${BASE_DIR}/$CFG_FILE -B
sleep 3
#sudo ifconfig wlan0 192.168.1.8
#sudo dhclient $WLAN_DEV
sudo ifconfig $WLAN_DEV $IP
#sudo ifconfig $WLAN_DEV:1 192.168.1.9
#sudo ip r a default via $GW dev $WLAN_DEV
sudo ifconfig $LAN_DEV 192.168.2.2 # <<<< 故意改的ip为另一个网段的地址
sudo route add default $ROUTE
####修改路由还不熟,以前使用的是linux下的iproute2比较方便,现在不会指定设备来添加路由
-----------------------------------------------
以下是配置文件

[Copy to clipboard] [ - ]CODE:[axlrose@mybsd iwn] $ cat wpa_supplicant_home_cfg.conf
# This is a network block that connects to any unsecured access point.
# We give it a low priority so any defined blocks are preferred.
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1

eapol_version=1
#ap_scan=1
fast_reauth=1


network={
ssid="home"   <<<---- ssid
#psk="密码明码"
psk=b5971ceb09ef6ca002accbfbe9b6742f8716677d2479bc0c8affef5d0b10fdb0 ##加密后的密码数据
}


[Copy to clipboard] [ - ]CODE:[axlrose@mybsd iwn] $ uname -a
FreeBSD mybsd.mybsd.org 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan   1 14:37:25 UTC 2009     [email]root@logan.cse.buffalo.edu[/email]:/usr/obj/usr/src/sys/GENERIC   i386
最后附上两张FreeBSD桌面截图
http://paste.ubuntu.org.cn/i13351
http://paste.ubuntu.org.cn/i13345
这张是gentoo 的,没多大区别
http://paste.ubuntu.org.cn/i13157