예를 들면 다음과 같습니다. TCP 및 ICMP 플러드로부터 보호하기 위한 스테이트리스 방화벽 필터 구성
이 예는 TCP 및 ICMP 서비스 거부 공격으로부터 보호하는 무상태 방화벽 필터를 만드는 방법을 보여줍니다.
요구 사항
스테이트리스(stateless) 방화벽 필터를 구성하기 전에 디바이스 초기화를 제외한 특별한 구성은 필요하지 않습니다.
개요
이 예에서는 TCP 및 ICMP 패킷을 감시하도록 불리는 protect-RE
무상태 방화벽 필터를 만듭니다. 여기에 설명된 폴리서를 사용합니다.
tcp-connection-policer
-이 폴리서에서는 TCP 트래픽을 최대 버스트 크기가 15,000바이트인 초당 1,000,000비트로 제한합니다. 어느 한도를 초과하는 트래픽은 폐기됩니다.icmp-policer
-이 폴리서에서는 최대 버스트 크기가 15,000바이트인 1,000,000bpps로 ICMP 트래픽을 제한합니다. 어느 한도를 초과하는 트래픽은 폐기됩니다.
제한을 지정할 때 대역폭 제한은 32,000bpps에서 32,000,000,000bpps까지일 수 있으며 버스트 크기 제한은 1,500바이트에서 100,000,000바이트까지입니다. 제한을 지정할 때 다음 약어를 사용합니다. k(1,000), m(1,000,000) 및 g(1,000,000,000).
각 폴리서가 필터 용어의 동작에 통합됩니다. 이 예에는 다음 용어가 포함됩니다.
tcp-connection-term
—소스 주소가 192.168.0.0/24 또는 10.0.0.0/24인 특정 TCP 패킷을 감시합니다. 이러한 주소는 접두사trusted-addresses
목록에 정의되어 있습니다.필터링된 패킷에는 패킷이
tcp-established
포함tcp-established
되며, 일치 조건은 비트 필드 일치 조건에tcp-flags “(ack | rst)”
대한 별칭이며, 이는 TCP 연결의 첫 번째 패킷이 아니라 설정된 TCP 세션을 나타냅니다.icmp-term
-ICMP 패킷을 정책. 모든 ICMP 패킷은 카운터에서icmp-counter
계산됩니다.
명령을 사용하여 insert
방화벽 필터 내에서 용어를 이동할 수 있습니다. Junos OS CLI 사용자 가이드에 삽입을 참조하십시오.
무상태 방화벽을 인터페이스의 입력 또는 출력 측면 또는 둘 다에 적용할 수 있습니다. 디바이스로 전송되는 패킷을 필터링하려면 방화벽 필터를 라우팅 엔진 아닌 인터페이스에 적용합니다. 라우팅 엔진 시작되거나 목적지로 향하는 패킷을 필터링하려면 방화벽 필터를 루프백(lo0) 인터페이스에 적용합니다.
그림 1 은 샘플 네트워크를 보여줍니다.

