Dell Networking SONiC: Sådan konfigurerer du politikbaseret routing

摘要: Denne artikel forklarer, hvordan du konfigurerer politikbaseret routing i Dell Networking SONiC med et enkelt eksempel.

本文适用于 本文不适用于 本文并非针对某种特定的产品。 本文并非包含所有产品版本。

说明

Forudsætninger

Vi bruger standardgrænsefladenavne til at demonstrere koncepterne. Se artiklen Dell Networking S-serien: Basic Interface Configuration - SONiC 4.0 for at få flere oplysninger om navngivning af grænseflade


Indeks

 

Hvad er politikbaseret routing?

Policy-Based Routing (PBR) giver en metode til at videresende pakker ved at tilsidesætte de oplysninger, der er tilgængelige i IP-routingtabellen. Du kan implementere politikker, der selektivt får pakker til at tage forskellige stier. Traditionel IP-routing videresender pakker kun baseret på destinations-IP-adressen i pakken. PBR kan konfigureres til at videresende pakker baseret på andre kriterier, såsom TCP/UDP-portnumre, kilde-IP-adresse, DSCP-værdi og TCP-flag. Dell SONiC bruger flowbaserede servicepolitikker til politikbaseret routing. Videresendelsespolitikker består af klassekort, der vælger pakker og angiver handlinger, der får en pakke til at blive videresendt til et forudbestemt næste hop eller interface og omgår den sti, der bestemmes af rute- og videresendelsestabeller. Du kan definere flere match- og udgående grænseflade- eller næste hop-værdier i samme politik. Du kan anvende videresendelsespolitikker på skiftet eller dirigeret trafik. Trafik kan dirigeres til den samme VRF, der bruges af indgående grænseflade, eller en anden VRF.

Brug politikbaseret routing til at give lige adgang, protokolfølsom routing, kildefølsom routing, routing baseret på interaktiv sammenligning med batchtrafik og routing baseret på dedikerede links. Politikbaseret routing er en mere fleksibel mekanisme til routing af pakker end destinationsrouting.
 

Trin til konfiguration af politikbaseret routing

Dell SONiC implementerer PBR ved at stille en modulær struktur til rådighed til klassificering af trafik og anvendelse af videresendelseshandlinger, f.eks. indstil IP næste hop, på udvalgt trafik.

Sådan konfigureres PBR:

  1. Klassificer (vælg) trafik til politikbaseret routing ved hjælp af ACL'er eller felterne L2, L3 eller L4 i pakkeoverskrifter.
  2. Konfigurer de videresendelseshandlinger, der skal udføres på hvert klassificeret flow, i et politikkort.
  3. Anvend videresendelsespolitikken på indgående grænseflader – globalt på alle switchgrænseflader, en specificeret grænseflade, et VLAN eller en portkanal
I en nøddeskal:

Trin til konfiguration af politikbaseret routing


BEMÆRK: I Dell SONiC:
  • Hvis en indgående trafik ikke finder overensstemmelse i nogen af de udsagn, der anvendes på et politikkort i en grænseflade/vlan/portkanal/globalt, videresendes den i henhold til standardrutetabellen.
  • En videresendelsespolitik understøttes kun på indgående grænseflader.
  • Videresendelsespolitikker kan kun videresende udvalgt trafik; de kan ikke fange, skifte eller dirigere trafik til CPU'en.
  • Videresendelsespolitikker med næste hop- og næste hopgruppe-handlinger gælder kun for dirigeret L3-trafik.
  • Videresendelsespolitikker, der bruger en Ethernet- eller portkanaludgangsgrænseflade, gælder kun på switchet L2-trafik.
  • Videresendelsespolitikker gælder ikke for trafik, der er bestemt til CPU'en (destinations-IP-adressen er den samme som switchadressen) eller trafik, der er fanget i CPU'en.
  • Når du anvender en videresendelsespolitik globalt på alle grænseflader, skal næste hop være i standard VRF, medmindre du angiver en ikke-standard VRF ved hjælp af kommandoen sæt {ip | ipv6} next-hop ip-address vrf vrf-name i politikoversigten.

 

Syntaks for konfiguration

Konfigurer klassekort for at klassificere trafik

Vi kan klassificere (matche) den indgående trafik ved at følge metoder i et klassekort.

  1. Brug af IPv4 eller IPv6 eller MAC-adgangsliste
  2. Brug af L2-L4-overskriftsfelter

Kommandosyntaks under brug af Access-listen for at matche trafikken på klassekortet.

Hvis vi konfigurerer adgangslisten, så den svarer til trafikken på klassekortet, skal du sørge for at konfigurere adgangslisten.

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# class-map {CLASSMAP-NAME} match-type acl 
DELLSONiC(config-class-map)# match access-group {ip, ipv6, mac} {Access-List-name}

