目录
一、loopback接口的基本概念
loopback接口的特点:
1、loopback接口创建后将一直保持UP状态,并具有环回特性;
2、loopback接口可以配置掩码为全1的IP地址;
二、loopback接口的应用
1、在远程登录中的应用
为了标识和管理网络设备(路由器、交换机等)通常会配置一个IP地址用于远程连接;
i. 配置远程连接的IP地址的方式
在物理端口中配置IP地址:如果物理端口出现故障,将导致无法使用该IP地址管理网络设备;
在vlan中配置IP地址:vlan必须关联一个或多个物理端口,vlan端口才能up起来;在实际应用中,核心层的交换机通常只
关联一个端口,如果该端口down,那么导致vlan端口down,也就无法使用该vlan端口的IP地址来管
理网络设备;
在loopback接口配置IP地址:loopback接口只要设备正常运行或者不手动shutdown,那么loopback接口永处于up状态;所以
用于标识或管理网络设备是最佳选择;
ii. 在loopback口中配置IP地址来管理网络设备
示例拓扑图:
需求:
1、配置SW1的loopback口IP地址,并开启ssh;
2、使用静态路由配置pc到SW1的loopback口的互通,SW3 - SW1和SW3 - SW2 - SW1两条路径;
3、在PC机中,通过ssh连接上SW1的loopback口的IP地址;
4、模拟PC到SW1两条链路中的一条链路出现故障(两条模拟,看是否达到预期效果);
配置:
1、配置SW1交换机
配置ssh stelnet server enable ssh user admin ssh user admin authentication-type all ssh user admin service-type stelnet user-interface vty 0 4 authentication-mode aaa protocol inbound ssh aaa local-user admin password cipher 123456 local-user admin privilege level 15 local-user admin service-type ssh 配置网络的互通 vlan batch 10 20 stp disable interface Vlanif10 ip address 192.168.1.1 255.255.255.252 interface Vlanif20 ip address 192.168.2.1 255.255.255.252 interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 10 interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 20 ip route-static 192.168.56.0 255.255.255.0 192.168.2.2 ip route-static 192.168.56.0 255.255.255.0 192.168.1.2 配置loopback口 interface LoopBack10 ip address 10.10.10.1 255.255.255.255 |
2、配置SW2交换机
vlan batch 10 30 interface Vlanif10 ip address 192.168.1.2 255.255.255.252 interface Vlanif30 ip address 192.168.3.1 255.255.255.252 interface MEth0/0/1 interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 10 interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 30 ip route-static 10.10.10.1 255.255.255.255 192.168.1.1 ip route-static 192.168.56.0 255.255.255.0 192.168.3.2 |
3、配置SW3交换机
vlan batch 20 30 40 interface Vlanif20 ip route-static 10.10.10.1 255.255.255.255 192.168.2.1 |
2、用于作为OSPF、BGP的Router ID
在默认情况下,BGP会自动选取全局Router ID作为BGP协议的Router ID。如果选中的Router ID是物理接口的IP地址,当IP地址发生变化时,会引起路由的振荡。为了提高网络的稳定性,可以将Router ID手动配置为Loopback接口地址。