Cisco 交换机堆栈上最后的网关

网络工程 思科 路由 转变
2021-07-12 22:32:26

当我在 Cisco 3850 交换机堆栈上运行 show ip route 时,我得到以下输出

PO-SW-SVR-SS-02(config)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is 10.20.25.254 to network 0.0.0.0

S*    0.0.0.0/0 [254/0] via 10.20.25.254
      10.0.0.0/8 is variably subnetted, 31 subnets, 3 masks
S        10.0.0.0/8 [1/0] via 10.6.9.0
C        10.6.9.0/24 is directly connected, Vlan2
L        10.6.9.6/32 is directly connected, Vlan2
C        10.6.10.0/24 is directly connected, Vlan10
L        10.6.10.254/32 is directly connected, Vlan10
C        10.6.11.0/24 is directly connected, Vlan11
L        10.6.11.254/32 is directly connected, Vlan11
C        10.6.12.0/24 is directly connected, Vlan12
L        10.6.12.254/32 is directly connected, Vlan12
C        10.6.13.0/24 is directly connected, Vlan13
L        10.6.13.254/32 is directly connected, Vlan13
C        10.6.14.0/24 is directly connected, Vlan14
L        10.6.14.254/32 is directly connected, Vlan14
C        10.6.15.0/24 is directly connected, Vlan15
L        10.6.15.254/32 is directly connected, Vlan15
C        10.6.16.0/24 is directly connected, Vlan16
L        10.6.16.254/32 is directly connected, Vlan16
C        10.6.101.0/24 is directly connected, Vlan101
L        10.6.101.254/32 is directly connected, Vlan101
C        10.6.102.0/24 is directly connected, Vlan102
L        10.6.102.254/32 is directly connected, Vlan102
C        10.6.103.0/24 is directly connected, Vlan103
L        10.6.103.254/32 is directly connected, Vlan103
C        10.6.104.0/24 is directly connected, Vlan104
L        10.6.104.254/32 is directly connected, Vlan104
C        10.6.200.0/24 is directly connected, Vlan200
L        10.6.200.254/32 is directly connected, Vlan200
C        10.20.25.0/24 is directly connected, Vlan25
L        10.20.25.172/32 is directly connected, Vlan25
C        10.50.1.0/24 is directly connected, Vlan50
L        10.50.1.253/32 is directly connected, Vlan50

但是,我不希望我的最后网关设置10.20.25.254为 network 0.0.0.0

我需要这个交换机堆栈的网关指向的网络是10.6.9.10这样它就可以连接到 Internet。我尝试10.6.9.10使用以下命令将最后的网关设置为

ip default-gateway 10.6.9.10
ip default-network 10.6.9.0

但是,万不得已的门户不知何故还是显示出来10.20.25.254了。我猜我错过了一些东西。谁能指出我正确的方向,让我的交换机堆栈指向10.6.9.10我不确定网关10.20.25.254最初是如何设置的:\ 我10.20.25.254在整个配置中没有看到对任何地方的引用

作为旁注,VLAN2 ( 10.6.9.0/24) 是我的本地 VLAN,并且此交换机堆栈中继到具有10.6.9.10地址的交换机堆栈话虽如此,既然设备是直接连接的,而且两个交换机堆栈在 VLAN2 中都有一个接口,这是否有必要?

2个回答

在不知道交换机型号或代码版本的情况下,根据您提供的路由表输出,您的交换机很可能在 L3 模式下运行(即已ip routing在配置中启用)。

ip default-gateway命令仅由 L2 交换机使用,在 L3 模式下被交换机完全忽略。如果要使用该ip default-gateway命令并在 L2 模式下运行交换机,则需要配置no ip routing.

在L3模式的交换机上,需要在配置中创建静态路由,比如ip route 0.0.0.0 0.0.0.0 10.6.9.10插入路由表。

根据您的路由表,您已经配置了静态路由。您可能还需要使用no ip route 0.0.0.0 0.0.0.0 10.20.25.254命令删除它

正如 YLearn 所指出的,您需要确定交换机是严格按照第 2 层交换机的方式运行,还是实际上是路由(第 3 层)。如果是路由,那么就不要使用default-gatewayordefault-network命令了。

不应该ip default-gateway在充当路由器的路由器上使用这些命令,该ip default-network命令实际上是针对 IGRP 的,它不理解默认路由;您可以使用静态默认路由。

Cisco 有一份解释差异的文档:使用 IP 命令配置最后的网关

概括

在 Cisco 路由器上禁用ip 路由时,请使用ip default-gateway命令使用ip default-networkip route 0.0.0.0 0.0.0.0命令在启用了ip 路由的Cisco 路由器上设置最后的网关路由协议传播默认路由信息的方式因协议而异。


您还说10.6.9.10要用于网关地址是另一个交换机。您需要确保该地址确实是该网络的网关。不要将第 2 层 LAN 与第 3 层路由混淆。您用作网关的地址需要是知道如何到达其他网络的路由器(或第 3 层交换机)。

您应该编辑您的问题,以包含关于您的网络连接方式和完整交换机配置的良好描述(图表会很棒)。这将有助于我们为您提供更具体的答案。