开发板ping外网与localhost

2019-07-13 01:29发布

从nfs启动后,可以ping内网ip,外网ping不通

[root@Industech /]# ping 192.168.0.108             
PING 192.168.0.108 (192.168.0.108): 56 data bytes
64 bytes from 192.168.0.108: seq=0 ttl=64 time=0.597 ms
--- 192.168.0.108 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.597/0.597/0.597 ms     
[root@Industech /]#    
ping 220.181.111.148                                                                                        
PING 220.181.111.148 (220.181.111.148): 56 data bytes                                                                                 
ping: sendto: Network is unreachable

1.设置域名(下面的域名如果不行,可以网上搜)
echo nameserver 203.80.96.10 > /etc/resolv.conf

[root@Industech /]# ping www.baidu.com
ping: bad address 'www.baidu.com'    
[root@Industech /]# ping 220.181.111.148
PING 220.181.111.148 (220.181.111.148): 56 data bytes
ping: sendto: Network is unreachable                

2.设置默认路由
/sbin/route add default gw 192.168.0.1
设置默认路由之后,可以ping通外网ip 作者 : 帅得不敢出门  C++哈哈堂<31843264> 转载请保留此信息


ping localhost
ping: bad address 'localhost'

cat etc/hosts
127.0.0.1       localhost
127.0.0.2       jyxtec
解决方法:挎贝主机etc/nsswitch.conf 到板子上,如果能ping通localhost,不能ping通外网网址,则修改nsswitch.conf
hosts:      files mdns4_minimal [NOTFOUND=return] dns

hosts:      files dns