基于SR-TE policy 配置SR-TE

SR-TE policy --真机

一、topo

基于SR-TE policy 配置SR-TE_第1张图片
需求:
1、默认情况下R1访问R4通过矢量路由协议OSPF/ISIS的SPF算法走最优路径:R1-R6-R4
2、通过segment routing段路由严格控路让R1-R4走R1-R2-R4-R6这条链路互访

二、SR-BE配置步骤

1、基础连通性配置

1)命名、关闭DCN、PNP(以R1为例)

[HUAWEI]sysname R1
[R1]undo dcn
[R1]undo pnp enable 

2)互联接口,回环口配置IP地址(以R1为例)

[R1-GigabitEthernet0/5/0]int g0/5/1       
[R1-GigabitEthernet0/5/0]ip add 10.1.16.1 24
[R1-GigabitEthernet0/5/0]int g0/5/1         
[R1-GigabitEthernet0/5/1]ip add 10.1.12.1 24
[R1-GigabitEthernet0/5/1]int lo0
[R1-LoopBack0]ip add 10.1.1.1 32

连通性测试:

[R6-LoopBack0]ping 10.1.16.1
  PING 10.1.16.1: 56  data bytes, press CTRL_C to break
    Reply from 10.1.16.1: bytes=56 Sequence=1 ttl=255 time=1 ms
    Reply from 10.1.16.1: bytes=56 Sequence=2 ttl=255 time=1 ms
    Reply from 10.1.16.1: bytes=56 Sequence=3 ttl=255 time=1 ms
    Reply from 10.1.16.1: bytes=56 Sequence=4 ttl=255 time=1 ms
    Reply from 10.1.16.1: bytes=56 Sequence=5 ttl=255 time=2 ms

  --- 10.1.16.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 1/1/2 ms
 
[R6-LoopBack0]ping 10.1.46.4
  PING 10.1.46.4: 56  data bytes, press CTRL_C to break
    Reply from 10.1.46.4: bytes=56 Sequence=1 ttl=255 time=1 ms
    Reply from 10.1.46.4: bytes=56 Sequence=2 ttl=255 time=1 ms
    Reply from 10.1.46.4: bytes=56 Sequence=3 ttl=255 time=1 ms
    Reply from 10.1.46.4: bytes=56 Sequence=4 ttl=255 time=1 ms
    Reply from 10.1.46.4: bytes=56 Sequence=5 ttl=255 time=1 ms

  --- 10.1.46.4 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 1/1/1 ms

2、core igp配置(以R1为例)

1)OSPF

ospf 1 router-id 1.1.1.1
 area 0.0.0.0
  network 10.1.1.1 0.0.0.0
  network 10.1.12.1 0.0.0.0
  network 10.1.16.1 0.0.0.0

验证:

[R1]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole route
------------------------------------------------------------------------------
_public_ Routing Table : OSPF
         Destinations : 10       Routes : 11        

OSPF routing table status : 
         Destinations : 7        Routes : 8         

Destination/Mask    Proto   Pre  Cost        Flags NextHop         Interface

       10.1.2.2/32  OSPF    10   1             D   10.1.12.2       GigabitEthernet0/5/1
       10.1.3.3/32  OSPF    10   2             D   10.1.12.2       GigabitEthernet0/5/1
       10.1.4.4/32  OSPF    10   2             D   10.1.16.6       GigabitEthernet0/5/0
       10.1.6.6/32  OSPF    10   1             D   10.1.16.6       GigabitEthernet0/5/0
      10.1.23.0/24  OSPF    10   2             D   10.1.12.2       GigabitEthernet0/5/1
      10.1.34.0/24  OSPF    10   3             D   10.1.12.2       GigabitEthernet0/5/1
                    OSPF    10   3             D   10.1.16.6       GigabitEthernet0/5/0
      10.1.46.0/24  OSPF    10   2             D   10.1.16.6       GigabitEthernet0/5/0

OSPF routing table status : 
         Destinations : 3        Routes : 3         

Destination/Mask    Proto   Pre  Cost        Flags NextHop         Interface
                
       10.1.1.1/32  OSPF    10   0                 10.1.1.1        LoopBack0
      10.1.12.0/24  OSPF    10   1                 10.1.12.1       GigabitEthernet0/5/1
      10.1.16.0/24  OSPF    10   1                 10.1.16.1       GigabitEthernet0/5/0

2)ISIS

a.全局使能ISIS
isis 1
 is-level level-2
 cost-style wide
 network-entity 49.0001.0000.0000.0001.00
 is-name R1
