现象
板子无法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