Kommandosyntaks under brug af L2-L4-overskriftsfelter

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# class-map {CLASSMAP-NAME} match-type fields match-all
DELLSONiC(config-class-map)# match {MATCH-CRITERIA}
 
The following is the Match Criteria

  dei                  Match packets using DEI value
  destination-address  Match packets using destination address
  dscp                 Match packets using DSCP value
  ethertype            Match packets using ethertype
  ip                   Match packets using IP/IPv6 protocol
  l4-port              Match packets using TCP/UDP port
  pcp                  Match packets using PCP
  source-address       Match packets using source address
  tcp-flags            Match packets using TCP flags
  vlan                 Match packets using VLAN ID

 

Konfigurer politiktilknytning

En PBR-videresendelsespolitik angiver de videresendelseshandlinger, der skal udføres for at matche trafik til politikbaseret routing. En videresendelsespolitik understøtter følgende handlinger:

  • Indstil næste hop - Dirigerer IPv4-trafik til et IPv4 næste hop; dirigerer IPv6-trafik til et IPv6 næste hop.
  • Indstil næste hopgruppe – Angiver den gruppe, hvorfra den bedste næste hop-IPv4- eller IPv6-adresse vælges.
  • Indstil grænseflade - Videresend L2-trafik til en specificeret udgangsgrænseflade.
  • Indstil grænseflade null - Fjerner matchende trafik, hvis null-grænsefladen er indstillet, eller hvis ingen af de angivne næste hop er tilgængelige, eller hvis den angivne udgangsgrænseflade ikke er L2 og linker.
  • Indstil replikeringsgruppe – Bruges til at replikere trafik til anycast-servere, der er designet til at løse hashingproblemet som beskrevet i RFC7690.

Kommandosyntaks

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# policy-map {POLICYMAP-NAME} type forwarding  
DELLSONiC(config-policy-map)# 
DELLSONiC(config-policy-map)# class {CLASS-MAP-NAME} priority {Priority-value}

Enter a priority number (0-4095) to specify the order in which a class map is applied in the policy map to match traffic in the flow. A higher priority class map is processed before a lower priority.


If next hop is a IP address

DELLSONiC(config-policy-map-flow)# set ip next-hop {IP-ADDRESS}


If next hop is a IPv6 address

DELLSONiC(config-policy-map-flow)# set ipv6 next-hop {IPv6 Address}


If we need a specific interface where the traffic is to be forwarded

DELLSONiC(config-policy-map-flow)# set interface {Eth, Null, PortChannel } {interface number}


If we have a IPv4/IPv6 Next Hop Group

DELLSONiC(config-policy-map-flow)# set ip next-hop-group {IPv4 Next Hop Group}
DELLSONiC(config-policy-map-flow)# set ipv6 next-hop-group {IPv6 Next Hop Group}


If we have a IPv4/IPv6 Replication Group

DELLSONiC(config-policy-map-flow)# set ip replication-group {Ipv4 Replication Group}
DELLSONiC(config-policy-map-flow)# set ipv6 replication-group {Ipv4 Replication Group}

 

Konfigurer servicepolitik (Anvend politikkort i grænseflade)

På en grænseflade eller undergrænseflade:

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# interface {Eth slot/port[/breakout-port] [.subinterface]}
DELLSONiC(config-if-Eth)# service-policy type forwarding in {policy-map-name}

På VLAN-grænseflader:

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# interface Vlan {vlan-id}
DELLSONiC(conf-if-Vlan)# service-policy type forwarding in {policy-map-name}

På portkanalgrænseflader,

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# interface PortChannel {portchannel-number}
DELLSONiC(conf-if-po)# service-policy type forwarding in {policy-map-name}

Globalt på alle switchgrænseflader

When you apply a forwarding policy globally on all interfaces, the next-hops must be in the default VRF unless you set a non-default VRF using the set {ip | ipv6} next-hop ip-address vrf vrf-name command in the policy map.

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# service-policy type forwarding in {policy-map-name}

 

Bekræft

Use the Following commands to verify Class Map

DELLSONiC# show class-map {class-map-name}

Use the Following commands to verify policy map

DELLSONiC# show policy-map {POLICY-MAP-NAME}


Use the Following commands to service Policy

DELLSONiC# show policy-map type forwarding

DELLSONiC# show service-policy interface {Interface}

DELLSONiC# show service-policy summary

 

Eksempelkonfiguration

Lad os overveje følgende topologi.

Topologi

Vi har ikke en rute til 50.0.0.0/24 og 60.0.0.0/24 i DELLSONiC.