이 방화벽 필터는 라우팅 엔진 트래픽을 TCP 패킷으로 제한하기 때문에 레이어 4용 다른 전송 프로토콜을 사용하는 라우팅 프로토콜은 이 필터가 활성화될 때 세션을 성공적으로 설정할 수 없습니다. 이 예는 디바이스 R1과 디바이스 R2 사이에 OSPF를 설정합니다.
CLI 빠른 구성 은(는) 의 모든 디바이스 그림 1에 대한 구성을 보여줍니다.
섹션 #configuration1102__policy-firewall-tcp-icmp-st 은 디바이스 R2의 단계를 설명합니다.
구성
절차
CLI 빠른 구성
스테이트리스(stateless) 방화벽 필터를 빠르게 구성하려면 다음 명령을 텍스트 파일로 복사하여 모든 라인브러브를 제거한 다음 명령을 CLI에 붙여 넣습니다.
디바이스 R1
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 primary set interfaces lo0 unit 0 family inet address 172.16.0.1/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.0.0.2 set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set routing-options router-id 192.168.0.1 set routing-options autonomous-system 100
디바이스 R2
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces lo0 unit 0 family inet filter input protect-RE set interfaces lo0 unit 0 family inet address 192.168.0.2/32 primary set interfaces lo0 unit 0 family inet address 172.16.0.2/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext neighbor 10.0.0.1 peer-as 100 set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set policy-options prefix-list trusted-addresses 10.0.0.0/24 set policy-options prefix-list trusted-addresses 192.168.0.0/24 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set routing-options router-id 192.168.0.2 set routing-options autonomous-system 200 set firewall family inet filter protect-RE term tcp-connection-term from source-prefix-list trusted-addresses set firewall family inet filter protect-RE term tcp-connection-term from protocol tcp set firewall family inet filter protect-RE term tcp-connection-term from tcp-established set firewall family inet filter protect-RE term tcp-connection-term then policer tcp-connection-policer set firewall family inet filter protect-RE term tcp-connection-term then accept set firewall family inet filter protect-RE term icmp-term from source-prefix-list trusted-addresses set firewall family inet filter protect-RE term icmp-term from protocol icmp set firewall family inet filter protect-RE term icmp-term then policer icmp-policer set firewall family inet filter protect-RE term icmp-term then count icmp-counter set firewall family inet filter protect-RE term icmp-term then accept set firewall policer tcp-connection-policer filter-specific set firewall policer tcp-connection-policer if-exceeding bandwidth-limit 1m set firewall policer tcp-connection-policer if-exceeding burst-size-limit 15k set firewall policer tcp-connection-policer then discard set firewall policer icmp-policer filter-specific set firewall policer icmp-policer if-exceeding bandwidth-limit 1m set firewall policer icmp-policer if-exceeding burst-size-limit 15k set firewall policer icmp-policer then discard
단계별 절차
다음 예제에서는 구성 계층에서 다양한 수준의 탐색이 필요합니다. CLI 탐색에 대한 정보는 을(를) 참조하십시오 구성 모드에서 CLI 편집기 사용.
삭제할 스테이트리스 방화벽 필터 구성 방법:
디바이스 인터페이스를 구성합니다.
[edit interfaces fe-1/2/0 unit 0 family inet ] user@R2# set address 10.0.0.2/30 [edit interfaces lo0 unit 0 family inet] user@R2# set address 192.168.0.2/32 primary user@R2# set address 172.16.0.2/32
BGP 피어링 세션을 구성합니다.
[edit protocols bgp group ext] user@R2# set type external user@R2# set export send-direct user@R2# set neighbor 10.0.0.1 peer-as 100
AS(Autonomous System) 번호와 라우터 ID를 구성합니다.
[edit routing-options] user@R2# set autonomous-system 200 user@R2# set router-id 192.168.0.2
OSPF를 구성합니다.
[edit protocols ospf area 0.0.0.0] user@R2# set interface lo0.0 passive user@R2# set interface fe-1/2/0.0
신뢰할 수 있는 주소 목록을 정의합니다.
[edit policy-options prefix-list trusted-addresses] user@R2# set 10.0.0.0/24 user@R2# set 192.168.0.0/24
직접 경로를 보급하는 정책을 구성합니다.
[edit policy-options policy-statement send-direct term 1] user@R2# set from protocol direct user@R2# set then accept
TCP 폴리서 구성합니다.
[edit firewall policer tcp-connection-policer] user@R2# set filter-specific user@R2# set if-exceeding bandwidth-limit 1m user@R2# set if-exceeding burst-size-limit 15k user@R2# set then discard
ICMP 폴리서 를 생성합니다.
[edit firewall policer icmp-policer] user@R2# set filter-specific user@R2# set if-exceeding bandwidth-limit 1m user@R2# set if-exceeding burst-size-limit 15k user@R2# set then discard
TCP 필터 규칙을 구성합니다.
[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# set from source-prefix-list trusted-addresses user@R2# set from protocol tcp user@R2# set from tcp-established user@R2# set then policer tcp-connection-policer user@R2# set then accept
ICMP 필터 규칙을 구성합니다.
[edit firewall family inet filter protect-RE term icmp-term] user@R2# set from source-prefix-list trusted-addresses user@R2# set from protocol icmp user@R2# set then policer icmp-policer user@R2# set then count icmp-counter user@R2# set then accept
필터를 루프백 인터페이스에 적용합니다.
[edit interfaces lo0 unit 0] user@R2# set family inet filter input protect-RE
결과
구성 모드에서 , , show protocols
show policy-options
, show routing-options
및 show firewall
명령을 입력show interfaces
하여 구성을 확인합니다. 출력에 의도한 구성이 표시되지 않으면 이 예의 지침을 반복하여 구성을 수정합니다.
user@R2# show interfaces fe-1/2/0 { unit 0 { family inet { address 10.0.0.2/30; } } } lo0 { unit 0 { family inet { filter { input protect-RE; } address 192.168.0.2/32 { primary; } address 172.16.0.2/32; } } }
user@R2# show protocols bgp { group ext { type external; export send-direct; neighbor 10.0.0.1 { peer-as 100; } } } ospf { area 0.0.0.0 { interface lo0.0 { passive; } interface fe-1/2/0.0; } }
user@R2# show policy-options prefix-list trusted-addresses { 10.0.0.0/24; 192.168.0.0/24; } policy-statement send-direct { term 1 { from protocol direct; then accept; } }
user@R2# show routing-options router-id 192.168.0.2; autonomous-system 200;
user@R2# show firewall family inet { filter protect-RE { term tcp-connection-term { from { source-prefix-list { trusted-addresses; } protocol tcp; tcp-established; } then { policer tcp-connection-policer; accept; } } term icmp-term { from { source-prefix-list { trusted-addresses; } protocol icmp; } then { policer icmp-policer; count icmp-counter; accept; } } } } policer tcp-connection-policer { filter-specific; if-exceeding { bandwidth-limit 1m; burst-size-limit 15k; } then discard; } policer icmp-policer { filter-specific; if-exceeding { bandwidth-limit 1m; burst-size-limit 15k; } then discard; } }
디바이스 구성이 완료되면 구성 모드에서 을(를) 입력합니다 commit
.
확인
구성이 제대로 작동하는지 확인합니다.
TCP 폴리서 확인을 위해 패킷 생성 도구를 사용할 수 있습니다. 이 작업은 여기에 표시되지 않습니다.
- 현재 상태 비저기 방화벽 필터 표시
- 텔넷을 사용하여 TCP 방화벽 필터에서 tcp 설정 조건 확인
- 텔넷을 사용하여 TCP 방화벽 필터에서 신뢰할 수 있는 접두사 조건 확인
- OSPF를 사용하여 TCP 방화벽 필터 확인
- ICMP 방화벽 필터 확인
현재 상태 비저기 방화벽 필터 표시
목적
방화벽 필터의 구성을 확인합니다.
실행
운영 모드에서 명령을 입력합니다 show firewall
.
user@R2> show firewall Filter: protect-RE Counters: Name Bytes Packets icmp-counter 0 0 Policers: Name Bytes Packets icmp-policer 0 tcp-connection-policer 0
의미
출력에는 디바이스 R2에 적용되는 필터, 카운터 및 폴리서가 표시됩니다.
텔넷을 사용하여 TCP 방화벽 필터에서 tcp 설정 조건 확인
목적
텔넷 트래픽이 예상대로 작동하는지 확인합니다.
실행
디바이스가 조건을 충족 from tcp-established
하는 호스트와의 TCP 세션만 설정할 수 있는지 확인합니다.
디바이스 R2에서 디바이스 R1과의 BGP 세션이 설정되었는지 확인합니다.
user@R2> show bgp summary | match down Groups: 1 Peers: 1 Down peers: 0
디바이스 R2에서 디바이스 R1로 텔넷.
user@R2> telnet 192.168.0.1 Trying 192.168.0.1... Connected to R1.example.net. Escape character is '^]'. R1 (ttyp4) login:
디바이스 R1에서 디바이스 R2로 텔넷.
user@R1> telnet 192.168.0.2 Trying 192.168.0.2... telnet: connect to address 192.168.0.2: Operation timed out telnet: Unable to connect to remote host
디바이스 R2에서 일치 조건을 비활성화합니다
from tcp-established
.[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# deactivate from tcp-established user@R2# commit
디바이스 R1에서 텔넷에서 디바이스 R2로 다시 시도합니다.
user@R1> telnet 192.168.0.1 Trying 192.168.0.2... Connected to R2.example.net. Escape character is '^]'. R2 (ttyp4) login:
의미
다음 정보를 확인합니다.
예상대로 BGP 세션이 설정됩니다.
from tcp-established
일치 조건은 BGP 세션 설정은 차단할 것으로 예상되지 않습니다.디바이스 R2에서 디바이스 R1로 텔넷을 사용할 수 있습니다. 디바이스 R1에는 방화벽 필터가 구성되어 있지 않으므로 이것은 예상되는 동작입니다.
디바이스 R1에서 디바이스 R2로 텔넷할 수 없습니다. Telnet은 TCP를 전송 프로토콜로 사용하므로 이 결과는 놀랍습니다. 텔넷 연결이 부족한 원인은 일치 조건입니다
from tcp-established
. 이 일치 조건은 디바이스 R2에서 허용되는 TCP 트래픽 유형을 제한합니다. 이 일치 조건이 비활성화되면 텔넷 세션이 성공적으로 수행됩니다.
텔넷을 사용하여 TCP 방화벽 필터에서 신뢰할 수 있는 접두사 조건 확인
목적
텔넷 트래픽이 예상대로 작동하는지 확인합니다.
실행
디바이스가 신뢰할 수 있는 소스 주소 중 하나와 일치하는 IP 주소의 호스트를 가진 텔넷 세션만 설정할 수 있는지 확인합니다. 예를 들어 신뢰할 수 있는 주소 접두사 중 하나를 사용하여 다른 호스트의 명령을 사용하여 디바이스 telnet
에 로그인합니다. 또한 신뢰할 수 없는 소스 주소를 가진 텔넷 세션이 차단되는지 확인합니다.
디바이스 R1에서 신뢰할 수 없는 소스 주소에서 디바이스 R2로 텔넷을 연결합니다.
user@R1> telnet 172.16.0.2 source 172.16.0.1 Trying 172.16.0.2... ^C
디바이스 R2에서 신뢰할 수 있는 접두사 목록에 172.16/16을 추가합니다.
[edit policy-options prefix-list trusted-addresses] user@R2# set 172.16.0.0/16 user@R2# commit
디바이스 R1에서 텔넷에서 디바이스 R2로 다시 시도합니다.
user@R1> telnet 172.16.0.2 source 172.16.0.1 Trying 172.16.0.2... Connected to R2.example.net. Escape character is '^]'. R2 (ttyp4) login:
의미
다음 정보를 확인합니다.
디바이스 R1에서 신뢰할 수 없는 소스 주소를 사용하여 디바이스 R2로 텔넷할 수 없습니다. 172.16/16 접두사가 신뢰할 수 있는 접두사 목록에 추가된 후 소스 주소 172.16.0.1의 텔넷 요청이 수락됩니다.
OSPF 세션 설정이 차단됩니다. OSPF는 TCP를 전송 프로토콜로 사용하지 않습니다.
from protocol tcp
일치 조건이 비활성화되면 OSPF 세션 설정이 차단되지 않습니다.
OSPF를 사용하여 TCP 방화벽 필터 확인
목적
OSPF 트래픽이 예상대로 작동하는지 확인합니다.
실행
디바이스가 OSPF 연결을 설정할 수 없는지 확인합니다.
디바이스 R1에서 OSPF 세션을 확인합니다.
user@R1> show ospf neighbor Address Interface State ID Pri Dead 10.0.0.2 fe-1/2/0.0 Init 192.168.0.2 128 34
디바이스 R2에서 OSPF 세션을 확인합니다.
user@R2> show ospf neighbor
디바이스 R2에서 일치 조건을 제거합니다
from protocol tcp
.[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# deactivate from protocol user@R2# commit
디바이스 R1에서 OSPF 세션을 다시 확인합니다.
user@R1> show ospf neighbor Address Interface State ID Pri Dead 10.0.0.2 fe-1/2/0.0 Full 192.168.0.2 128 36
디바이스 R2에서 OSPF 세션을 다시 확인합니다.
user@R2> show ospf neighbor Address Interface State ID Pri Dead 10.0.0.1 fe-1/2/0.0 Full 192.168.0.1 128 39
의미
다음 정보를 확인합니다.
OSPF 세션 설정이 차단됩니다. OSPF는 TCP를 전송 프로토콜로 사용하지 않습니다.
from protocol tcp
일치 조건이 비활성화되면 OSPF 세션 설정이 성공적으로 수행됩니다.
ICMP 방화벽 필터 확인
목적
ICMP 패킷이 폴리딩 및 카운트되고 있는지 확인합니다. 또한 요청이 신뢰할 수 없는 소스 주소에서 유래할 때 핑 요청이 삭제되는지 확인합니다.
실행
이전 확인 단계에서 변경한 구성을 실행 취소합니다.
TCP 방화벽 설정을 다시 활성화하고 신뢰할 수 있는 172.16/16 소스 주소를 삭제합니다.
[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# activate from protocol user@R2# activate from tcp-established [edit policy-options prefix-list trusted-addresses] user@R2# delete 172.16.0.0/16 user@R2# commit
디바이스 R1에서 디바이스 R2에서 루프백 인터페이스를 ping합니다.
user@R1> ping 192.168.0.2 rapid count 600 size 2000 PING 192.168.0.2 (192.168.0.2): 2000 data bytes !!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!! --- 192.168.0.2 ping statistics --- 600 packets transmitted, 536 packets received, 10% packet loss pinground-trip min/avg/max/stddev = 2.976/3.405/42.380/2.293 ms
디바이스 R2에서 방화벽 통계를 확인합니다.
user@R2> show firewall Filter: protect-RE Counters: Name Bytes Packets icmp-counter 1180804 1135 Policers: Name Bytes Packets icmp-policer 66 tcp-connection-policer 0
디바이스 R1의 신뢰할 수 없는 소스 주소에서 디바이스 R2의 루프백 인터페이스에 핑 요청을 보냅니다.
user@R1> ping 172.16.0.2 source 172.16.0.1 PING 172.16.0.2 (172.16.0.2): 56 data bytes ^C --- 172.16.0.2 ping statistics --- 14 packets transmitted, 0 packets received, 100% packet loss
의미
다음 정보를 확인합니다.
핑 출력은 10% 패킷 손실이 발생하고 있음을 보여줍니다.
ICMP 패킷 카운터가 증가하며 icmp-policer가 증가합니다.
디바이스 R2는 명령에 ICMP 응답을
ping 172.16.0.2 source 172.16.0.1
보내지 않습니다.