1. 环回接口的作用

  • 模拟路由器的任意 IP 地址(常用于测试、作为 Router-ID、OSPF/ BGP 等的稳定标识)
  • 永远处于 up 状态(只要路由器运行,环回接口就在线)
  • 可用于验证路由连通性

2. 配置思路

  1. 创建环回接口并配置 IP 地址
  2. 配置静态路由或动态路由(让其他路由器知道这个环回 IP)
  3. 测试连通性

3. 基本配置步骤(以两台路由器 R1、R2 为例)

R1 配置

# 进入系统视图system-view# 创建环回接口interface LoopBack 0 ip address 1.1.1.1 255.255.255.255 quit# 配置直连口 IPinterface GigabitEthernet 0/0/0 ip address 192.168.12.1 255.255.255.0 quit# 添加到 R2 的静态路由(告诉 R1 如何到达 R2 的环回)ip route-static 2.2.2.2 255.255.255.255 192.168.12.2php270 Bytes© 菜鸟-创作你的创作

R2 配置

system-view# 创建环回接口interface LoopBack 0 ip address 2.2.2.2 255.255.255.255 quit# 配置直连口 IPinterface GigabitEthernet 0/0/0 ip address 192.168.12.2 255.255.255.0 quit# 添加到 R1 的静态路由ip route-static 1.1.1.1 255.255.255.255 192.168.12.1php242 Bytes© 菜鸟-创作你的创作

4. 测试

ping 2.2.2.2   # 在 R1 上测试ping 1.1.1.1   # 在 R2 上测试php51 Bytes© 菜鸟-创作你的创作

如果能 ping 通,说明环回路由已经配置成功。


5. 在动态路由中发布环回

以 OSPF 为例:

ospf 1 area 0  network 1.1.1.1 0.0.0.0  network 192.168.12.0 0.0.0.255php73 Bytes© 菜鸟-创作你的创作

这样,环回接口的 IP 会自动通告到其他路由器。

https://www.52runoob.com/archives/5690