五、验证配置结果
# 检查Device A上使用show ip ospf database能学习到区域2的路由。
Device A# show ip ospf database
OSPF Router with ID (192.168.12.1) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
192.168.12.1 192.168.12.1 1025 0x80000002 0x00292E 1
192.168.12.2 192.168.12.2 3 0x80000004 0x00DA5E 2
192.168.23.3 192.168.23.3 7 (DNA) 0x80000001 0x001328 0
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.12.2 192.168.12.2 1031 0x80000001 0x00CE8E
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.23.0 192.168.12.2 820 0x80000001 0x0077CC
192.168.23.0 192.168.23.3 7 (DNA) 0x80000001 0x002414
192.168.34.0 192.168.23.3 7 (DNA) 0x80000001 0x00AA82
# OSPF基础配置。
P1(config)# router ospf 1
P1(config-router)# network 172.168.40.0 0.0.0.255 area 0
P1(config-router)# network 172.168.10.0 0.0.0.255 area 0
P1(config-router)# network 172.168.0.3 0.0.0.0 area 0
P1(config-router)# exit
# 在P1上配置骨干网MPLS信令,打开接口MPLS能力。
P1(config)# interface gigabitethernet 1/0
P1(config-GigabitEthernet 1/0)# ip address 172.168.10.2 255.255.255.0
P1(config-GigabitEthernet 1/0)# mpls ip
P1(config-GigabitEthernet 1/0)# label-switch
P1(config-GigabitEthernet 1/0)# exit
P1(config)# interface gigabitethernet 1/1
P1(config-GigabitEthernet 1/1)# ip address 172.168.40.1 255.255.255.0
P1(config-GigabitEthernet 1/1)# mpls ip
P1(config-GigabitEthernet 1/1)# label-switch
P1(config-GigabitEthernet 1/1)# exit
P1(config)# mpls ip
P1(config)# mpls router ldp
PE2(config-mpls-router)# ldp router-id interface loopback 0 force
PE2(config-mpls-router)# exit
五、验证配置结果
(1) PE1的配置验证。
# 检查PE1上存在OSPF伪链路路由。
PE1# show ip ospf 10 sham-links
Sham Link SLINK0 to address 192.168.0.2 is up
Area 0.0.0.0 source address 192.168.0.1, Cost: 1
Output interface is GigabitEthernet 1/1
Nexthop address 172.16.40.2
Transmit Delay is 1 sec, State Point-To-Point,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:01
Adjacency state Full
# 检查PE1的OSPF邻居。
PE1# show ip ospf 10 neighbor
OSPF process 10, 1 Neighbors, 1 is Full:
Neighbor ID Pri State BFD State Dead Time Address Interface
192.168.0.2 1 Full/ – – 00:00:34 192.168.0.2 SLINK0
# 检查PE1 VRF路由。
PE1# show ip route vrf VPNA
Routing Table: VPNA
Codes: C – connected, S – static, R – RIP, B – BGP
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
Gateway of last resort is no set
C 192.168.10.0/24 is directly connected, GigabitEthernet 1/2
O 192.168.20.0/24 [110/101] via 192.168.1.2, 00:56:23, GigabitEthernet 1/2
O 192.168.30.0/24 [110/2] via 172.168.0.2, 00:00:36
O 192.168.40.0/24 [110/2] via 172.168.0.2, 00:00:36
(2) PE2的配置验证。
# 检查PE1上存在OSPF 伪链路路由。
PE2# show ip ospf 10 sham-links
Sham Link SLINK0 to address 192.168.0.1 is up
Area 0.0.0.0 source address 192.168.0.2, Cost: 1
Output interface is GigabitEthernet 1/1
Nexthop address 172.16.10.1
Transmit Delay is 1 sec, State Point-To-Point,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:01
Adjacency state Full
# 检查PE2的OSPF邻居。
PE2# show ip ospf 10 neighbor
OSPF process 10, 1 Neighbors, 1 is Full:
Neighbor ID Pri State BFD State Dead Time Address Interface
192.168.0.1 1 Full/ – – 00:00:34 192.168.0.1 SLINK0
# 检查PE2 VRF路由。
PE2# show ip route vrf VPNA
Routing Table: VPNA
Codes: C – connected, S – static, R – RIP, B – BGP
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
Gateway of last resort is no set
O 192.168.10.0/24 [110/2] via 172.168.0.1, 00:00:36
O 192.168.20.0/24 [110/2] via 172.168.0.1, 00:00:36
C 192.168.30.0/24 is directly connected, GigabitEthernet 1/2
O 192.168.40.0/24 [110/101] via 192.168.30.2, 00:56:23, GigabitEthernet 1/2
六、 配置文件 ● SITEA的配置文件。
!
interface gigabitethernet 1/0
ip address 192.168.10.2 255.255.255.0
ip ospf cost 1
!
interface gigabitethernet 1/1
ip address 192.168.20.1 255.255.255.0
ip ospf cost 200
!
router ospf 10
network 192.168.10.0 255.255.255.0 area 0
network 192.168.20.0 255.255.255.0 area 0
!
●SITEB的配置文件。
!
interface gigabitethernet 1/0
ip address 192.168.30.2 255.255.255.0
ip ospf cost 1
!
interface gigabitethernet 1/1
ip address 192.168.20.2 255.255.255.0
ip ospf cost 200
!
router ospf 10
network 192.168.30.0 255.255.255.0 area 0
network 192.168.20.0 255.255.255.0 area 0
!
● PE1的配置文件。
!
ip vrf VPNA
rd 1:100
route-target both 1:100
!
interface gigabitethernet 1/1
ip address 172.168.10.1 255.255.255.0
label-switching
mpls ip
!
interface gigabitethernet 1/2
ip vrf forwarding VPNA
ip address 192.168.10.1 255.255.255.0
interface loopback 0
ip address 172.168.0.1 255.255.255.255
!
interface loopback 10
ip vrf forwarding VPNA
ip address 192.168.0.1 255.255.255.255
!
router bgp 1
neighbor 172.168.0.2 remote-as 1
neighbor 172.168.0.2 update-source loopback 0
address-family vpnv4
neighbor 172.168.0.2 activate
address-family ipv4 vrf VPNA
redistribute ospf 10
redistribute connected
!
router ospf 1
network 172.168.10.0 0.0.0.255 area 0
network 172.168.0.1 0.0.0.0 area 0
!
router ospf 10 vrf VPNA
network 192.168.10.0 255.255.255.0 area 0
redistribute bgp subnets
area 0 sham-link 192.168.0.1 192.168.0.2
!
mpls ip
mpls router ldp
ldp router-id interface loopback 0 force
!
●PE2的配置文件。
!
ip vrf VPNA
rd 1:100
route-target both 1:100
!
interface gigabitethernet 1/1
ip address 172.168.40.2 255.255.255.0
label-switching
mpls ip
!
interface gigabitethernet 1/2
ip vrf forwarding VPNA
ip address 192.168.30.1 255.255.255.0
!
interface loopback 0
ip address 172.168.0.2 255.255.255.255
!
interface loopback 10
ip vrf forwarding VPNA
ip address 192.168.0.2 255.255.255.255
!
router bgp 1
neighbor 172.168.0.1 remote-as 1
neighbor 172.168.0.1 update-source loopback 0
address-family vpnv4
neighbor 172.168.0.1 activate
address-family ipv4 vrf VPNA
redistribute ospf 10
redistribute connected
!
router ospf 1
network 172.168.40.0 0.0.0.255 area 0
network 172.168.0.2 0.0.0.0 area 0
!
router ospf 10 vrf VPNA
network 192.168.30.0 255.255.255.0 area 0
redistribute bgp subnets
area 0 sham-link 192.168.0.2 192.168.0.1
!
mpls ip
mpls router ldp
ldp router-id interface loopback 0 force
!
●P1的配置文件。
!
interface gigabitethernet 1/0
ip address 172.168.10.2 255.255.255.0
mpls ip
label-switch
!
interface gigabitethernet 1/1
ip address 172.168.40.1 255.255.255.0
mpls ip
label-switch
!
interface loopback 0
ip address 172.168.0.3 255.255.255.255
!
router ospf 1
network 172.168.40.0 0.0.0.255 area 0
network 172.168.10.0 0.0.0.255 area 0
network 172.168.0.3 0.0.0.0 area 0
!
mpls ip
mpls router ldp
ldp router-id interface loopback 0 force
!
五、验证配置结果
# 检查Device A路由表,192.168.4.0/24表项存在备份路由。
Device A# show ip route fast-reroute | begin 192.168.4.0
O 192.168.4.0/24 [ma] via 192.168.1.2, 00:39:28, GigabitEthernet 0/1
[b] via 192.168.2.2, 00:39:28, GigabitEthernet 0/2
五、验证配置结果
# 检查Device A上查看OSPF联动BFD处于UP状态。
Device A# show ip ospf neighbor
OSPF process 1, 1 Neighbors, 1 is Full:
Neighbor ID Pri State BFD State Dead Time Address Interface
192.168.1.2 1 Full/BDR Up 00:00:40 192.168.1.2 GigabitEthernet 0/1
192.168.13.3 1 Full/BDR Up 00:00:40 192.168.13.3 GigabitEthernet 0/2
# 检查Device B上查看OSPF联动BFD处于UP状态。
Device B# show ip ospf neighbor
OSPF process 1, 1 Neighbors, 1 is Full:
Neighbor ID Pri State BFD State Dead Time Address Interface
192.168.1.1 1 Full/BDR Up 00:00:40 192.168.1.1 GigabitEthernet 0/1
192.168.13.3 1 Full/BDR Up 00:00:40 192.168.23.3
# Device C的配置。
Device C(config)# router rip
Device C(config-router)# version 2
Device C(config-router)# no auto-summary
Device C(config-router)# network 0.0.0.0 255.255.255.255
Device C(config-router)# passive-interface default
Device C(config-router)# no passive-interface gigabitethernet 0/1
五、验证配置结果
# 检查A、B和C上的IP路由表,应看到RIP学到了远端网络的路由。
●Device A
Device A# show ip route
Codes: C – connected, S – static, R – RIP, B – BGP
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
Gateway of last resort is no set
C 110.11.2.0/24 is directly connected, GigabitEthernet 0/1
C 110.11.2.1/32 is local host.
R 117.0.0.0/8 [120/1] via 110.11.2.2, 00:00:47, GigabitEthernet 0/1
C 155.10.1.0/24 is directly connected, GigabitEthernet 0/2
C 155.10.1.1/32 is local host.
C 192.168.217.0/24 is directly connected, VLAN 1
C 192.168.217.233/32 is local host.
R 196.38.165.0/24 [120/1] via 110.11.2.3, 00:19:18, GigabitEthernet 0/1
●Device B
Device B# show ip route
Codes: C – connected, S – static, R – RIP, B – BGP
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
Gateway of last resort is no set
C 110.11.2.0/24 is directly connected, GigabitEthernet 0/1
C 110.11.2.2/32 is local host.
R 155.10.0.0/16 [120/1] via 110.11.2.1, 00:15:21, GigabitEthernet 0/1
C 196.38.165.0/24 is directly connected, GigabitEthernet 0/2
C 196.38.165.1/32 is local host.
R 117.0.0.0/8 [120/1] via 110.11.2.2, 00:00:47, GigabitEthernet 0/1
●Device C
Device C# show ip route
Codes: C – connected, S – static, R – RIP, B – BGP
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
Gateway of last resort is no set
C 110.11.2.0/24 is directly connected, GigabitEthernet 0/1
C 110.11.2.3/32 is local host.
C 117.102.0.0/16 is directly connected, GigabitEthernet 0/2
C 117.102.0.1/32 is local host.
R 155.10.0.0/16 [120/1] via 110.11.2.1, 00:20:55, GigabitEthernet 0/1
R 196.38.165.0/24 [120/1] via 110.11.2.3, 00:19:18, GigabitEthernet 0/1
六、配置文件
● 设备A的配置文件。
!
interface gigabitethernet 0/1
no switchport
ip address 110.11.2.1 255.255.255.0
!
interface gigabitethernet 0/2
no switchport
ip address 155.10.1.1 255.255.255.0
!
router rip
version 2
passive-interface default
no passive-interface gigabitethernet 0/1
network 0.0.0.0
!
●设备B的配置文件。
!
interface gigabitethernet 0/1
no switchport
ip address 110.11.2.2 255.255.255.0
!
interface gigabitethernet 0/2
no switchport
ip address 196.38.165.1 255.255.255.0
!
router rip
version 2
passive-interface default
no passive-interface gigabitethernet 0/1
network 0.0.0.0
!
● 设备C的配置文件。
!
interface gigabitethernet 0/1
no switchport
ip address 110.11.2.3 255.255.255.0
!
interface gigabitethernet 0/2
no switchport
ip address 117.102.0.1 255.255.255.0
!
router rip
version 2
no auto-summary
passive-interface default
no passive-interface gigabitethernet 0/1
network 0.0.0.0
! 七、常见错误
●接口上未配置IPv4地址。
● 某台设备上没有定义RIP版本,或RIP版本号与其他设备不一致。
● network命令配置的地址范围未覆盖某接口。
● network命令参数IP地址比较比特位配置错误。0表示精确匹配,1表不做比较。
● 设备互联接口被设置为被动接口。
五、 验证配置结果
# Device A上检查路由表,可以查到10.3.3.0/24的RIP路由,度量值为6。
Device A# show ip route rip
R 10.3.3.0/24 [120/6] via 192.168.12.2, 00:06:11, GigabitEthernet 0/1