《开发板 — ping得通本地,但是不能上网。route设置默认网关》

在3531D的开发板上面接入LAN7500的USB转以太网口,加载完驱动后。

然后开启eth1

查看一下ifconfig,发现没有ip,配置一下ip

 直接ping本地发现可以ping得通,代表链路是连接的。

 

然后ping www.baidu.com 和百度的ip,发现都ping不上,表示不能连接外网。

运行route,可以发现没有网关,因此添加网关

route add default gw 192.168.60.1(注意这里添加的路由器的默认网关,不一定是60.1。具体根据实际情况配置,可以通过window然后cmd在输入ipconfig

网关的意思就是,通过路由器的这个ip可以去访问外网。

 

然后就发现可以ping得通,如果发现ping得通百度的ip,但是不能ping  www.baidu.com就表示是DNS问题。直接配置/etc/resolv.conf。

 

删除网关

route del default

 

查看路由信息:

[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.233.0   0.0.0.0         255.255.255.0   U     0      0        0 eth1

 

 

 

设置开机自动获取ip,修改启动脚本

cd  /
insmod smsc7500.ko
ifconfig eth1 up
sleep   8
/sbin/udhcpc -b -i eth1

 

posted @ 2019-01-24 10:20  一个不知道干嘛的小萌新  阅读(1115)  评论(0编辑  收藏  举报