您的位置:首页 > 其它

wpa_supplicant移植安装

2016-04-28 20:35 232 查看
前面讲了iw工具的使用,这篇文章来讲解wpa_supplicant工具的安装和使用

用到的源码:

openssl-1.0.1d.tar.gz,    
下载地址:点击这里!

wpa_supplicant-2.0.tar.gz 下 载地址:点击这里!

以手机上WIFI热点为例,有4种常用的"认证/加密"

a. open

b. WEP

c. WPA(TKIP)

d. WPA2(AES)

wpa_supplicant : 可用于上述4种"认证/加密"

需要用到libopenssl库文件,先编译它的依赖libopenssl

tar xzf openssl-1.0.1d.tar.gz

cd openssl-1.0.1d/

./config shared no-asm --prefix=$PWD/tmp

修改Makefile:

CC= arm-linux-gcc

AR= arm-linux-ar $(ARFLAGS) r

RANLIB= arm-linux-ranlib

NM= arm-linux-nm

MAKEDEPPROG= arm-linux-gcc

make

make install

/* 把tmp目录头文件和库文件放在交叉工具链路径下,并且库文件复制到根文件系统的lib */

把编译出来的头文件应该放入:/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include

把编译出来的库文件应该放入:/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib

把编译出来的库文件应该放入根文件系统的lib目录:

编译wpa_supplicant-2.0.tar.gz 

tar xzf wpa_supplicant-2.0.tar.gz 

cd wpa_supplicant-2.0/wpa_supplicant/

cp defconfig .config

修改.config加上一行: CONFIG_LIBNL32=y    /* 不加提示找不到-lnl库 */

修改Makefile:

CC=arm-linux-gcc

make

make DESTDIR=$PWD/tmp install

把wpa_supplicant/examples/plaintext.conf配置文件复制到开发板的etc目录下

启动开发板用下面的命令:

mkdir -p /var/run/wpa_supplicant

① OPEN

wpa_supplicant -B -c/etc/plaintext.conf -iwlan0

wpa_cli -iwlan0 status  // 查看状态

ifconfig wlan0 172.168.1.55     /* 无线网卡的IP */

ping 172.168.1.1                         /* 无线网卡的网关 */

配置文件内容为:

ctrl_interface=/var/run/wpa_supplicant

network={

        ssid="Linux"

        key_mgmt=NONE

}

② WEP/WEP

wpa_supplicant -B -c/etc/wep.conf  -iwlan0

wpa_cli -iwlan0 status  // 查看状态

ifconfig wlan0 192.168.1.55

ping 192.168.1.1

配置文件:

ctrl_interface=/var/run/wpa_supplicant

network={

        ssid="Linux"

        key_mgmt=NONE

        wep_key0="Linux"

        wep_tx_keyidx=0

}

③WPA(TKIP)

wpa_supplicant -B -c/etc/wpa-psk-tkip.conf  -iwlan0

wpa_cli -iwlan0 status  // 查看状态

ifconfig wlan0 192.168.1.55

ping 192.168.1.1

配置文件

ctrl_interface=/var/run/wpa_supplicant  # 一个目录,用于wpa_supplicant和wpa_cli的socket通信

network={

        ssid="Linux"

        proto=WPA  # proto: list of accepted protocols, 可取WPA,RSN

                   # If not set, this defaults to: WPA RSN

        key_mgmt=WPA-PSK # 认证方式

                         # If not set, this defaults to: WPA-PSK WPA-EAP

        pairwise=TKIP    # If not set, this defaults to: CCMP TKIP

        group=TKIP       # If not set, this defaults to: CCMP TKIP WEP104 WEP40 

        psk="Linux"    /* 密码 */

}

④ WPA2(AES)

wpa_supplicant -B -c/etc/wpa_wpa2.conf  -iwlan0

wpa_cli -iwlan0 status  // 查看状态

ifconfig wlan0 192.168.1.55

ping 192.168.1.1

配置文件:

ctrl_interface=/var/run/wpa_supplicant

network={

        ssid="Linux"

        psk="Linux"

}

另:

wpa_cli可工作于"命令模式"和"交互模式"

⑤ 配置文件里设置多个network:

ctrl_interface=/var/run/wpa_supplicant

network={

        ssid="Linux"

        psk="baiwenwang123"

}

network={

        ssid="Linux1"

        psk="Linux"

}

⑥ 访问外网:

修改/etc/resolv.conf添加DNS:

nameserver 192.168.1.1

设置网关:

route add default gw 192.168.1.1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: