Zedboard petalinux 网络配置 解决办法 ping: sendto: Network is unreachable

现象

板子无法ping通电脑端

可以ping通自己:

ping 127.0.0.1

PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.194 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.105 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.090 ms
64 bytes from 127.0.0.1: seq=3 ttl=64 time=0.090 ms
64 bytes from 127.0.0.1: seq=4 ttl=64 time=0.089 ms
64 bytes from 127.0.0.1: seq=5 ttl=64 time=0.093 ms
64 bytes from 127.0.0.1: seq=6 ttl=64 time=0.097 ms
64 bytes from 127.0.0.1: seq=7 ttl=64 time=0.092 ms
64 bytes from 127.0.0.1: seq=8 ttl=64 time=0.087 ms

使用ifconfig 查看本机的IP配置


root@avnet-digilent-zedboard-2018_3:/usr/bin# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0A:35:00:1E:53
          inet6 addr: fe80::20a:35ff:fe00:1e53%lo/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5513 errors:0 dropped:0 overruns:0 frame:0
          TX packets:383 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1130369 (1.0 MiB)  TX bytes:127002 (124.0 KiB)
          Interrupt:27 Base address:0xb000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:792 (792.0 B)  TX bytes:792 (792.0 B)

问题

可以看到没有IP。

需要设置一个IP。

解决

法1:

petalinux中取消自动获取IP,按"N"键
在这里插入图片描述

1 设置查看本机IP

在这里插入图片描述

2 板端设置

2.1 设置 板子IP

 ifconfig eth0 192.168.2.187 netmask 255.255.255.0


root@avnet-digilent-zedboard-2018_3:/usr/bin# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.2.1     0.0.0.0         UG    0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0

2.2 设置网关

发现网关(Gateway),是空着的没有设置,于是执行一下命令设置了网关:

# route add default gw 192.168.2.1
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 rausb0
default         192.168.2.1     0.0.0.0         UG    0      0        0 rausb0

2.3 成功


root@avnet-digilent-zedboard-2018_3:/usr/bin# ping 192.168.2.187
PING 192.168.2.187 (192.168.2.187): 56 data bytes
64 bytes from 192.168.2.187: seq=0 ttl=64 time=0.253 ms
64 bytes from 192.168.2.187: seq=1 ttl=64 time=0.108 ms
64 bytes from 192.168.2.187: seq=2 ttl=64 time=0.098 ms
64 bytes from 192.168.2.187: seq=3 ttl=64 time=0.101 ms

ref
https://blog.csdn.net/juxianliyu/article/details/43534491?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值