路由循环怎么办?

路由循环怎么办?

大家好吗?我的情况是这样的,我在 GNS3 上安装了以下网络拓扑。

拓扑 GNS3

我还在每个点进行了以下设置。下面的配置与相同的拓扑有关,但之前使用的是 ubuntu 机器代替图像中存在的路由器。图像的这个拓扑结构是 OpenWRT15.05。想法是从 A 向 B 发送 ping,但当进入 R1 时,信号应该到达 R2,然后是 R3,再回到 R1 并继续按此顺序进行,从而形成一个循环。通过所有这些配置,我只设法让信号到达 R2,从那时起它就丢失了,我无法让它继续在网络中,经过 R3 并返回 R1 继续循环。如果您能帮助我或提供可以帮助我的想法和提示,我将不胜感激。目前的疑问是大学在网络方面的工作。

设置:

拓扑

A:0 => R1:0(A = 主机,0 = 接口,=> 已连接)

A:eth0.10 => R1:etht0.10 NET = 10.0.0.0 R1:eth1.12 => R2:eth1.12 NET = 192.168.12.0 B:eth0.20 => R2:eth0.20 NET = 172.16.0.0 R2:eht2.23 => R3:eth1.23 NET = 192.168.23.0 R3:eth0.13 => R1:eth2.13 NET = 192.168.13.0 配置 A

vconfig add eth0 10
ifconfig eth0.10 up
ifconfig eth0.10 10.0.0.1 netmask 255.255.255.0
route add default gw 10.0.0.2 dev eth0.10

vconfig add eth0 20
ifconfig eth0.20 up
ifconfig eth0.20 172.16.0.2 netmask 255.255.255.0
route add default gw 172.16.0.2 dev eth0.20

R1

ifconfig eth2 up
vconfig add eth0 10
ifconfig eth0.10 up
vconfig add eth1 12
ifconfig eth1.12 up
vconfig add eth2 13
ifconfig eth2.13 up

ifconfig eth0.10 10.0.0.2 netmask 255.255.255.0
ifconfig eth1.12 192.168.12.1 netmask 255.255.255.0
ifconfig eth2.13 192.168.13.1 netmask 255.255.255.0


route add default gw 192.168.12.2 dev eth1.12
echo 1 > /proc/sys/net/ipv4/ip_forward

R2

ifconfig eth2 up
vconfig add eth0 20
ifconfig eth0.20 up
vconfig add eth1 12
ifconfig eth1.12 up
vconfig add eth2 23
ifconfig eth2.23 up

ifconfig eth0.20 172.16.0.1 netmask 255.255.255.0
ifconfig eth1.12 192.168.12.2 netmask 255.255.255.0
ifconfig eth2.23 192.168.23.1 netmask 255.255.255.0

route add default gw 192.168.23.2 dev eth2.23
echo 1 > /proc/sys/net/ipv4/ip_forward

R3

vconfig add eth0 13
ifconfig eth0.13 up
vconfig add eth1 23
ifconfig eth1.23 up

ifconfig eth0.13 192.168.13.2 netmask 255.255.255.0
ifconfig eth1.23 192.168.23.2 netmask 255.255.255.0

route add default gw 192.168.13.2 dev eth0.13
echo 1 > /proc/sys/net/ipv4/ip_forward

*/etc/网络/接口

A

nano /etc/network/interfaces

iface eth0:10 inet static
    adress 10.0.0.1
    netmask 255.255.255.0
    broadcast 10.0.0.255
    network 10.0.0.0
    gateway 10.0.0.2

nano /etc/network/interfaces

iface eth0:20 inet static
    adress 172.16.0.2
    netmask 255.255.255.0
    broadcast 172.16.0.255
    network 172.16.0.0
    gateway 172.16.0.1

R1

iface eth0:10 inet static
    adress 10.0.0.2
    netmask 255.255.255.0
    broadcast 10.0.0.255
    network 10.0.0.0
    gateway 192.168.12.1

iface eth1:12 inet static
    adress 192.168.12.1
    netmask 255.255.255.0
    broadcast 192.168.12.255
    network 192.168.12.0
    gateway 192.168.12.2

iface eth2:13 inet static
    adress 192.168.13.1
    netmask 255.255.255.0
    broadcast 192.168.13.255
    network 192.168.13.0
    gateway 192.168.12.1

R2

iface eth0:20 inet static
    adress 172.16.0.1
    netmask 255.255.255.0
    broadcast 172.16.0.255
    network 172.16.0.0
    gateway 192.168.12.2

iface eth1:12 inet static
    adress 192.168.12.2
    netmask 255.255.255.0
    broadcast 192.168.12.255
    network 192.168.12.0
    gateway 192.168.23.1

iface eth2:23 inet static
    adress 192.168.23.1
    netmask 255.255.255.0
    broadcast 192.168.23.255
    network 192.168.23.0
    gateway 192.168.12.2

答案1

这里有几个问题。

我不知道这些是不是拼写错误或者其他什么。

首先,您显示计算机 B 配置,并显示您正在配置默认网关 172.16.0.2,但稍后在接口配置中显示 172.16.0.1。后者是正确的,前者不正确。

其次,在路由器 3 的配置中,您显示的默认网关是 192.168.13.2,该地址与路由器 3 上的一个接口的地址相同。相反,它应该是 192.168.13.1,即路由器 1 的接口。

第三,您需要从路由器接口中删除网关设置。他们错了。您不能在与接口自己的 IP 地址不在同一子网的接口上配置网关 IP 地址。这就是网关的全部意义 - 它是同一子网上的路由,具有子网的出路。路由器不使用,也不应该在接口上配置网关。相反,默认网关是此设置中唯一重要的东西。

第四,即使配置正确,您也不会通过从 A ping B 来创建循环。路由器 2 将计算机 B 的 IP 地址视为直接连接。因此,它不会使用默认网关。相反,它会将数据包直接发送到计算机 B。因此,您从 A 到 B 的 ping 将正常通过,不会产生循环。

如果要创建循环,则必须 ping 不属于拓扑中任何网络的 IP 地址。您可以从计算机 A 或 B 执行此操作。例如,ping 10.91.13.5。

如果您想确认自己处于循环状态,您将从其中一个路由器获得传输中已过期的 TTL。如果您更改 ping 上的 TTL,您将能够从 3 个路由器中的任何一个获得传输中已过期的 TTL。

话虽如此,您确实明白数据包不会无限循环,对吧?这就是 TTL 的用途。

目前的情况是,您从 A 发出的 ping 操作可以到达 B,但是没有有效的返回路径来回复。

继续学习,继续努力!

相关内容