———————————————————————————————————————
主机操作系统:Centos 6.7
交叉编译器环境:arm-linux-gcc-4.5.4
开发板平台: FL2440
Linux内核版本: linux-3.0
开发模块: SIM900 WiFI-STA模式
邮箱:leiyuxing205@gmail.com
———————————————————————————————————————
=====================================================================
而我想要的是板子自己去动态随机获取IP联网,这样可以不用给wlan0指定IP。接下我们来完成这个功能。
=====================================================================
一.要支持动态获取的话,你需要在内核中和制作文件系统的内核部分和bysybox部分选中必要的选项
1. 内核部分
Networking --->
Networking support
Networking options --->
Packet socket //添加.配置CONFIG_PACKET
[ * ] IP: DHCP support //添加
[ * ] Network packet filtering (replaces ipchains)
2.busybox部分
[*]udhcp server(udhcpd)
[*]udhcp client(udhcpc)都选上
udhcpd就是终端设备作为DHCP服务器 ;udhcpc就是终端设备作为DHCP客户端
Networking Utilities --->
[*] udhcp client for DHCPv6 (udhcpc6)
[*] udhcp server (udhcpd) //生成udhcpc命令
make
sudo make install
二.从busybox的examples/udhcp/下copy好simple.script文件到开发板/usr/share/udhcpc/下,并重命名为default.script.注意更改default.script的权限!!!
>: chmod a+x default.script
连接你的路由器:
>: wpa_supplicant -Dwext -iwlan0 -c/apps/etc/wireless/wpa_supplicant.conf &
>: phy0 -> rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'.
phy0 -> rt2x00lib_request_firmware: Info - Firmware detected - version: 0.36.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 3, CWmax: 4, Aifs: 2, TXop: 102.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 4, CWmax: 5, Aifs: 2, TXop: 188.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 5, CWmax: 10, Aifs: 3, TXop: 0.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 5, CWmax: 10, Aifs: 7, TXop: 0.
Trying to associate with d4:ee:07:22:6b:5c (SSID='HiWiFi_LingYun' freq=2412 MHz)
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 5, CWmax: 10, Aifs: 3, TXop: 0.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 4, CWmax: 10, Aifs: 7, TXop: 0.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 3, CWmax: 4, Aifs: 2, TXop: 94.
phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 2, CWmax: 3, Aifs: 2, TXop: 47.
Associated with d4:ee:07:22:6b:5c
WPA: Key negotiation completed with d4:ee:07:22:6b:5c [PTK=CCMP GTK=CCMP]
CTRL-EVENT-CONNECTED - Connection to d4:ee:07:22:6b:5c completed (auth) [id=0 id_str=]
动态获取IP地址:
>: udhcpc -i wlan0
udhcpc (v1.20.2) started
Setting IP address 0.0.0.0 on wlan0
Sending discover...
Sending select for 192.168.199.245...
Lease of 192.168.199.245 obtained, lease time 43200
Setting IP address 192.168.199.245 on wlan0
Deleting routers
route: SIOCDELRT: No such process
Adding router 192.168.199.1
Recreating /etc/resolv.conf
Adding DNS server 192.168.199.1
>: ping 4.2.2.2
PING 4.2.2.2 (4.2.2.2): 56 data bytes
64 bytes from 4.2.2.2: seq=0 ttl=43 time=277.500 ms
64 bytes from 4.2.2.2: seq=1 ttl=43 time=363.115 ms
64 bytes from 4.2.2.2: seq=2 ttl=43 time=381.084 ms
64 bytes from 4.2.2.2: seq=3 ttl=43 time=400.133 ms
64 bytes from 4.2.2.2: seq=4 ttl=43 time=419.020 ms
64 bytes from 4.2.2.2: seq=5 ttl=43 time=370.071 ms
64 bytes from 4.2.2.2: seq=6 ttl=43 time=354.070 m
--- 4.2.2.2 ping statistics ---
16packets transmitted, 7 packets received, 5% packet loss
round-trip min/avg/max = 277.500/386.415/449.047 ms
>: ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=6 ttl=39 time=88.134 ms
64 bytes from 8.8.8.8: seq=12 ttl=39 time=89.959 ms
64 bytes from 8.8.8.8: seq=13 ttl=39 time=84.943 ms
64 bytes from 8.8.8.8: seq=15 ttl=39 time=95.898 ms
--- 8.8.8.8 ping statistics ---
16 packets transmitted, 4 packets received, 75% packet loss
round-trip min/avg/max = 84.943/89.733/95.898 ms
>: ping www.baidu.com
PING www.baidu.com (119.75.218.70): 56 data bytes
64 bytes from 119.75.218.70: seq=0 ttl=53 time=26.076 ms
64 bytes from 119.75.218.70: seq=1 ttl=53 time=65.218 ms
64 bytes from 119.75.218.70: seq=2 ttl=53 time=65.232 ms
64 bytes from 119.75.218.70: seq=3 ttl=53 time=66.166 ms
64 bytes from 119.75.218.70: seq=4 ttl=53 time=66.125 ms
64 bytes from 119.75.218.70: seq=5 ttl=53 time=25.296 ms
64 bytes from 119.75.218.70: seq=6 ttl=53 time=65.288 ms
64 bytes from 119.75.218.70: seq=7 ttl=53 time=70.324 ms
--- www.baidu.com ping statistics ---
8 packets transmitted, 8 packets received, 0% packet loss
round-trip min/avg/max = 25.296/56.215/70.324 ms
查看相关网关信息
>: route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default Hiwifi.lan 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.199.0 * 255.255.255.0 U 0 0 0 wlan0
标签:seq,IP地址,time,bytes,ms64,station,ttl,Rt3070,8.8 From: https://blog.51cto.com/u_15834920/5767600