在MPLS ×××网络里的客户,如果使用动态路由OSPF,就会被MPLS网割断,形成的区不完整。

解决这个问题方法使用sham-link命令,可以使分割两面的区一体化。

131611405.png

R3和R5是PE,R1是P,R7和R8是CE,R3和R8的F0/0之间建立area 0区,R5和R7的F1/0之间也建立area 0区,如果用一般重分发的方法,得到对端的OSPF路由是O IA而不是O的,虽然双方都是用的area 0,使用sham-link来完整0区。在R7和R8的lookback接口启用area 1和2。

sham-link建立有些必要条件,要使用lookback接口作为起始和终端,要用/32地址

interface Loopback2
 ip vrf forwarding ***-1
 ip address 1.1.1.3 255.255.255.255

接口的IP路由要通过MP-BGP送达对端,

router bgp 100

 address-family ipv4 vrf ***-1

  redistribute ospf 2 vrf ***-1

  network 1.1.1.3 mask 255.255.255.255

使用的OSPF进行号要相同,如没有什么必要,不需要配置domain-id

router ospf vrf ***-1 

 area 0 sham-link 1.1.1.3 1.1.1.5

 redistribute bgp 100 subnets
 network 10.10.1.0 0.0.0.255 area 0

 

R3#sh ip ro vrf ***-1

Routing Table: ***-1
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, 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, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 2 subnets
C       1.1.1.3 is directly connected, Loopback2
B       1.1.1.5 [200/0] via 5.5.5.5, 00:36:34
     10.0.0.0/24 is subnetted, 4 subnets
C       10.10.1.0 is directly connected, FastEthernet1/0
O IA    10.10.2.0 [110/2] via 10.10.1.2, 00:06:30, FastEthernet1/0
O       10.10.3.0 [110/2] via 5.5.5.5, 00:06:30
O IA    10.10.4.0 [110/3] via 5.5.5.5, 00:06:30

