这篇文章介绍一下sham-link,并提供一个sham-link在XR平台下的配置案例(ASR9000)
写在最前面
拓扑请看图,使用的是virl模拟器
拓扑介绍
Core使用常用的IGP ISIS协议,标签分发没有选择使用LDP,而是使用的SR,PE-R2于PE-R4直接起VPNv4的邻居.以下是主要的配置:
1
```
2
R2:
3
router isis 1
4
is-type level-2-only
5
net 49.0000.0000.0002.00
6
address-family ipv4 unicast
7
metric-style wide
8
segment-routing mpls
9
!
10
interface Loopback0
11
address-family ipv4 unicast
12
prefix-sid index 2
13
!
14
!
15
interface GigabitEthernet0/0/0/1
16
point-to-point
17
address-family ipv4 unicast
18
19
router bgp 1
20
bgp router-id 10.1.2.2
21
address-family vpnv4 unicast
22
!
23
neighbor 10.1.4.4
24
remote-as 1
25
update-source Loopback0
26
address-family vpnv4 unicast
27
next-hop-self
28
```
29
```
30
R3
31
router isis 1
32
is-type level-2-only
33
net 49.0000.0000.0003.00
34
address-family ipv4 unicast
35
metric-style wide
36
segment-routing mpls
37
!
38
interface Loopback0
39
address-family ipv4 unicast
40
prefix-sid index 3
41
!
42
!
43
interface GigabitEthernet0/0/0/0
44
point-to-point
45
address-family ipv4 unicast
46
!
47
!
48
interface GigabitEthernet0/0/0/1
49
point-to-point
50
address-family ipv4 unicast
51
```
52
```
53
R4
54
router isis 1
55
is-type level-2-only
56
net 49.0000.0000.0004.00
57
address-family ipv4 unicast
58
metric-style wide
59
segment-routing mpls
60
!
61
interface Loopback0
62
address-family ipv4 unicast
63
prefix-sid index 4
64
!
65
!
66
interface GigabitEthernet0/0/0/0
67
point-to-point
68
address-family ipv4 unicast
69
70
router bgp 1
71
bgp router-id 10.1.4.4
72
address-family vpnv4 unicast
73
!
74
neighbor 10.1.2.2
75
remote-as 1
76
update-source Loopback0
77
address-family vpnv4 unicast
78
next-hop-self
79
```
默认为SR分配的标签块是16000-23999,为R4配置prefix-sid是index 4,所以我们在其它设备上去往R4 loopback接口的数据包会压16004的标签.
1
RP/0/0/CPU0:R2#show mpls forwarding
2
Fri Jul 5 07:57:52.647 UTC
3
Local Outgoing Prefix Outgoing Next Hop Bytes
4
Label Label or ID Interface Switched
5
------ ----------- ------------------ ------------ --------------- ------------
6
16003 Pop SR Pfx (idx 3) Gi0/0/0/1 10.1.23.3 0
7
16004 16004 SR Pfx (idx 4) Gi0/0/0/1 10.1.23.3 987559 <<<<
8
24000 Aggregate VIP: Per-VRF Aggr[V] \
9
VIP 8300
10
24001 Unlabelled 10.1.1.1/32[V] Gi0/0/0/0 10.1.12.1 0
11
24002 Unlabelled 10.1.15.0/24[V] Gi0/0/0/0 10.1.12.1 0
12
24003 Pop SR Adj (idx 1) Gi0/0/0/1 10.1.23.3 0
13
24004 Pop SR Adj (idx 3) Gi0/0/0/1 10.1.23.3 0
14
15
RP/0/0/CPU0:R2#traceroute 10.1.4.4 source 10.1.2.2
16
Fri Jul 5 07:58:32.184 UTC
17
18
Type escape sequence to abort.
19
Tracing the route to 10.1.4.4
20
21
1 10.1.23.3 [MPLS: Label 16004 Exp 0] 9 msec 0 msec 0 msec
22
2 10.1.34.4 0 msec * 0 msec
23
RP/0/0/CPU0:R2#
PE与CE之间的路由-OSPF
1
R1 Same with R5
2
router ospf 1
3
router-id 10.1.1.1
4
address-family ipv4 unicast
5
area 0
6
interface Loopback0
7
passive enable
8
!
9
interface GigabitEthernet0/0/0/0
10
```
11
```
12
R2 Same with R4
13
router ospf 1
14
vrf VIP
15
router-id 10.1.24.2
16
redistribute bgp 1 <<<<<
17
address-family ipv4 unicast
18
area 0
19
interface GigabitEthernet0/0/0/0
20
21
router bgp 1
22
bgp router-id 10.1.2.2
23
address-family vpnv4 unicast
24
!
25
neighbor 10.1.4.4
26
remote-as 1
27
update-source Loopback0
28
address-family vpnv4 unicast
29
next-hop-self
30
!
31
!
32
vrf VIP
33
rd auto
34
address-family ipv4 unicast
35
network 10.1.24.2/32
36
redistribute ospf 1 <<<<路由互相引入,必须配置
37
!
SHAM-LINK
Sham-link的由来,主要是由于CE与远端CE之间存在一条后门链路并使能了OSPF,这样就会造成本端CE会优选OSPF的区域内或区域间的路由,从后门链路走;而不会优选从PE学来的重分发的BGP路由。但往往这条后面链路只是作为一个备份路径使用,而不是用来在正常情况下跑流量的,因为Core的链路环境往往由运营商维护,更稳定一些.那如何解决这样的次优选路问题,这就引进的sham-link.
Sham-link的目的是将在PE上起一个虚拟的OSPF邻居关系,让远端CE的路由可以通过OSPF传递到PE上;
配置sham-link有以下的注意点:
- shan-link的源地址和目的地址必须是32位的掩码的loopback地址
- 必须绑定加入VPN示例即配置vrf
- 必须通过BGP进行路由通告,不能使用ospf进行路由通告
在后门链路上配置OSPF属于area 0,在CE1上检查一下路由表:
1
增加后门链路前:
2
RP/0/0/CPU0:R1#show route
3
L 10.1.1.1/32 is directly connected, 04:47:18, Loopback0
4
O IA 10.1.5.5/32 [110/3] via 10.1.12.2, 00:01:37, GigabitEthernet0/0/0/0 <<<<
5
C 10.1.12.0/24 is directly connected, 04:47:18, GigabitEthernet0/0/0/0
6
L 10.1.12.1/32 is directly connected, 04:47:18, GigabitEthernet0/0/0/0
7
C 10.1.15.0/24 is directly connected, 00:06:03, GigabitEthernet0/0/0/1
8
L 10.1.15.1/32 is directly connected, 00:06:03, GigabitEthernet0/0/0/1
9
O E2 10.1.24.4/32 [110/1] via 10.1.12.2, 00:04:28, GigabitEthernet0/0/0/0
10
O IA 10.1.45.0/24 [110/2] via 10.1.12.2, 00:01:38, GigabitEthernet0/0/0/0
11
增加后门链路后:
12
13
L 10.1.1.1/32 is directly connected, 04:50:46, Loopback0
14
O 10.1.5.5/32 [110/2] via 10.1.15.5, 00:00:01, GigabitEthernet0/0/0/1 <<<
15
C 10.1.12.0/24 is directly connected, 04:50:46, GigabitEthernet0/0/0/0
16
L 10.1.12.1/32 is directly connected, 04:50:46, GigabitEthernet0/0/0/0
17
C 10.1.15.0/24 is directly connected, 00:09:30, GigabitEthernet0/0/0/1
18
L 10.1.15.1/32 is directly connected, 00:09:30, GigabitEthernet0/0/0/1
19
O E2 10.1.24.2/32 [110/1] via 10.1.15.5, 00:00:01, GigabitEthernet0/0/0/1
20
O E2 10.1.24.4/32 [110/1] via 10.1.12.2, 00:07:56, GigabitEthernet0/0/0/0
21
O 10.1.45.0/24 [110/2] via 10.1.15.5, 00:00:01, GigabitEthernet0/0/0/1
对于去往对端CE环回口地址的路由由域间换成域内路由,走后门链路,与我们需求不符和,下面我们开始添加sham-link的配置:
1
1. shan-link的源地址和目的地址必须是32位的掩码的loopback地址
2
2. 必须绑定加入VPN示例即配置vrf
3
4
RP/0/0/CPU0:R2#show run int lo1
5
Mon Jul 8 06:22:15.998 UTC
6
interface Loopback1
7
vrf VIP
8
ipv4 address 10.1.24.2 255.255.255.255
9
10
3. 必须通过BGP进行路由通告,不能使用ospf进行路由通告
11
12
router bgp 1
13
vrf VIP
14
address-family ipv4 unicast
15
network 10.1.24.2/32
16
17
为什么这里需要使用BGP去重分发该路由?原因:如果使用的是ospf发布该loopback接口,对端CE学到的是O的路由会优选后门链路走,就不会经过骨干,sham-link就建立不起来
18
19
20
4. 配置sham-link
21
RP/0/0/CPU0:R2(config)#router ospf 1
22
RP/0/0/CPU0:R2(config-ospf)#vrf VIP
23
RP/0/0/CPU0:R2(config-ospf-vrf)#area 0
24
RP/0/0/CPU0:R2(config-ospf-vrf-ar)#sham-link 10.2.24.2 10.2.24.4
25
RP/0/0/CPU0:R2(config-ospf-vrf-ar-sl)#
26
RP/0/0/CPU0:R2(config-ospf-vrf-ar-sl)#commit
27
28
5. 检查sham-link邻接关系:
29
30
RP/0/0/CPU0:R2#show ospf vrf VIP sham-links
31
Mon Jul 8 06:34:38.668 UTC
32
33
Sham Links for OSPF 1, VRF VIP
34
35
Sham Link OSPF_SL0 to address 10.1.24.4 is up
36
Area 0, source address 10.1.24.2
37
IfIndex = 2
38
Run as demand circuit
39
DoNotAge LSA allowed., Cost of using 1
40
Transmit Delay is 1 sec, State POINT_TO_POINT,
41
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
42
Hello due in 00:00:03:904
43
Adjacency State FULL (Hello suppressed)
44
Number of DBD retrans during last exchange 0
45
Index 2/2, retransmission queue length 1, number of retransmission 0
46
First 0x15143ed0(5)/0(0) Next 0x15143ed0(5)/0(0)
47
Last retransmission scan length is 0, maximum is 0
48
Last retransmission scan time is 0 msec, maximum is 0 msec
49
Link State retransmission due in 3975 msec
50
RP/0/0/CPU0:R2#
51
52
RP/0/0/CPU0:R2#show ospf vrf VIP neighbor
53
Mon Jul 8 06:55:10.553 UTC
54
55
* Indicates MADJ interface
56
# Indicates Neighbor awaiting BFD session up
57
58
Neighbors for OSPF 1, VRF VIP
59
60
Neighbor ID Pri State Dead Time Address Interface
61
10.1.24.4 1 FULL/ - - 10.1.24.4 OSPF_SL0
62
Neighbor is up for 00:20:32
63
10.1.1.1 1 FULL/DR 00:00:31 10.1.12.1 GigabitEthernet0/0/0/0
64
Neighbor is up for 00:43:47
65
66
Total neighbor count: 2
检查一下增加sham-link后的路由表:
1
RP/0/0/CPU0:R1#show route
2
L 10.1.1.1/32 is directly connected, 05:27:56, Loopback0
3
O 10.1.5.5/32 [110/2] via 10.1.15.5, 00:00:12, GigabitEthernet0/0/0/1
4
C 10.1.12.0/24 is directly connected, 05:27:56, GigabitEthernet0/0/0/0
5
L 10.1.12.1/32 is directly connected, 05:27:56, GigabitEthernet0/0/0/0
6
C 10.1.15.0/24 is directly connected, 00:46:40, GigabitEthernet0/0/0/1
7
L 10.1.15.1/32 is directly connected, 00:46:40, GigabitEthernet0/0/0/1
8
O E2 10.1.24.2/32 [110/1] via 10.1.12.2, 00:00:12, GigabitEthernet0/0/0/0
9
[110/1] via 10.1.15.5, 00:00:12, GigabitEthernet0/0/0/1
10
O E2 10.1.24.4/32 [110/1] via 10.1.12.2, 00:45:06, GigabitEthernet0/0/0/0
11
O 10.1.45.0/24 [110/2] via 10.1.15.5, 00:00:12, GigabitEthernet0/0/0/1
12
13
修改一下后门链路的cost:
14
router ospf 1
15
area 0
16
interface GigabitEthernet0/0/0/1
17
cost 100
18
修改后的路由表:(符合我们预期走骨干网)
19
RP/0/0/CPU0:R1# show route
20
L 10.1.1.1/32 is directly connected, 05:25:14, Loopback0
21
O 10.1.5.5/32 [110/4] via 10.1.12.2, 00:16:40, GigabitEthernet0/0/0/0 <<< Get from sham-link
22
C 10.1.12.0/24 is directly connected, 05:25:14, GigabitEthernet0/0/0/0
23
L 10.1.12.1/32 is directly connected, 05:25:14, GigabitEthernet0/0/0/0
24
C 10.1.15.0/24 is directly connected, 00:43:58, GigabitEthernet0/0/0/1
25
L 10.1.15.1/32 is directly connected, 00:43:58, GigabitEthernet0/0/0/1
26
O E2 10.1.24.2/32 [110/1] via 10.1.12.2, 00:16:40, GigabitEthernet0/0/0/0
27
O E2 10.1.24.4/32 [110/1] via 10.1.12.2, 00:42:23, GigabitEthernet0/0/0/0
28
O 10.1.45.0/24 [110/3] via 10.1.12.2, 00:16:40, GigabitEthernet0/0/0/0
SHAM-LINK抓包
配置文件+抓包:
https://mega.nz/#F!QGgXlKAZ!TcFXtvvA29YqV7lYfrqUBg
this blog from Xuxing's Blog;