2、移植好了之后还没有完全配置好网卡,需进行下面步骤才可连接加密路由:
2.1从RT3070网卡的光盘资料中找到wpa_supplicant-0.7.2.tar.gz和openssl-0.9.8e.tar.gz拷贝到虚拟机的个人文件夹里面,并且解压。
#tar xzvf openssl-0.9.8e.tar.gz
#tar xvvf wpa_supplicant-0.7.2.tar.gz
#cd wpa_supplicant-0.7.2/patches/
将 openssl-0.9.8e-tls-extensions.patch 拷贝到 openssl-0.9.8e 源码目录下,切换到openssl-0.9.8e 源码目录下将上述打入上述补丁。
#patch -p1 < openssl-0.9.8e-tls-extensions.patch
配置 openssl-0.9.8e 源码
新建一个安装目录
#mkdir /opt/openssl
#./Configure linux-elf-arm -DL_ENDIAN linux:arm-linux-gcc no-shared --prefix=/opt/openssl
其中 prefix 选项为编译后程序安装的目录
#make
#make install
配置编译 wpa_supplicant-0.7.2 源文件,在 wpa_supplicant-0.7.2/wpa_supplicant目录
下对 makefile 进行修改
#vi Makefile
保存
#cp defconfig .config
#make
将编译生成的 wpa_supplicant 和 wpa_cli 拷贝到目标板的/bin 目录下
2.2在开发板/etc 目录下添加配置无线网络的配置文件:内容如下,命名为 wpa_supplicant.conf #vi wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
eapol_version=1
ap_scan=1
fast_reauth=1
# WPA2:
network={
ssid="HLY"
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=TKIP CCMP WEP104 WEP40
psk="HLY7654321"
priority=50
}
# WPA:
network={
ssid="HLY"
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
scan_ssid=1
psk="HLY7654321"
priority=10
}
# WEP:
network={
ssid="HLY"
scan_ssid=1
key_mgmt=NONE
wep_tx_keyidx=0
wep_key0=12345678af (psk=”HLY7654321”)
priority=8
}
# Open:
network={
ssid="HLY" (psk=”HLY7654321”)
key_mgmt=NONE
priority=5
}
2.3在开发板建立目录/var/run/wpa_supplicant
#mkdir -p /var/run/wpa_supplicant
添加如下脚本来自动加载驱动和配置文件,在开发板顶层目录建立ra.sh脚本文件
#cd /
#vi ra.sh
#!/bin/sh
if [ -z $1 ]; then
echo " $0 usage ";
exit 0;
fi
config="/etc/wpa_supplicant.conf"
#WPA2
sed -i "8 c ssid="${1}"" $config
sed -i "14 c psk="${2}"" $config
#WPA
sed -i "19 c ssid="${1}"" $config
sed -i "25 c psk="${2}"" $config
#WEP
sed -i "30 c ssid="${1}"" $config
sed -i "34 c psk="${2}"" $config
#OPEN
sed -i "39 c psk="${2}"" $config
/bin/wpa_supplicant -B -i ra0 -c/etc/wpa_supplicant.conf -Dwext
sleep 2
ifconfig eth0 down
ifconfig ra0 up
sleep 2
udhcpc -i ra0
#echo "nameserver 192.168.1.1" > /etc/resolv.conf
#ifconfig ra0 192.168.1.22
#route add default gw 192.168.1.1
2.4在开发板建立目录/usr/share/udhcpc/
#mkdir -p /usr/share/udhcpc/
进入该目录,建立 udhcpc 配置脚本 default.script
#cd /usr/share/udhcpc/
#vi default.script
#!/bin/sh
RESOLV_CONF="/etc/resolv.conf"
[ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; }
NETMASK=""
[ -n "$subnet" ] && NETMASK="netmask $subnet"
BROADCAST="broadcast +"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
case "$1" in
deconfig)
echo "Setting IP address 0.0.0.0 on $interface"
ifconfig $interface 0.0.0.0
;;
renew|bound)
echo "Setting IP address $ip on $interface"
ifconfig $interface $ip $NETMASK $BROADCAST
if [ -n "$router" ] ; then
echo "Deleting routers"
while route del default gw 0.0.0.0 dev $interface ; do
:
done
metric=0
for i in $router ; do
echo "Adding router $i"
route add default gw $i dev $interface metric $((metric++))
done
fi
echo "Recreating $RESOLV_CONF"
echo -n > $RESOLV_CONF-$$
[ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$
for i in $dns ; do
echo " Adding DNS server $i"
echo "nameserver $i" >> $RESOLV_CONF-$$
done
mv $RESOLV_CONF-$$ $RESOLV_CONF
;;
esac
exit 0
建立必要的文件/etc/resolv.conf
#touch /etc/resolv.conf
改变权限
#chmod 777 /etc/resolv.conf
2.5一切准备好之后,运行 ra.sh 这个脚本就可以连接上无线网络,运行这个脚本需要提供两个参数,第一个参数是无线网络的 SSID,第二个参数是无线网络的密码。
#cd /
#./ra.sh HLY HLY7654321
有如下打印
附注:
1、启动无线:#ifconfig ra0 up
2、设置IP:#ifconfig ra0 192.168.1.230 netmask 255.255.255.0
3、扫描无线网络:#iwlist ra0 scan
4、查看网卡连接WIFI状态:#iwconfig ra0
5、连接路由:#iwconfig ra0 essid "Netcore"
6、设置路由密码:#iwconfig ra0 key HLY7654321