R3#sh ip b v v ***-1 10.10.1.0
BGP routing table entry for 123:1:10.10.1.0/24, version 21
Paths: (1 available, best #1, table ***-1)
  Advertised to update-groups:
     1
  Local
    0.0.0.0 from 0.0.0.0 (3.3.3.3)
      Origin incomplete, metric 0, localpref 100, weight 32768, valid, sourced, best
      Extended Community: RT:123:1 OSPF DOMAIN ID:0x0005:0x000000020200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:10.10.1.1:0
      mpls labels in/out 22/aggregate(***-1)
R3#
R3#
R3#
R3#sh ip b v v ***-1 10.10.2.0
BGP routing table entry for 123:1:10.10.2.0/24, version 43
Paths: (1 available, best #1, table ***-1)
Flag: 0x820
  Advertised to update-groups:
     1
  Local
    10.10.1.2 from 0.0.0.0 (3.3.3.3)
      Origin incomplete, metric 2, localpref 100, weight 32768, valid, sourced, best
      Extended Community: RT:123:1 OSPF DOMAIN ID:0x0005:0x000000020200
        OSPF RT:0.0.0.0:3:0 OSPF ROUTER ID:10.10.1.1:0
      mpls labels in/out 25/nolabel
R3#
R3#
R3#sh ip b v v ***-1 10.10.3.0
BGP routing table entry for 123:1:10.10.3.0/24, version 29
Paths: (1 available, best #1, table ***-1, RIB-failure(17))
  Not advertised to any peer
  Local
    5.5.5.5 (metric 3) from 1.1.1.1 (1.1.1.1)
      Origin incomplete, metric 0, localpref 100, valid, internal, best
      Extended Community: RT:123:1 OSPF DOMAIN ID:0x0005:0x000000020200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:10.10.3.1:0
      Originator: 5.5.5.5, Cluster list: 1.1.1.1
      mpls labels in/out nolabel/21
R3#
R3#
R3#sh ip b v v ***-1 10.10.4.0
BGP routing table entry for 123:1:10.10.4.0/24, version 34
Paths: (1 available, best #1, table ***-1, RIB-failure(17))
  Not advertised to any peer
  Local
    5.5.5.5 (metric 3) from 1.1.1.1 (1.1.1.1)
      Origin incomplete, metric 2, localpref 100, valid, internal, best
      Extended Community: RT:123:1 OSPF DOMAIN ID:0x0005:0x000000020200
        OSPF RT:0.0.0.0:3:0 OSPF ROUTER ID:10.10.3.1:0
      Originator: 5.5.5.5, Cluster list: 1.1.1.1
      mpls labels in/out nolabel/22
R3#

 

R8#sh ip ro
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, 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, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 2 subnets
O E2    1.1.1.3 [110/1] via 10.10.1.1, 01:13:49, FastEthernet0/0
O E2    1.1.1.5 [110/1] via 10.10.1.1, 01:13:49, FastEthernet0/0
     10.0.0.0/24 is subnetted, 4 subnets
C       10.10.1.0 is directly connected, FastEthernet0/0
C       10.10.2.0 is directly connected, Loopback0
O       10.10.3.0 [110/3] via 10.10.1.1, 01:13:49, FastEthernet0/0
O IA    10.10.4.0 [110/4] via 10.10.1.1, 01:13:49, FastEthernet0/0
R8#sh ip os da

            OSPF Router with ID (10.10.5.1) (Process ID 2)

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
10.10.1.1       10.10.1.1       1385        0x8000002B 0x006C0D 2
10.10.3.1       10.10.3.1       2     (DNA) 0x80000007 0x00DABC 2
10.10.3.2       10.10.3.2       3     (DNA) 0x8000000A 0x00C6FE 1
10.10.5.1       10.10.5.1       549         0x80000009 0x008840 1

                Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
10.10.1.1       10.10.1.1       1385        0x80000003 0x00B328
10.10.3.1       10.10.3.1       1125  (DNA) 0x80000004 0x009342

                Summary Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
10.10.2.0       10.10.5.1       549         0x80000003 0x00AA5F
10.10.4.0       10.10.3.2       3     (DNA) 0x80000001 0x00A06A

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count
10.10.5.1       10.10.5.1       549         0x80000003 0x009252 1

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
10.10.1.0       10.10.5.1       552         0x80000003 0x00B555
10.10.3.0       10.10.5.1       552         0x80000003 0x00B353
10.10.4.0       10.10.5.1       552         0x80000003 0x00B252

                Summary ASB Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
10.10.1.1       10.10.5.1       552         0x80000003 0x009D6B
10.10.3.1       10.10.5.1       552         0x80000003 0x009174

                Type-5 AS External Link States

Link ID         ADV Router      Age         Seq#       Checksum Tag
1.1.1.3         10.10.1.1       361         0x80000004 0x0074EA 3489661028
1.1.1.3         10.10.3.1       42    (DNA) 0x80000001 0x006CF3 3489661028
1.1.1.5         10.10.1.1       361         0x80000004 0x0060FC 3489661028
1.1.1.5         10.10.3.1       16    (DNA) 0x80000001 0x005806 3489661028
R8#ping 10.10.4.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 112/128/160 ms
R8#

下面贴一下完整配置。

R8

hostname R8
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
no ip domain lookup
ip domain name lab.local
!
!
interface Loopback0
 ip address 10.10.2.1 255.255.255.0
 ip ospf network point-to-point
!
interface FastEthernet0/0
 ip address 10.10.1.2 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
router ospf 2
 log-adjacency-changes
 network 10.10.1.0 0.0.0.255 area 0
 network 10.10.2.0 0.0.0.255 area 1
!
no ip http server

 

R3

hostname R3
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
no ip domain lookup
ip domain name lab.local
!
!
ip vrf ***-1
 rd 123:1
 route-target export 123:1
 route-target import 123:1
!
!
interface Loopback1
 ip address 3.3.3.3 255.255.255.255
!
interface Loopback2
 ip vrf forwarding ***-1
 ip address 1.1.1.3 255.255.255.255
!
interface FastEthernet0/0
 ip address 192.168.5.1 255.255.255.0
 duplex auto
 speed auto
 mpls ip
!
interface FastEthernet1/0
 ip vrf forwarding ***-1
 ip address 10.10.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet2/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
 mpls ip
!
router ospf 2 vrf ***-1
 log-adjacency-changes
 area 0 sham-link 1.1.1.3 1.1.1.5
 redistribute bgp 100 subnets
 network 10.10.1.0 0.0.0.255 area 0
!
router ospf 1
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 192.168.1.0 0.0.0.255 area 0
 network 192.168.5.0 0.0.0.255 area 0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 1.1.1.3 mask 255.255.255.255
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 update-source Loopback1
 neighbor 2.2.2.2 remote-as 100
 neighbor 2.2.2.2 update-source Loopback1
 no auto-summary
 !
 address-family ***v4
  neighbor 1.1.1.1 activate
  neighbor 1.1.1.1 send-community both
  neighbor 2.2.2.2 activate
  neighbor 2.2.2.2 send-community both
 exit-address-family
 !
 address-family ipv4 vrf ***-1
  redistribute ospf 2 vrf ***-1
  no synchronization
  network 1.1.1.3 mask 255.255.255.255
 exit-address-family
!
no ip http server

 

R1

hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
no ip domain lookup
ip domain name lab.local
!
!
interface Loopback1
 ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
 ip address 192.168.6.1 255.255.255.0
 duplex auto
 speed auto
 mpls ip
!
interface FastEthernet1/0
 ip address 192.168.1.2 255.255.255.0
 duplex auto
 speed auto
 mpls ip
!
interface FastEthernet2/0
 ip address 192.168.3.1 255.255.255.0
 duplex auto
 speed auto
 mpls ip
!
router ospf 1
 log-adjacency-changes
 network 1.1.1.1 0.0.0.0 area 0
 network 192.168.1.0 0.0.0.255 area 0
 network 192.168.3.0 0.0.0.255 area 0
 network 192.168.6.0 0.0.0.255 area 0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor aaa peer-group
 neighbor aaa remote-as 100
 neighbor aaa update-source Loopback1
 neighbor 2.2.2.2 peer-group aaa
 neighbor 3.3.3.3 peer-group aaa
 neighbor 4.4.4.4 peer-group aaa
 neighbor 5.5.5.5 peer-group aaa
 neighbor 6.6.6.6 peer-group aaa
 no auto-summary
 !
 address-family ***v4
  neighbor aaa send-community both
  neighbor aaa route-reflector-client
  neighbor 2.2.2.2 activate
  neighbor 3.3.3.3 activate
  neighbor 4.4.4.4 activate
  neighbor 5.5.5.5 activate
  neighbor 6.6.6.6 activate
 exit-address-family
!
no ip http server

 

 

R5

hostname R5
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
no ip domain lookup
ip domain name lab.local
!
!
ip vrf ***-1
 rd 123:1
 route-target export 123:1
 route-target import 123:1
!
!
interface Loopback1
 ip address 5.5.5.5 255.255.255.255
!
interface Loopback2
 ip vrf forwarding ***-1
 ip address 1.1.1.5 255.255.255.255
!
interface FastEthernet0/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.168.3.2 255.255.255.0
 duplex auto
 speed auto
 mpls ip
!
interface FastEthernet2/0
 ip vrf forwarding ***-1
 ip address 10.10.3.1 255.255.255.0
 duplex auto
 speed auto
!
router ospf 2 vrf ***-1
 log-adjacency-changes
 area 0 sham-link 1.1.1.5 1.1.1.3
 redistribute bgp 100 subnets
 network 10.10.3.0 0.0.0.255 area 0
!
router ospf 1
 log-adjacency-changes
 network 5.5.5.5 0.0.0.0 area 0
 network 192.168.3.0 0.0.0.255 area 0
 network 192.168.7.0 0.0.0.255 area 0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 update-source Loopback1
 neighbor 2.2.2.2 remote-as 100
 neighbor 2.2.2.2 update-source Loopback1
 no auto-summary
 !
 address-family ***v4
  neighbor 1.1.1.1 activate
  neighbor 1.1.1.1 send-community both
  neighbor 2.2.2.2 activate
  neighbor 2.2.2.2 send-community both
 exit-address-family
 !
 address-family ipv4 vrf ***-1
  redistribute ospf 2 vrf ***-1
  no synchronization
  network 1.1.1.5 mask 255.255.255.255
 exit-address-family
!
no ip http server

 

 

R7

hostname R7
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
no ip domain lookup
ip domain name lab.local
!
!
interface Loopback0
 ip address 10.10.4.1 255.255.255.0
 ip ospf network point-to-point
!
interface FastEthernet0/0
 no ip address
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 10.10.3.2 255.255.255.0
 duplex auto
 speed auto
!
router ospf 2
 log-adjacency-changes
 network 10.10.3.0 0.0.0.255 area 0
 network 10.10.4.0 0.0.0.255 area 2
!
no ip http server