Buildroot
PC端配置
Windows 安全中心—>防火墙和网络保护—>关闭防火墙。
配置 RNDIS 网卡的静态IP,打开设置—>高级网络设置—>更改适配器选项。
连接开发板后,PC端会多出一个未识别的本地网络。
将PC网络共享给开发板网络。
配置开发板网络信息。
开发板配置
添加路由信息
route add default gw 172.32.0.100
添加 DNS servers
打开文件
vi /etc/resolv.conf
添加以下内容:
nameserver 8.8.8.8
联网测试
ping -I usb0 www.baidu.com
开机自动配置
路由信息和 DNS servers 重启后会被清除,我们创建一个脚本开机后自动帮我们完成配置
cd /etc/init.d
vi S99usb_network添加以下内容:
#!/bin/sh
case $1 in
start)
route add default gw 172.32.0.100
echo "nameserver 8.8.8.8" > /etc/resolv.conf
;;
stop)
;;
*)
exit 1
;;
esac修改脚本权限
chmod 775 S99usb_network
网络测试
查看路由信息
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.32.0.100 0.0.0.0 UG 0 0 0 usb0
172.32.0.0 0.0.0.0 255.255.0.0 U 0 0 0 usb0查看 DNS servers
# cat /etc/resolv.conf
nameserver 8.8.8.8网络测试
# ping -I usb0 www.baidu.com
PING www.baidu.com (183.2.172.42): 56 data bytes
64 bytes from 183.2.172.42: seq=0 ttl=50 time=9.827 ms
64 bytes from 183.2.172.42: seq=1 ttl=50 time=9.258 ms
64 bytes from 183.2.172.42: seq=2 ttl=50 time=8.340 ms
64 bytes from 183.2.172.42: seq=3 ttl=50 time=8.994 ms
64 bytes from 183.2.172.42: seq=4 ttl=50 time=9.933 ms
64 bytes from 183.2.172.42: seq=5 ttl=50 time=8.321 ms
64 bytes from 183.2.172.42: seq=6 ttl=50 time=8.609 ms
64 bytes from 183.2.172.42: seq=7 ttl=50 time=9.013 ms
64 bytes from 183.2.172.42: seq=8 ttl=50 time=9.234 ms
64 bytes from 183.2.172.42: seq=9 ttl=50 time=9.284 ms
^C
--- www.baidu.com ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 8.321/9.081/9.933 ms