我有一个Art-Net 设备和两台笔记本电脑,一台运行 Ubuntu 21.04 的联想 x270 和一台运行 Ubuntu 20.04 的联想 T14。为了连接到 Art-Net 设备,我使用笔记本电脑上的以太网适配器,并将其直接连接到设备。
2.0.0.5
对于我使用的笔记本电脑,设备地址是2.0.0.4
,因此我按如下方式配置以太网适配器:
sudo ifconfig enxd03745229ac8 2.0.0.4 netmask 255.0.0.0 up
sudo route add -host 2.0.0.5 gw 2.0.0.4 dev enxd03745229ac8
之后,我可以从 x270 ping 通 Art-Net 设备,但不能从 T14 笔记本电脑 ping 通。
这是为什么?在 T14 上,还有其他地方可以将包裹路由到其他地方吗?
ifconfig/route 输出
x270
user@user-ThinkPad-X270 ~/m/Artnet (master)> ifconfig enxd03745229ac8
enxd03745229ac8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 2.0.0.4 netmask 255.255.255.0 broadcast 2.0.0.255
ether d0:37:45:22:9a:c8 txqueuelen 1000 (Ethernet)
RX packets 1 bytes 46 (46.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 592 bytes 247929 (247.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
user@user-ThinkPad-X270 ~/m/Artnet (master)> 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 600 0 0 wlp3s0
2.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enxd03745229ac8
2.0.0.5 2.0.0.4 255.255.255.255 UGH 0 0 0 enxd03745229ac8
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlp3s0
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp3s0
> ping 2.0.0.5
PING 2.0.0.5 (2.0.0.5) 56(84) bytes of data.
64 bytes from 2.0.0.5: icmp_seq=1 ttl=255 time=1.36 ms
64 bytes from 2.0.0.5: icmp_seq=2 ttl=255 time=3.94 ms
^C
--- 2.0.0.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 1.364/2.652/3.940/1.288 ms
T14
simon@simon-t14 /d/w/m/m/Artnet (master)> ifconfig enxd03745229ac8
enxd03745229ac8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 2.0.0.4 netmask 255.0.0.0 broadcast 2.255.255.255
ether d0:37:45:22:9a:c8 txqueuelen 1000 (Ethernet)
RX packets 5 bytes 382 (382.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 300 bytes 187644 (187.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
simon@simon-t14 /d/w/m/m/Artnet (master)> 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 600 0 0 wlp3s0
2.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 enxd03745229ac8
4.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 enp5s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enxd03745229ac8
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp3s0
simon@simon-t14 /d/w/m/m/Artnet (master)> ping 2.0.0.5
PING 2.0.0.5 (2.0.0.5) 56(84) bytes of data.
^C
--- 2.0.0.5 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2051ms
答案1
不要对两台笔记本电脑使用相同的 IP 地址。对不同的设备使用相同的 IP 地址永远是不好的。将 T14 的 IP 地址设置为 2.0.0.6 就可以了。
我还避免使用子网开始和结束的前 5 个地址,以避免网关和其他网络设备出现重复 IP 问题。