我有两台 ubuntu 机器,每台都有两个物理网卡。我试图在其中两台机器之间创建一个私有网络,将一个节点的网卡与另一个节点的网卡连接起来。
在节点 1 中运行
是否配置
命令得到以下结果:
dpdk0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.9.10 netmask 255.255.255.0 broadcast 169.254.9.255
ether 54:b2:03:8c:ee:b0 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
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 129.241.200.185 netmask 255.255.255.0 broadcast 129.241.200.255
inet6 2001:700:300:2211:b98c:4988:f6f8:5ad0 prefixlen 64 scopeid 0x0<global>
inet6 2001:700:300:2211:9c8c:db02:7582:8d7e prefixlen 64 scopeid 0x0<global>
inet6 2001:700:300:2211:2423:1e11:c231:9132 prefixlen 64 scopeid 0x0<global>
inet6 2001:700:300:2211:9597:ef3:4f7f:cca7 prefixlen 64 scopeid 0x0<global>
inet6 2001:700:300:2211:e885:dcfc:9e47:e12d prefixlen 64 scopeid 0x0<global>
inet6 2001:700:300:2211:ad8a:cde9:c572:a371 prefixlen 64 scopeid 0x0<global>
inet6 fe80::103:3a80:c3f3:918c prefixlen 64 scopeid 0x20<link>
ether 54:b2:03:8c:ee:af txqueuelen 1000 (Ethernet)
RX packets 5290825 bytes 615071421 (615.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1200850 bytes 188144673 (188.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xdc100000-dc120000
当我在同一个节点运行时
ip 路由显示表本地
我得到了以下结果
broadcast 10.24.208.0 dev wlp6s0 proto kernel scope link src 10.24.210.207
local 10.24.210.207 dev wlp6s0 proto kernel scope host src 10.24.210.207
broadcast 10.24.211.255 dev wlp6s0 proto kernel scope link src 10.24.210.207
broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
broadcast 129.241.200.0 dev eno1 proto kernel scope link src 129.241.200.185
local 129.241.200.185 dev eno1 proto kernel scope host src 129.241.200.185
broadcast 129.241.200.255 dev eno1 proto kernel scope link src 129.241.200.185
broadcast 169.254.0.0 dev wlp6s0 proto kernel scope link src 169.254.8.1
local 169.254.8.1 dev wlp6s0 proto kernel scope host src 169.254.8.1
broadcast 169.254.9.0 dev dpdk0 proto kernel scope link src 169.254.9.10
local 169.254.9.10 dev dpdk0 proto kernel scope host src 169.254.9.10
broadcast 169.254.9.255 dev dpdk0 proto kernel scope link src 169.254.9.10
broadcast 169.254.255.255 dev wlp6s0 proto kernel scope link src 169.254.8.1
当我在同一个节点运行时
路线-n
我得到了以下结果
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 129.241.200.1 0.0.0.0 UG 100 0 0 eno1
0.0.0.0 10.24.208.1 0.0.0.0 UG 20600 0 0 wlp6s0
10.24.208.0 0.0.0.0 255.255.252.0 U 600 0 0 wlp6s0
10.24.210.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp6s0
129.241.200.0 0.0.0.0 255.255.255.0 U 100 0 0 eno1
当我在 Node 1 中运行命令时
iptables -t nat -L
我得到了以下结果
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
现在,当我在 Node 2 中运行相同的命令时,我得到了以下结果:
ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 129.241.200.232 netmask 255.255.255.0 broadcast 129.241.200.255
inet6 2001:700:300:2211:56b2:3ff:fe8c:f363 prefixlen 64 scopeid 0x0<global>
inet6 fe80::56b2:3ff:fe8c:f363 prefixlen 64 scopeid 0x20<link>
ether 54:b2:03:8c:f3:63 txqueuelen 1000 (Ethernet)
RX packets 4229811 bytes 389612925 (389.6 MB)
RX errors 0 dropped 2278 overruns 0 frame 0
TX packets 11968 bytes 1677329 (1.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xdc100000-dc120000
enp5s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.9.9 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::56b2:3ff:fe8c:f364 prefixlen 64 scopeid 0x20<link>
ether 54:b2:03:8c:f3:64 txqueuelen 1000 (Ethernet)
RX packets 5649 bytes 1340080 (1.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 522 bytes 42061 (42.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xdc000000-dc01ffff
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
ip route show table local
broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
broadcast 129.241.200.0 dev eno1 proto kernel scope link src 129.241.200.232
local 129.241.200.232 dev eno1 proto kernel scope host src 129.241.200.232
broadcast 129.241.200.255 dev eno1 proto kernel scope link src 129.241.200.232
broadcast 169.254.0.0 dev enp5s0 proto kernel scope link src 169.254.9.9
local 169.254.9.9 dev enp5s0 proto kernel scope host src 169.254.9.9
broadcast 169.254.255.255 dev enp5s0 proto kernel scope link src 169.254.9.9
sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
129.241.200.0 0.0.0.0 255.255.255.0 U 0 0 0 eno1
iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
现在,当我尝试从节点 1 执行 ping 操作时enp5s0接口 169.254.9.9 没有收到任何数据包,当我尝试从节点 2 dpdk 接口 ping 时dpdk0IP 地址为 169.254.9.10,我收到输出:网络不可达。
请注意,在我的两个节点上,我都使用以下命令启用了数据包转发:
sudo sysctl -w net.ipv4.ip_forward=1
我将非常感激任何有关我做错事情的提示。我猜根据 ARP 表判断,这些接口根本不存在条目,但我不知道如何在路由表中设置这些条目,以便能够在两个节点之间进行 ping 操作。