无法 ping 或 ssh 进入嵌入式 Linux 设备:eno1 没有 IPv4 地址

无法 ping 或 ssh 进入嵌入式 Linux 设备:eno1 没有 IPv4 地址

我正在尝试连接到运行的 Ubuntu 服务器ssh(我们称之为)的嵌入式 Linux 设备(我们称之为)。并通过直接以太网电缆和串行 UART 连接。我可以使用串行终端 ( ) 连接到设备,但超时。我也无法使用该设备。所以,我相信这是两件事之一:petalinux22.04oippetalinuxoipminicomsshping

  • 网络设置不兼容(子网掩码、网关等),或者
  • 嵌入式 Linux 设备上的防火墙不允许流量通过。

为了检查第一个,我尝试查找oip;的 IP 地址。但是,我没有看到与以下相关的 IPv4 eno1

编辑(添加 ifconfig、arp、netstat 和 ip Route 的输出)

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether cc:48:3a:66:a3:b3 brd ff:ff:ff:ff:ff:ff
    altname enp0s31f6
    inet6 fe80::91fe:23e9:430c:4c90/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:5d:96:04 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: wlp60s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 18:47:3d:31:82:dd brd ff:ff:ff:ff:ff:ff
    inet 192.168.29.146/24 brd 192.168.29.255 scope global dynamic noprefixroute wlp60s0
       valid_lft 40510sec preferred_lft 40510sec
    inet6 2405:201:d001:8b9b:6aa1:628a:c18a:852c/64 scope global temporary dynamic
       valid_lft 4186sec preferred_lft 4186sec
    inet6 2405:201:d001:8b9b:9fbf:f0f:d3d4:34f5/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 4186sec preferred_lft 4186sec
    inet6 fe80::8d6c:7a7c:f242:2c67/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:0c:f4:0a:c5 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
6: br-71e276fedf6f: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:93:94:0b:70 brd ff:ff:ff:ff:ff:ff
    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-71e276fedf6f
       valid_lft forever preferred_lft forever

$ ifconfig -a
br-71e276fedf6f: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255
        ether 02:42:93:94:0b:70  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:0c:f4:0a:c5  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether cc:48:3a:66:a3:b3  txqueuelen 1000  (Ethernet)
        RX packets 12827  bytes 1018633 (1.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3854  bytes 679852 (679.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xed700000-ed720000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 31692  bytes 4654677 (4.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 31692  bytes 4654677 (4.6 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:5d:96:04  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp60s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.29.146  netmask 255.255.255.0  broadcast 192.168.29.255
        inet6 fe80::8d6c:7a7c:f242:2c67  prefixlen 64  scopeid 0x20<link>
        inet6 2405:201:d001:8b9b:9fbf:f0f:d3d4:34f5  prefixlen 64  scopeid 0x0<global>
        inet6 2405:201:d001:8b9b:2e48:2aca:eaf7:f31b  prefixlen 64  scopeid 0x0<global>
        ether 18:47:3d:31:82:dd  txqueuelen 1000  (Ethernet)
        RX packets 7661151  bytes 11185482986 (11.1 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2146363  bytes 514484076 (514.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ arp -an
? (192.168.29.73) at 5c:e9:1e:9c:3a:b0 [ether] on wlp60s0
? (192.168.29.1) at a8:da:0c:c0:06:48 [ether] on wlp60s0

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.29.1    0.0.0.0         UG        0 0          0 wlp60s0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 virbr0
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 docker0
172.19.0.0      0.0.0.0         255.255.0.0     U         0 0          0 br-71e276fedf6f
192.168.29.0    0.0.0.0         255.255.255.0   U         0 0          0 wlp60s0
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0

$ ip route
default via 192.168.29.1 dev wlp60s0 proto dhcp metric 600
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.19.0.0/16 dev br-71e276fedf6f proto kernel scope link src 172.19.0.1 linkdown
192.168.29.0/24 dev wlp60s0 proto kernel scope link src 192.168.29.146 metric 600
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

方面则oip更为ip addr直接。在这里,我已经eth0静态设置了IP。 编辑(添加 ifconfig、arp、netstat 和 ip Route 的输出)

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
3: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
    link/can
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether a6:e6:68:9d:46:5f brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a4e6:68ff:fe9d:465f/64 scope link
       valid_lft forever preferred_lft forever

$ ifconfig -a
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:47

eth0      Link encap:Ethernet  HWaddr A6:E6:68:9D:46:5F
          inet addr:192.168.0.10  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a4e6:68ff:fe9d:465f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:77 errors:0 dropped:0 overruns:0 frame:0
          TX packets:692 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17852 (17.4 KiB)  TX bytes:54248 (52.9 KiB)
          Interrupt:48

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

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

$ arp -an
-sh: arp: command not found

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

$ ip route
default via 192.168.0.1 dev eth0 proto static
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.10

另外,SSH服务器通过命令检查,在设备上运行sudo systemctl status sshd。最终目标是调试为什么我无法ping或无法ssh访问设备。

答案1

192.168.0.10/24 已设置petalinux以太网0链接到奥伊普诺1,为了允许 oip 和 petalinux 之间的通信,请在奥伊普(作为用户,这意味着它可能应该以sudo) 开头:

ip addr add 192.168.0.11/24 dev eno1

就是这样:现在每个人都应该能够使用对方的 IP 地址访问对方:192.168.0.10 或 192.168.0.11(两者都在 192.168.0.0/24 内)。除了多余的信息(libvirt 和 Docker 也在运行)之外,我在这里没有看到任何奇怪的问题。

笔记:petalinux无法直接从 PC 访问(在评论)也不能通过奥伊普至少有两个原因:Ubuntu 的 Docker 将 filter/FORWARD 设置为 DROP,并且 PC 可能没有足够的路由到 192.168.0.0/24。但这不是问题的一部分。

相关内容