You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mininet双路由器拓扑中主机h1与h2无法互通的问题排查求助

Mininet双路由器拓扑中主机h1与h2无法互通的问题排查求助

大家好,我在Ubuntu 22.04.02虚拟机的Mininet环境中做实验,搭建了如下网络拓扑:
h1 - r1 - r2 - h2

各节点初始网络配置

主机h1配置

h1-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.103  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::70e9:dfff:fe2c:6242  prefixlen 64  scopeid 0x20<link>
        ether 72:e9:df:2c:62:42  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 1076 (1.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 1076 (1.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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 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

主机h2配置

h2-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.2  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::f429:9fff:fe6a:5211  prefixlen 64  scopeid 0x20<link>
        ether f6:29:9f:6a:52:11  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 1076 (1.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 1076 (1.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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 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

路由器r1配置

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 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

r1-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.1  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::10dc:6cff:feb2:1688  prefixlen 64  scopeid 0x20<link>
        ether 12:dc:6c:b2:16:88  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 1076 (1.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 1076 (1.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

r1-eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.1  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::8cd5:99ff:fedf:e2a8  prefixlen 64  scopeid 0x20<link>
        ether 8e:d5:99:df:e2:a8  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 1076 (1.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15  bytes 1146 (1.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

路由器r2配置

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 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

r2-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::87d:6aff:fee9:477  prefixlen 64  scopeid 0x20<link>
        ether 0a:7d:6a:e9:04:77  txqueuelen 1000  (Ethernet)
        RX packets 21  bytes 1398 (1.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15  bytes 1146 (1.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

r2-eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.2  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::cc40:70ff:fe31:f96d  prefixlen 64  scopeid 0x20<link>
        ether ce:40:70:31:f9:6d  txqueuelen 1000  (Ethernet)
        RX packets 15  bytes 1146 (1.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15  bytes 1146 (1.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

已执行的路由配置步骤

为了让两台主机互通,我在各节点的xterm终端执行了以下命令:

路由器r1

ifconfig r1-eth0 192.168.0.1 netmask 255.255.255.0
ifconfig r1-eth1 192.168.2.1 netmask 255.255.255.0
ip route add 192.168.0.0/24 dev r1-eth0
ip route add 192.168.1.0/24 via 192.168.2.2

路由器r2

ifconfig r2-eth0 192.168.1.1 netmask 255.255.255.0
ifconfig r2-eth1 192.168.2.2 netmask 255.255.255.0
ip route add 192.168.0.0/24 via 192.168.2.1

主机h1

ifconfig h1-eth0 192.168.0.103 netmask 255.255.255.0
route add default gw 192.168.0.1
ip route add 192.168.1.0/24 via 192.168.0.1
ip route add 192.168.2.0/24 via 192.168.0.1

主机h2

ifconfig h2-eth0 192.168.1.2 netmask 255.255.255.0
route add default gw 192.168.1.1
ip route add 192.168.0.0/24 via 192.168.1.1
ip route add 192.168.2.0/24 via 192.168.1.1

各节点更新后的路由表

主机h1路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.0.1     0.0.0.0         UG    0      0        0 h1-eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 h1-eth0
192.168.1.0     192.168.0.1     255.255.255.0   UG    0      0        0 h1-eth0
192.168.2.0     192.168.0.1     255.255.255.0   UG    0      0        0 h1-eth0

主机h2路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 h2-eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 h2-eth0
192.168.2.0     192.168.1.1     255.255.255.0   UG    0      0        0 h2-eth0

路由器r1路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 r1-eth0
192.168.1.0     192.168.2.2     255.255.255.0   UG    0      0        0 r1-eth1
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 r1-eth1

路由器r2路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     192.168.2.1     255.255.255.0   UG    0      0        0 r2-eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 r2-eth0
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 r2-eth1

当前遇到的问题

我尝试从h1 ping h2,以及从h2 ping h1时,都收到了destination host unreachable的错误。

另外我的ping可达矩阵如下:

*** Ping: testing ping reachability
r1 -> r2 h1 X
r2 -> r1 X X
h1 -> r1 r2 X
h2 -> r1 r2 X

想请教下各位,我哪里配置错了?是不是漏掉了什么步骤?希望能得到大家的指点和帮助!

备注:内容来源于stack exchange,提问作者Toshitt Ahuja

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 15:59:49