DELLSONiC# show ip route 
Codes:  K - kernel route, C - connected, S - static, B - BGP, O - OSPF
        > - selected route, * - FIB route, q - queued route, r - rejected route
       Destination        Gateway                                                                    Dist/Metric   Last Update 
--------------------------------------------------------------------------------------------------------------------------------
 C>*   1.1.1.1/32         Direct                          Loopback0                                  0/0           09:18:16 ago
 C>*   10.0.0.0/24        Direct                          Eth1/1                                     0/0           09:17:56 ago
 C>*   20.0.0.0/24        Direct                          Eth1/2                                     0/0           01:58:41 ago
 C>*   30.0.0.0/24        Direct                          Eth1/3                                     0/0           09:14:38 ago

 

Mål:

Trafik til serverfarm 50.0.0.0/24 skal dirigeres til næste hop 20.0.0.2. Trafikken til serverfarm 60.0.0.0/24 skal dirigeres til næste hop 30.0.0.2.
 

Konfiguration

Lad os konfigurere klassekortet. Her klassificerer vi trafikken baseret på forskellige parametre.
Klasse Kort MATCH_IP_OF_SERVER-1 Matchkriterierne er DST-IP 50.0.0.0/24.
På klassekortet MATCH_IP_OF_SERVER-2, er matchkriterierne DST-IP 60.0.0.0/24.

admin@DELLSONiC:~$ sonic-cli
DELLSONiC#
DELLSONiC# configure
DELLSONiC(config)# class-map MATCH_IP_OF_SERVER-1 match-type fields match-all
DELLSONiC(config-class-map)# description "MATCH IP ADDRESS of SERVER FARM 1"
DELLSONiC(config-class-map)# match destination-address ip 50.0.0.0/24
DELLSONiC(config-class-map)# exit
DELLSONiC(config)#
DELLSONiC(config)# class-map MATCH_IP_OF_SERVER-2 match-type fields match-all
DELLSONiC(config-class-map)# description "MATCH IP ADDRESS of SERVER FARM 2"
DELLSONiC(config-class-map)# match destination-address ip 60.0.0.0/24
DELLSONiC(config-class-map)# exit
DELLSONiC(config)# exit
DELLSONiC#

Lad os konfigurere Policy Map.
Her definerer vi, hvad der er den næste handling, der skal udføres, hvis trafikken matcher en tilstand. I dette tilfælde, hvis trafikken matcher en bestemt destinations-IP-adresse, skal du videresende til en bestemt næste hop-IP.

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# policy-map FORWARD_TO_SERVER type forwarding
DELLSONiC(config-policy-map)# class MATCH_IP_OF_SERVER-2 priority 100
DELLSONiC(config-policy-map-flow)# set ip next-hop 30.0.0.2
DELLSONiC(config-policy-map-flow)# exit
DELLSONiC(config-policy-map-flow)#
DELLSONiC(config-policy-map)# class MATCH_IP_OF_SERVER-1 priority 100
DELLSONiC(config-policy-map-flow)# set ip next-hop 20.0.0.2
DELLSONiC(config-policy-map-flow)# exit
DELLSONiC(config-policy-map)# exit
DELLSONiC(config)#

Lad os anvende politikkortet som servicepolitik på grænsefladen Eth 1/1.

admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# interface Eth 1/1
DELLSONiC(config-if-Eth1/1)# service-policy type forwarding in FORWARD_TO_SERVER
DELLSONiC(config-if-Eth1/1)# end


Kontrollér konfiguration

Lad os kontrollere klassekortkonfigurationen. Her kan vi se for MATCH_IP_OF_SERVER-1 Matchkriterierne er DST-IP 50.0.0.0/24. På klassekortet MATCH_IP_OF_SERVER-2, er matchkriterierne DST-IP 60.0.0.0/24.

DELLSONiC# show class-map MATCH_IP_OF_SERVER-1
Class-map MATCH_IP_OF_SERVER-1 match-type fields
  Description: "MATCH IP ADDRESS of SERVER FARM 1"
  Match:
    dst-ip 50.0.0.0/24
  Referenced in flows:
    policy FORWARD_TO_SERVER at priority 100
DELLSONiC#

 

DELLSONiC# show class-map MATCH_IP_OF_SERVER-2
Class-map MATCH_IP_OF_SERVER-2 match-type fields
  Description: "MATCH IP ADDRESS of SERVER FARM 2"
  Match:
    dst-ip 60.0.0.0/24
  Referenced in flows:
    policy FORWARD_TO_SERVER at priority 100
DELLSONiC#

Politikkortet definerer, hvad der er det næste hop for en trafik, der er klassificeret under et klassekort.