b.接口使能ISIS
[R1]int g0/5/1
[R1-GigabitEthernet0/5/1]isis en
[R1-GigabitEthernet0/5/1]int g0/5/0
[R1-GigabitEthernet0/5/0]isis en
[R1-GigabitEthernet0/5/0]int lo0
[R1-LoopBack0]isis en

验证:

[R1]dis isis route 

                         Route information for ISIS(1)
                         -----------------------------

                        ISIS(1) Level-2 Forwarding Table
                        --------------------------------

IPV4 Destination   IntCost    ExtCost ExitInterface     NextHop         Flags
-------------------------------------------------------------------------------
10.1.1.1/32        0          NULL    Loop0             Direct          D/-/L/-
10.1.2.2/32        10         NULL    GE0/5/1           10.1.12.2       A/-/-/-
10.1.3.3/32        20         NULL    GE0/5/1           10.1.12.2       A/-/-/-
10.1.4.4/32        20         NULL    GE0/5/0           10.1.16.6       A/-/-/-
10.1.6.6/32        10         NULL    GE0/5/0           10.1.16.6       A/-/-/-
10.1.12.0/24       10         NULL    GE0/5/1           Direct          D/-/L/-
10.1.16.0/24       10         NULL    GE0/5/0           Direct          D/-/L/-
10.1.23.0/24       20         NULL    GE0/5/1           10.1.12.2       A/-/-/-
10.1.34.0/24       30         NULL    GE0/5/1           10.1.12.2       A/-/-/-
                                      GE0/5/0           10.1.16.6       
10.1.46.0/24       20         NULL    GE0/5/0           10.1.16.6       A/-/-/-
     Flags: D-Direct, A-Added to URT, L-Advertised in LSPs, S-IGP Shortcut, 
            U-Up/Down Bit Set, LP-Local Prefix-Sid
     Protect Type: L-Link Protect, N-Node Protect

3、使能MPLS(以R1为例)

全局使能

[R1]mpls lsr-id 10.1.1.1
[R1]mpls

4、使能SR(以R1为例)

1)全局使能SR

[R1]segment-routing

2)IGP使能SR

a.OSPF
ospf 1
 opaque-capability enable
 segment-routing mpls
 segment-routing global-block 16100 16199
b.ISIS
isis 1
 segment-routing mpls
 segment-routing global-block 16100 16199

3)回环接口使能prefix sid

[R1]interface LoopBack 0
[R1-LoopBack0]ospf prefix-sid index 1

验证:

[R1]dis segment-routing prefix mpls forwarding

                   Segment Routing Prefix MPLS Forwarding Information
             --------------------------------------------------------------
             Role : I-Ingress, T-Transit, E-Egress, I&T-Ingress And Transit

Prefix             Label      OutLabel   Interface         NextHop          Role  MPLSMtu   Mtu     State          
-----------------------------------------------------------------------------------------------------------------
10.1.1.1/32        16101      NULL       Loop0             127.0.0.1        E     ---       1500    Active          
10.1.2.2/32        16102      16202      GE0/5/1           10.1.12.2        I&T   ---       1500    Active          
10.1.3.3/32        16103      16203      GE0/5/1           10.1.12.2        I&T   ---       1500    Active          
10.1.4.4/32        16104      16604      GE0/5/0           10.1.16.6        I&T   ---       1500    Active          
10.1.6.6/32        16106      16606      GE0/5/0           10.1.16.6        I&T   ---       1500    Active          

Total information(s): 5

4)配置adjacency sid

思路:

基于SR-TE policy 配置SR-TE_第2张图片

R1:
segment-routing
 ipv4 adjacency local-ip-addr 10.1.12.1 remote-ip-addr 10.1.12.2 sid 147012
 ipv4 adjacency local-ip-addr 10.1.16.1 remote-ip-addr 10.1.16.6 sid 147016
#
R2:
segment-routing
 ipv4 adjacency local-ip-addr 10.1.12.2 remote-ip-addr 10.1.12.1 sid 147021
 ipv4 adjacency local-ip-addr 10.1.23.2 remote-ip-addr 10.1.23.3 sid 147023
#
R3:
segment-routing
 ipv4 adjacency local-ip-addr 10.1.23.3 remote-ip-addr 10.1.23.2 sid 147032
 ipv4 adjacency local-ip-addr 10.1.34.3 remote-ip-addr 10.1.34.4 sid 147034
#
R4:
segment-routing
 ipv4 adjacency local-ip-addr 10.1.34.4 remote-ip-addr 10.1.34.3 sid 147043
 ipv4 adjacency local-ip-addr 10.1.46.4 remote-ip-addr 10.1.46.6 sid 147046
