Dell Networking SONiC: 정책 기반 라우팅을 구성하는 방법
摘要: 이 문서에서는 간단한 예제를 통해 Dell Networking SONiC에서 정책 기반 라우팅을 구성하는 방법에 대해 설명합니다.
说明
필수 구성 요소개념을 설명하기 위해 표준 인터페이스 명명을 사용하고 있습니다. Dell Networking S-Series: 문서를 참조하십시오. 기본 인터페이스 구성 - SONiC 4.0 을 참조하십시오. 인터페이스 이름 지정에 관한 자세한 내용 |
인덱스
정책 기반 라우팅이란 무엇입니까?
PBR(Policy-Based Routing)은 IP 라우팅 테이블에서 사용할 수 있는 정보를 재정의하여 패킷을 전달하는 방법을 제공합니다. 선택적으로 패킷이 서로 다른 경로를 사용하도록 하는 정책을 구현할 수 있습니다. 기존 IP 라우팅은 패킷의 대상 IP 주소만을 기반으로 패킷을 전달합니다. PBR은 TCP/UDP 포트 번호, 소스 IP 주소, DSCP 값 및 TCP 플래그와 같은 다른 기준에 따라 패킷을 전달하도록 구성할 수 있습니다. Dell SONiC은 정책 기반 라우팅을 위해 흐름 기반 서비스 정책을 사용합니다. 포워딩 정책은 패킷을 선택하고 패킷이 라우팅 및 포워딩 테이블에 의해 결정된 경로를 우회하여 미리 결정된 다음 홉 또는 인터페이스로 포워딩되도록 하는 작업을 설정하는 클래스 맵으로 구성됩니다. 동일한 정책에서 여러 일치 및 송신 인터페이스 또는 넥스트 홉 값을 정의할 수 있습니다. 스위치 또는 라우팅된 트래픽에 포워딩 정책을 적용할 수 있습니다. 트래픽은 인그레스 인터페이스 또는 다른 VRF에서 사용하는 것과 동일한 VRF로 라우팅할 수 있습니다.
정책 기반 라우팅을 사용하여 동등한 액세스, 프로토콜 감지 라우팅, 소스 감지 라우팅, 배치 트래픽과 대화형 비교 기반 라우팅 및 전용 링크 기반 라우팅을 제공합니다. 정책 기반 라우팅은 대상 라우팅보다 패킷 라우팅을 위한 더 유연한 메커니즘입니다.
정책 기반 라우팅 구성 단계
Dell SONiC은 트래픽을 분류하고 선택한 트래픽에 IP 다음 홉 설정과 같은 전달 작업을 적용하는 모듈형 프레임워크를 제공하여 PBR을 구현합니다.
PBR을 구성하려면 다음을 수행합니다.
- 패킷 헤더에서 ACL 또는 L2, L3 또는 L4 필드를 사용하여 정책 기반 라우팅을 위한 트래픽을 분류(선택)합니다.
- 정책 맵에서 분류된 각 플로우에서 수행할 전달 작업을 구성합니다.
- 인그레스 인터페이스에 포워딩 정책 적용 - 모든 스위치 인터페이스, 지정된 인터페이스, VLAN 또는 포트 채널에서 전역적으로 적용됩니다.

