掌握OSPF路由重发布中修改路由度量
通过配置OSPF路由重发布修改路由度量,可以将指定路径的优先次序升高或降低。
Ruijie>enable
Ruijie#configure terminal
Ruijie(config)#hostname R1
R1(config)#interface gigabitEthernet 0/1
R1(config-if-GigabitEthernet 0/1)#no switchport
R1(config-if-GigabitEthernet 0/1)#ip address 192.168.2.1 255.255.255.0
R1(config-if-GigabitEthernet 0/1)#exit
R1(config)#interface gigabitEthernet 0/0
R1(config-if-GigabitEthernet 0/0)#no switchport
R1(config-if-GigabitEthernet 0/0)#ip address 192.168.1.1 255.255.255.0
R1(config-if-GigabitEthernet 0/0)#exit
Ruijie>enable
Ruijie#configure terminal
Ruijie(config)#hostname R2
R2(config)#interface gigabitEthernet 0/1
R2(config-if-GigabitEthernet 0/1)#no switchport
R2(config-if-GigabitEthernet 0/1)#ip address 192.168.1.2 255.255.255.0
R2(config-if-GigabitEthernet 0/1)#exit
R2(config)#interface gigabitEthernet 0/0
R2(config-if-GigabitEthernet 0/0)#no switchport
R2(config-if-GigabitEthernet 0/0)#ip address 192.168.3.1 255.255.255.0
R2(config-if-GigabitEthernet 0/0)#exit
Ruijie>enable
Ruijie#configure terminal
Ruijie(config)#hostname SW-1
SW-1(config)#interface fastEthernet 0/1
SW-1(config-if-FastEthernet 0/1)#no switchport
SW-1(config-if-FastEthernet 0/1)#ip address 192.168.2.2 255.255.255.0
SW-1(config-if-FastEthernet 0/1)#exit
SW-1(config)#interface vlan 1
SW-1(config-if-VLAN 1)#ip address 10.1.1.254 255.255.255.0
SW-1(config-if-VLAN 1)#exit
R1(config)#router ospf 1
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 192.168.2.0 0.0.0.255 area 0
R1(config-router)#exit
R2(config)#route ospf 1
R2(config-router)#network 192.168.1.0 0.0.0.255 area 0
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0
R2(config-router)#exit
R1(config)#ip route 10.1.1.0 255.255.255.0 192.168.2.2
SW-1(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.1
R1(config)#route ospf 1
R1(config-router)#redistribute static subnets
R1(config-router)#exit
在R2上查看是否学习到了重分布的静态路由
R1(config)#router ospf 1
R1(config-router)#redistribute static metric 50
R1(config-router)#exit
在R2上查看路由表,若去往SW-1的路由度量值变为50,则说明配置正确