首页 > 编程知识 正文

环回地址有哪些,什么是环回地址

时间:2023-05-03 10:46:17 阅读:276108 作者:2463

     在配置OSPF路由协议的时候配置回环(loopback)接口是很重要的1件事.Cisco建议你配置OSPF的时候 顺便配置回环接口.所谓回环接口,是逻辑接口而非物理接口,即不是你触摸的到的router上的真正的接口.

    作用是作为诊断OSPF而用.如果router的某一个接口由于故障down 掉而不可用了,此时你怎么通过telnet来连接并进行管理用呢?所以就引入了回环接口是概念,回环接口永远不会down掉,你就可以通过连上回环接口来进行管理

Configuring Loopback Interfaces

    配置回环接口前先使用show ip ospf命令查看RID,接下来对接口进行配置,如下:

RouterA的配置:
RouterA(config)#int loopback0
RouterA(config-if)#ip address 172.16.10.1 255.255.255.0
RouterA(config-if)#no shut
RouterA(config-if)#^Z
RouterA#

RouterB的配置:
RouterB(config)#int lo0
RouterB(config-if)#ip address 172.16.20.1 255.255.255.0
RouterB(config-if)#no shut
RouterB(config-if)#^Z
RouterB#

RouterC的配置:
RouterC(config)#int lo0
RouterC(config-if)#ip address 172.16.30.1 255.255.255.0
RouterC(config-if)#no shut
RouterC(config-if)#^Z
RouterC#
    注意2个回环接口的IP地址配置机制为任意配置,但是IP地址必须处于不同的子网内

Verifying Loopbacks and RIDs

    验证回环接口的地址,可以使用show running-config的命令查看,如下:
RouterC#sh run
(略)
!
interface Loopback0
ip address 172.16.30.1 255.255.255.0
!
(略)

loopback 接口的用法

    此类接口是应用最为广泛的一种虚接口,几乎在每台路由器上都会使用。常见于如下用途

        1 作为一台路由器的管理地址;
            系统管理员完成网络规划之后,为了方便管理,会为每一台路由器创建一个 
            loopback 接口,并在该接口上单独指定一个IP 地址作为管理地址,管理员会 
            使用该地址对路由器远程登录(telnet ),该地址实际上起到了类似设备名称 
            一类的功能。 
            但是通常每台路由器上存在众多接口和地址,为何不从当中随便挑选一个呢? 
            原因如下:由于telnet 命令使用TCP 报文,会存在如下情况:路由器的某一个 
            接口由于故障down 掉了,但是其他的接口却仍旧可以telnet ,也就是说,到 
            达这台路由器的TCP 连接依旧存在。所以选择的telnet 地址必须是永远也不会 
            down 掉的,而虚接口恰好满足此类要求。由于此类接口没有与对端互联互通 
            的需求,所以为了节约地址资源,loopback 接口的地址通常指定为32 位掩码。

        2 使用该接口地址作为动态路由协议OSPF 、BGP 的router id;
            动态路由协议OSPF 、BGP 在运行过程中需要为该协议指定一个Router id ,作 
            为此路由器的唯一标识,并要求在整个自治系统内唯一。由于router id 是一个 
            32 位的无符号整数,这一点与IP 地址十分相像。而且IP 地址是不会出现重复 
            现象的,所以通常将路由器的router id 指定为与该设备上的某个接口的地址相 
            同。由于loopback 接口的IP 地址通常被视为路由器的标识,所以也就成了 
            router id 的最佳选择。
        3、使用该接口地址作为BGP 建立TCP 连接的源地址;
            在BGP 协议中,两个运行BGP 的路由器之间建立邻居关系是通过TCP 建立连 
            接完成的。 
            在配置邻居时通常指定loopback 接口为建立TCP 连接的源地址(通常只用于 
            IBGP ,原因同2.1 ,都是为了增强TCP 连接的健壮性)

配置命令如下:

router id 61.235.66.1 
interface loopback 0 
ip address 61.235.66.1 255.255.255.255 
router bgp 100 
neighbor 61.235.66.7 remote-as 200 
neighbor 61.235.66.7 update-source LoopBack0

RID

Router ID (RID) The Router ID (RID) is an IP address used to identify the router. Cisco
chooses the Router ID by using the highest IP address of all configured loopback interfaces.
If no loopback interfaces are configured with addresses, OSPF will choose the highest IP
address of all active physical interfaces.

Loopback interfaces are logical interfaces, which means they are not real
router interfaces. They can be used for diagnostic(.诊断的) purposes as well as OSPF configuration

在OSPF中为什么要用loopback interface:

if you are not using loopback interfaces then the serial interface of your router is the RID of the router because it has the highest IP address of active interfaces. If this interface goes down, then a re-election must occur on who is going to be the DR and BDR on the network. Not necessarily a big deal, but what happens if this is a flapping link (going up/down)? The routers will not converge because the election is never completed. This is obviously a problem with OSPF. Loopback interfaces solve this problem because they never go down and the RID of the router never changes

 

转载于:https://blog.51cto.com/7492110/1249033

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。