逻辑上Router和它的loopback接口有什么关系?

网络工程 路由器 ip IP地址 界面 环回
2022-03-02 03:48:53

我有一个带有环回 0 的 Router1 连接到 Router2:

界面简介如下:

Router1>show ip interface brief 
Interface              IP-Address      OK? Method Status                Protocol 
GigabitEthernet0/0/0   10.0.12.1       YES manual up                    up 
GigabitEthernet0/0/1   unassigned      YES unset  administratively down down 
Loopback0              1.1.1.1         YES manual up                    up 
Vlan1                  unassigned      YES unset  administratively down down

ip路由如下:

Router1#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, E - EGP
       i - IS-IS, 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

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1/32 is directly connected, Loopback0
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       10.0.12.0/24 is directly connected, GigabitEthernet0/0/0
L       10.0.12.1/32 is directly connected, GigabitEthernet0/0/0

我有一个问题,Router1和它的loopback0的逻辑关系是什么?

如果我们把 loopback0 看成它的一个逻辑路由器接口,route 1.1.1.1/32应该是L,因为 Gig0/0/0 的 ip 是L

如果我们把loopback0看作一个独立的Server(因为它的关系是connected),它应该有东西连接loopback0,对吧?

1个回答

环回接口是被视为直接连接接口的虚拟接口。您的Loopback0接口是使用/32网络定义的,根据定义,该网络是本地路由。当您显示路线时,您看到它的方式/32就是报告的方式。如果您使用更长的掩码对其进行寻址,您还将获得一条Local 路由(/32地址)。

您的GigabitEthernet0/0/0接口是直接连接到10.0.12.0/24网络的物理接口,其L在该网络上的本地地址是10.0.12.1.

我对此进行了测试。

首先,/32在环回上有一个网络:

Router1(config)#int lo12345
Router1(config-if)#ip address 10.11.12.13 255.255.255.255
Router1(config-if)#do sh ip int br                       
Interface                  IP-Address      OK? Method Status                Protocol
  ...
Loopback12345              10.11.12.13     YES manual up                    up      
  ...
DFW-Router1(config-if)#do sh 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
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is x.x.x.x to network 0.0.0.0

  ...
      10.0.0.0/32 is subnetted, 1 subnets
C        10.11.12.13 is directly connected, Loopback12345
  ...

接下来,使用/24环回网络:

Router1(config-if)#ip address 10.11.12.13 255.255.255.0
Router1(config-if)#do sh ip int br
  ...
Loopback12345              10.11.12.13     YES manual up                    up      
  ...
Router1(config-if)#do sh 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
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is x.x.x.x to network 0.0.0.0

  ...
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.11.12.0/24 is directly connected, Loopback12345
L        10.11.12.13/32 is directly connected, Loopback12345
  ...

似乎如果接口地址网络地址,则您不会L在该网络的路由表中获得独立的本地地址。