참고: In Dell SONiC:
- 수신 트래픽이 interface/vlan/portchannel/globally의 정책 맵에 적용된 명령문에서 일치하는 항목을 찾지 못하면 표준 경로 테이블에 따라 전달합니다.
- 포워딩 정책은 ingress 인터페이스에서만 지원됩니다.
- 전달 정책은 선택한 트래픽만 전달할 수 있습니다. 트래픽을 트래핑, 전환 또는 CPU로 라우팅할 수 없습니다.
- next-hop 및 next-hop-group 작업이 포함된 포워딩 정책은 라우팅된 L3 트래픽에만 적용됩니다.
- 이더넷 또는 포트 채널 송신 인터페이스를 사용하는 포워딩 정책은 스위치드 L2 트래픽에만 적용됩니다.
- 전달 정책은 CPU로 향하는 트래픽(대상 IP 주소가 스위치 주소와 동일함) 또는 CPU에 트랩된 트래픽에는 적용되지 않습니다.
- 모든 인터페이스에 포워딩 정책을 전역적으로 적용할 때 정책 맵에서 명령을 사용하여 기본이 아닌 VRF를 설정하지 않는 한 넥트 홉은 기본 VRF에 있어야 set {ip | ipv6} next-hop ip-address vrf vrf-name.
구성 구문
트래픽 분류를 위한 클래스 맵 구성
클래스 맵에서 다음 메서드를 사용하여 들어오는 트래픽을 분류(일치)할 수 있습니다.
- IPv4, IPv6 또는 MAC 액세스 목록 사용
- L2-L4 헤더 필드 사용
명령 구문 while Using Access list를 사용하여 클래스 맵의 트래픽과 일치시킵니다.
클래스 맵의 트래픽과 일치하도록 액세스 목록을 구성하는 경우 액세스 목록을 구성해야 합니다.
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}
L2-L4 헤더 필드를 사용하는 동안 명령 구문
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
정책 맵 구성
PBR 전달 정책은 정책 기반 라우팅을 위해 일치하는 트래픽에 대해 수행할 전달 작업을 지정합니다. 전달 정책은 다음 작업을 지원합니다.
- Set next hop - IPv4 트래픽을 IPv4 next-hop으로 라우팅합니다. IPv6 트래픽을 IPv6 넥스트 홉으로 라우팅합니다.
- Set next-hop group - 최상의 넥스트 홉 IPv4 또는 IPv6 주소를 선택할 그룹을 지정합니다.
- 인터페이스 설정 - L2 트래픽을 지정된 송신 인터페이스로 전달합니다.
- Set interface null - null 인터페이스가 설정되었거나 지정된 넥스트 홉에 연결할 수 없는 경우 또는 지정된 이그레스 인터페이스가 L2가 아닌 경우 일치하는 트래픽을 삭제합니다.
- Set replication group - RFC7690에 설명된 대로 해싱 문제를 해결하도록 설계된 애니캐스트 서버로 트래픽을 복제하는 데 사용됩니다.
명령 구문
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}
서비스 정책 구성(인터페이스에 정책 맵 적용)
인터페이스 또는 하위 인터페이스에서:
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}
VLAN 인터페이스:
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# interface Vlan {vlan-id}
DELLSONiC(conf-if-Vlan)# service-policy type forwarding in {policy-map-name}
포트 채널 인터페이스에서
admin@DELLSONiC:~$ sonic-cli
DELLSONiC# configure
DELLSONiC(config)# interface PortChannel {portchannel-number}
DELLSONiC(conf-if-po)# service-policy type forwarding in {policy-map-name}
모든 스위치 인터페이스에서 전역적으로
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}
확인
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
샘플 구성
다음 토폴로지를 살펴보겠습니다.

DELLSONiC에는 50.0.0.0/24 및 60.0.0.0/24로 연결되는 경로가 없습니다.
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
목표:
서버 팜 50.0.0.0/24에 대한 트래픽은 다음 홉 20.0.0.2로 라우팅됩니다. 서버 팜 60.0.0.0/24에 대한 트래픽은 다음 홉 30.0.0.2로 라우팅됩니다.
구성
클래스 맵을 구성해 보겠습니다. 여기서는 다양한 매개변수를 기반으로 트래픽을 분류합니다.
클래스 맵 MATCH_IP_OF_SERVER-1 일치 기준은 DST-IP 50.0.0.0/24입니다.
클래스 맵에서 MATCH_IP_OF_SERVER-2, 일치 기준은 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#
Policy Map을 구성해 보겠습니다.
여기서는 트래픽이 조건과 일치하는 경우 수행할 다음 조치를 정의합니다. 이 경우 트래픽이 특정 대상 IP 주소와 일치하면 특정 다음 홉 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)#
정책 맵을 서비스 정책으로 인터페이스 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
구성 확인
클래스 맵 구성을 확인해 보겠습니다. 여기에서 다음을 확인할 수 있습니다. MATCH_IP_OF_SERVER-1 일치 기준은 DST-IP 50.0.0.0/24입니다. 클래스 맵에서 MATCH_IP_OF_SERVER-2, 일치 기준은 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#
정책 맵은 클래스 맵으로 분류된 트래픽의 다음 홉이 무엇인지 정의합니다.
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#
서비스 정책은 정책 맵을 적용할 위치를 정의합니다.
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#
다음 홉이 다운되면 어떻게 될까요?
다음 홉 20.0.0.2가 다운되었다고 가정합니다. 아래 출력을 참조하십시오. show에서 service-policy interface Eth 1/1 및 show service-policy policy-map을 볼 수 있습니다. FORWARD_TO_SERVER. 20.0.0.2에는 "(선택됨)"이 누락되고 연결 가능한 30.0.0.2에는 "(선택됨)"이 있습니다.
여기서 카운터(패킷 일치 및 프레임)는 증가하지만 다음 홉에 연결할 수 없으므로 패킷이 삭제됩니다.
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에 연결할 수 있고 선택되어 있는지 확인합니다. 20.0.0.2에 연결할 수 없으므로 selected가 누락되었습니다.
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