#
R6:
segment-routing
 ipv4 adjacency local-ip-addr 10.1.46.6 remote-ip-addr 10.1.46.4 sid 147064
 ipv4 adjacency local-ip-addr 10.1.16.6 remote-ip-addr 10.1.16.1 sid 147061

验证:


[R1]DIS segment-routing adjacency mpls forwarding  

            Segment Routing Adjacency MPLS Forwarding Information

Label     Interface         NextHop          Type        MPLSMtu   Mtu       
-----------------------------------------------------------------------------
2108      GE0/5/0           10.1.16.6        OSPFv2      ---       1500      
2109      GE0/5/1           10.1.12.2        OSPFv2      ---       1500      
2140      GE0/5/0           10.1.16.6        ISIS-V4     ---       1500      
2141      GE0/5/1           10.1.12.2        ISIS-V4     ---       1500      
147012    GE0/5/1           10.1.12.2        STATIC-V4   ---       1500      
147016    GE0/5/0           10.1.16.6        STATIC-V4   ---       1500      

Total information(s): 

三、SR-TE policy 配置

1)配置segment-list

R1:
segment-list toR4
  index 10 sid label 147012
  index 20 sid label 147023
  index 30 sid label 147034
R4:
segment-list toR1
  index 10 sid label 147043
  index 20 sid label 147032
  index 30 sid label 147021

2)配置SR-TE policy

R1:
sr-te policy A endpoint 10.1.4.4 color 100
  candidate-path preference 200
   segment-list toR4
R4:
 sr-te policy A endpoint 10.1.1.1 color 100
  candidate-path preference 200
   segment-list toR1

验证:

[R1]dis sr-te policy policy-name A   
PolicyName : A
Endpoint             : 10.1.4.4                       Color                : 100
TunnelId             : 1                              TunnelType           : SR-TE Policy
Binding SID          : -                              MTU                  : -
Policy State         : Up                             State Change Time    : 2022-07-20 02:39:27
Admin State          : UP                             Traffic Statistics   : Disable             
BFD                  : Disable                        Backup Hot-Standby   : Disable
DiffServ-Mode        : -
Candidate-path Count : 1                   

Candidate-path Preference: 200
Path State           : Active                         Path Type            : Primary
Protocol-Origin      : Configuration(30)              Originator           : 0, 0.0.0.0
Discriminator        : 200                            Binding SID          : -
GroupId              : 1                              Policy Name          : A
Template ID          : -                             
Segment-List Count   : 1
 Segment-List        : toR4
  Segment-List ID    : 1                              XcIndex              : 2000001
  List State         : Up                             BFD State            : -
  EXP                : -                              TTL                  : -
  DeleteTimerRemain  : -
  Label : 147012, 147023, 147034
  
[R4]dis sr-te policy policy-name A 
PolicyName : A
Endpoint             : 10.1.1.1                       Color                : 100
TunnelId             : 8193                           TunnelType           : SR-TE Policy
Binding SID          : -                              MTU                  : -
Policy State         : Up                             State Change Time    : 2022-07-20 02:47:26
Admin State          : UP                             Traffic Statistics   : Disable             
BFD                  : Disable                        Backup Hot-Standby   : Disable
DiffServ-Mode        : -
Candidate-path Count : 1                   

Candidate-path Preference: 200
Path State           : Active                         Path Type            : Primary
Protocol-Origin      : Configuration(30)              Originator           : 0, 0.0.0.0
Discriminator        : 200                            Binding SID          : -
GroupId              : 8193                           Policy Name          : A
Template ID          : -                             
Segment-List Count   : 1
 Segment-List        : toR1
  Segment-List ID    : 8193                           XcIndex              : 2008193
  List State         : Up                             BFD State            : -
  EXP                : -                              TTL                  : -
  DeleteTimerRemain  : -
  Label : 147043, 147032, 147021

四、流量导入

1、ipv4 bgp over SR-TE policy

1)创建tunnel policy

R1:
tunnel-policy toR4
 tunnel select-seq sr-te-policy load-balance-number 2 unmix
R4:
tunnel-policy toR1
 tunnel select-seq sr-te-policy load-balance-number 2 unmix

2)迭代隧道调用tunnel policy

R1:
route recursive-lookup tunnel tunnel-policy toR4
R4:
route recursive-lookup tunnel tunnel-policy toR1

3)配置颜色

a.R1和R4建立IBGP邻居关系
bgp 234
 router-id 1.1.1.1
 peer 10.1.4.4 as-number 234
 peer 10.1.4.4 connect-interface LoopBack0