DELLSONiC# show policy-map type forwarding
Policy FORWARD_TO_SERVER Type forwarding
  Description:
  Flow MATCH_IP_OF_SERVER-2 at priority 100
    Description:
    set ip nexthop 30.0.0.2
  Flow MATCH_IP_OF_SERVER-1 at priority 100
    Description:
    set ip nexthop 20.0.0.2
  Applied to:
    Eth1/1 at Ingress

 

DELLSONiC# show policy-map FORWARD_TO_SERVER
Policy FORWARD_TO_SERVER Type forwarding
  Description:
  Flow MATCH_IP_OF_SERVER-2 at priority 100
    Description:
    set ip nexthop 30.0.0.2
  Flow MATCH_IP_OF_SERVER-1 at priority 100
    Description:
    set ip nexthop 20.0.0.2
  Applied to:
    Eth1/1 at Ingress
DELLSONiC#

Servicepolitikken definerer, hvor politiktilknytningen skal anvendes.

DELLSONiC# show service-policy summary
Eth1/1
    forwarding policy FORWARD_TO_SERVER at ingress
CtrlPlane
    qos policy oob-qos-policy at ingress

 

DELLSONiC# show service-policy interface Eth 1/1
Eth1/1
  Policy FORWARD_TO_SERVER type forwarding at ingress
  Description:
    Flow MATCH_IP_OF_SERVER-2 at priority 100 (Active)
      Description:
      set ip nexthop 30.0.0.2 (Selected)
      Packet matches: 616 frames 62832 bytes
    Flow MATCH_IP_OF_SERVER-1 at priority 100 (Active)
      Description:
      set ip nexthop 20.0.0.2 (Selected)
      Packet matches: 50 frames 5100 bytes
DELLSONiC#

 

DELLSONiC# show service-policy policy-map FORWARD_TO_SERVER
Eth1/1
  Policy FORWARD_TO_SERVER type forwarding at ingress
  Description:
    Flow MATCH_IP_OF_SERVER-2 at priority 100 (Active)
      Description:
      set ip nexthop 30.0.0.2 (Selected)
      Packet matches: 616 frames 62832 bytes
    Flow MATCH_IP_OF_SERVER-1 at priority 100 (Active)
      Description:
      set ip nexthop 20.0.0.2 (Selected)
      Packet matches: 50 frames 5100 bytes
DELLSONiC#

 

Hvad hvis det næste hop er nede.

Overvej det næste hop 20.0.0.2 er nede. Se nedenstående output. Vi kan se fra vise service-policy interface Eth 1/1 og vise service-policy policy-map FORWARD_TO_SERVER. 20.0.0.2 mangler "(valgt)", mens 30.0.0.2, som kan nås, har "(valgt)".

Her øges tællerne (pakkekamp og ramme), men pakken falder, da næste hop ikke er tilgængelig.

DELLSONiC# show service-policy policy-map FORWARD_TO_SERVER
Eth1/1
  Policy FORWARD_TO_SERVER type forwarding at ingress
  Description:
    Flow MATCH_IP_OF_SERVER-2 at priority 100 (Active)
      Description:
      set ip nexthop 30.0.0.2 (Selected)
      Packet matches: 616 frames 62832 bytes
    Flow MATCH_IP_OF_SERVER-1 at priority 100 (Active)
      Description:
      set ip nexthop 20.0.0.2                          ====>Selected missing
      Packet matches: 50 frames 5100 bytes

30.0.0.2 er tilgængelig og valgt. 20.0.0.2 kan ikke nås og mangler derfor valgt.

DELLSONiC# show service-policy interface Eth 1/1
Eth1/1
  Policy FORWARD_TO_SERVER type forwarding at ingress
  Description:
    Flow MATCH_IP_OF_SERVER-2 at priority 100 (Active)
      Description:
      set ip nexthop 30.0.0.2 (Selected)
      Packet matches: 616 frames 62832 bytes
    Flow MATCH_IP_OF_SERVER-1 at priority 100 (Active)
      Description:
      set ip nexthop 20.0.0.2                          ====>Selected missing
      Packet matches: 50 frames 5100 bytes

受影响的产品

Enterprise SONiC Distribution, PowerSwitch S5212F-ON, PowerSwitch S5224F-ON, PowerSwitch S5232F-ON, PowerSwitch S5248F-ON, PowerSwitch S5296F-ON, PowerSwitch Z9264F-ON, PowerSwitch Z9432F-ON
文章属性
文章编号: 000222385
文章类型: How To
上次修改时间: 07 3月 2024
版本:  4
从其他戴尔用户那里查找问题的答案
支持服务
检查您的设备是否在支持服务涵盖的范围内。