作为实验的一部分,我的网络具有以下拓扑结构,其中两台主机连接到 mininet 中的路由器(在 Ubuntu 22.04.02 虚拟机上)
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
我正在尝试设置实验拓扑,以便两个主机可以相互访问,这当然可以通过配置路由表来实现
我已采取以下步骤:
在r1 终端(xterm):
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 终端(xterm):
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 终端 (xterm)
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 终端 (xterm)
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、h2、r1 和 r2 的更新路由表如下:
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 路由表:
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 或反之时,出现目标主机不可达错误。
我哪里做错了?我是否跳过了某个步骤?任何见解/帮助都值得感激。
PS:以下是我的 ping 可达性矩阵:
*** Ping: testing ping reachability
r1 -> r2 h1 X
r2 -> r1 X X
h1 -> r1 r2 X
h2 -> r1 r2 X