验证:

[R4-bgp]dis bgp peer 
 
 BGP local router ID : 4.4.4.4
 Local AS number : 234
 Total number of peers : 1                 Peers in established state : 1

  Peer                             V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State     	 PrefRcv
  10.1.1.1                         4         234       4       4      0   00:00:22     Established      1
a.创建route-policy
route-policy color permit node 10
 apply extcommunity color 0:100
c.向peer通告扩展community属性,通告loopback 带上route-policy
R1:
BGP 234
 peer 10.1.4.4 advertise-ext-community
 net 10.1.11.11 route-policy color 
 
R4:
BGP 234
 peer 10.1.1.1 advertise-ext-community
 net 10.1.44.44 route-policy color 

验证:

[R1-bgp]dis bgp routing-table 10.1.44.44
 
 BGP local router ID : 1.1.1.1
 Local AS number : 234
 Paths:   1 available, 1 best, 1 select, 0 best-external, 0 add-path
 BGP routing table entry information of 10.1.44.44/32:
 From: 10.1.4.4 (4.4.4.4)  
 Route Duration: 0d00h00m21s
 Relay IP Nexthop: 10.1.16.6
 Relay IP Out-Interface: GigabitEthernet0/5/0
 Relay Tunnel Out-Interface: A
 Original nexthop: 10.1.4.4
 Qos information : 0x0
 Ext-Community: Color <0 : 100>
 AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, pre 255
 Not advertised to any peer yet
 
 [R4-bgp]dis bgp routing-table 10.1.44.44
 
 BGP local router ID : 4.4.4.4
 Local AS number : 234
 Paths:   1 available, 1 best, 1 select, 0 best-external, 0 add-path
 BGP routing table entry information of 10.1.44.44/32:
 Network route.
 From: 0.0.0.0 (0.0.0.0)  
 Route Duration: 0d00h01m09s
 Direct Out-interface: LoopBack1
 Original nexthop: 127.0.0.1
 Qos information : 0x0
 Ext-Community: Color <0 : 100>
 AS-path Nil, origin igp, MED 0, pref-val 0, valid, local, best, select, pre 0
 Advertised to such 1 peers:
    10.1.1.1
[R1]dis ip routing-table 10.1.44.44
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole route
------------------------------------------------------------------------------
Routing Table : _public_
Summary Count : 1

Destination/Mask    Proto   Pre  Cost        Flags NextHop         Interface

     10.1.44.44/32  IBGP    255  0             RD  10.1.4.4        A

五、结果测试

[R1]tracert -v -a 10.1.11.11 10.1.44.44
 traceroute to 10.1.44.44(10.1.44.44), max hops: 30, packet length: 40, press CTRL_C to break
 1 10.1.12.2[MPLS Label=147023/147034 Exp=0/0 S=0/1 TTL=1/1] 4 ms  3 ms  3 ms 
 2  *  *  *
 3 10.1.44.44 3 ms  2 ms  3 ms
 
 [R1]dis ip routing-table 10.1.44.44 verbose 
Route Flags: R - relay, D - download to fib, T - to -instance, B - black hole route
------------------------------------------------------------------------------
Routing Table : _public_
Summary Count : 1

Destination: 10.1.44.44/32       
     Protocol: IBGP               Process ID: 0              
   Preference: 255                      Cost: 0              
      NextHop: 10.1.4.4            Neighbour: 10.1.4.4
        State: Active Adv Relied         Age: 00h05m57s           
          Tag: 0                    Priority: low            
        Label: NULL                  QoSInfo: 0x0           
   IndirectID: 0x10000F7            Instance:                                 
 RelayNextHop: 0.0.0.0             Interface: A
     TunnelID: 0x000000003200000001    Flags: RD 
     
 [R1]dis fib slot 7 10.1.44.44
  Route Entry Count: 1
Destination/Mask   Nexthop         Flag TimeStamp     Interface                         TunnelID            
10.1.44.44/32      10.1.4.4        DGU  03:46:23      A                                 0x000000003200000001
 
             QoSInfo: 0x0           

IndirectID: 0x10000F7 Instance:
RelayNextHop: 0.0.0.0 Interface: A
TunnelID: 0x000000003200000001 Flags: RD

[R1]dis fib slot 7 10.1.44.44
Route Entry Count: 1
Destination/Mask Nexthop Flag TimeStamp Interface TunnelID
10.1.44.44/32 10.1.4.4 DGU 03:46:23 A 0x000000003200000001


你可能感兴趣的:(华为认证,数通,segment,routing,网络)