NSX는 보안을 위한 Firewall로 Gateway Firewall(GFW)과 Distributed Firewall 기능을 제공하고 있습니다.
이 중 Gateway Firewall이 동작하는 방식과 문제 증상을 Troubleshooting 하기 위해 필요한 자료 수집을 알아보겠습니다.
GFW는 Edge에서 제공하는 Service 중(Gateway Firewall, NAT, DHCP) 하나로, Firewall Rule은 Top Down 순서로 적용됩니다.
Firewall Rule은 Stateful과 Stateless 모두 가능하며,
Stateful은 Flow의 최초 Packet(SYN)이 수신되면 State Table에 이를 위한 Record를 생성하고 이어지는 다음 Packet들은 Firewall Rule을 확인(examine)하지 않고,
Stateless는 Flow를 위한 State가 만들어지지 않기 때문에, Logical Router를 통과하는 모든 Packet은 Firewall Rule에 대해 확인(examine) 합니다.
Stateful과 Stateless 설정은 Gateway Firewall에서 Policy를 생성할 때 Gear 버튼을 눌러서 변경 가능합니다.
Firewall Logging은 Policy 하위의 각 Rule 마다 설정 가능합니다.
각 Rule 마다 통계치도 확인 가능합니다.
Firewall Rule은 Logical Router의 Interface에 적용되며, Interface를 확인하기 위해서는 Edge에 admin 계정으로 SSH로 접속 후, Service Router(SR)에서 아래 명령어로 확인 필요합니다.
※ Firewall Rule은 BACKPLANE Interface에는 적용되지 않음
edge-node-01> get logical-routers Sun Jan 28 2024 UTC 08:07:20.333 Logical Router UUID VRF LR-ID Name Type Ports Neighbors 736a80e3-23f6-5a2d-81d6-bbefb2786666 0 0 TUNNEL 4 6/5000 4f22c0b3-4a2f-4840-a8d2-cf8c797c087b 1 1 DR-Tier0-01 DISTRIBUTED_ROUTER_TIER0 5 2/50000 1eefa746-7662-4e21-8431-39dfc1f57394 2 2 SR-Tier0-01 SERVICE_ROUTER_TIER0 6 2/50000 d533b216-a47a-4200-9eb3-007e68c3a024 4 9 SR-tier1-01 SERVICE_ROUTER_TIER1 5 2/50000 5bc895a7-8cc3-4332-9b1a-abe3bd64fa22 5 8 DR-tier1-01 DISTRIBUTED_ROUTER_TIER1 4 1/50000 96486497-be55-4cc3-8ae1-bbc7fe391d4b 6 11 SR-one-arm SERVICE_ROUTER_TIER1 5 2/50000 edge-node-01> vrf 4 edge-node-01(tier1_sr[4])> get firewall interfaces Sun Jan 28 2024 UTC 08:07:40.008 Interface : a59de12c-1aaf-4852-834a-5229ed8643b5 Type : BACKPLANE Sync enabled : true Name : bp-sr0-port VRF ID : 4 Context entity : d533b216-a47a-4200-9eb3-007e68c3a024 Context name : SR-tier1-01 Interface : c8f68ee2-6b45-4017-ba3c-1d676b05f4a6 ### <-- !! Type : UPLINK Sync enabled : true Name : Tier0-01-tier1-01-t1_lrp VRF ID : 4 Context entity : d533b216-a47a-4200-9eb3-007e68c3a024 Context name : SR-tier1-01 |
이제 Interface를 확인했으니, 해당 Inerface에 설정된 Firewall Rule 확인해보겠습니다.
edge-node-01> get firewall c8f68ee2-6b45-4017-ba3c-1d676b05f4a6 ruleset rules Sun Jan 28 2024 UTC 08:10:02.331 DNAT rule count: 0 SNAT rule count: 0 Firewall rule count: 2 Rule ID : 1005 Rule : inout protocol any from any to any accept with log Rule ID : 1002 Rule : inout protocol any from any to any accept |
위에서 확인한 Firewall Rule을 보면, ID가 1005와 1002 인데 이는 Gateway Firewall UI에서 확인했던 Rule과 동일한 것을 알 수 있습니다.
NSX UI에서 확인했던 것처럼 Rule의 통계치도 Shell에서 확인 가능합니다.
edge-node-01> get firewall c8f68ee2-6b45-4017-ba3c-1d676b05f4a6 ruleset stats Sun Jan 28 2024 UTC 08:18:35.862 DNAT rule count: 0 SNAT rule count: 0 Firewall rule count: 2 Rule ID : 1005 Input bytes : 2000 Output bytes : 2074 Input packets : 28 Output packets : 28 Evaluations : 25 Hits : 25 Active connections : 1 L7 profile allow : 0 L7 profile reject : 0 L7 profile reject page : 0 Rule ID : 1002 Input bytes : 2045502 Output bytes : 8498019 Input packets : 39922 Output packets : 75088 Evaluations : 3469 Hits : 3407 Active connections : 0 L7 profile allow : 0 L7 profile reject : 0 L7 profile reject page : 0 |
테스트로 다음과 같이 http(tcp/80) 연결을 Drop 하도록 Rule을 생성하고 Firewall Rule Logging까지 활성화 한 후, Service Router가 위치한 Edge Node에서 /var/log/firewallpkt.log 파일을 통해 Rule과 관련된 로그를 확인할 수 있습니다.
/var/log/firewallpkt.log 2024-01-28T08:37:15.670Z edge-node-01.contoso.com NSX 5320 FIREWALL [nsx@6876 comp="nsx-edge" subcomp="datapathd" s2comp="firewallpkt" level="INFO"] <4 c8f68ee26b454017:ba3c1d676b05f4a6> INET reason-match DROP 1006 IN 48 TCP 192.168.1.2/57720->172.31.1.30/80 S 2024-01-28T08:37:15.921Z edge-node-01.contoso.com NSX 5320 FIREWALL [nsx@6876 comp="nsx-edge" subcomp="datapathd" s2comp="firewallpkt" level="INFO"] <4 c8f68ee26b454017:ba3c1d676b05f4a6> INET reason-match DROP 1006 IN 48 TCP 192.168.1.2/57721->172.31.1.30/80 S |
위 로그에 대한 해석 방법입니다.
NAT Rule 또한, Firewall Rule처럼 Service Router의 Interface에 설정됩니다.
※ NAT와 Firewall 모두 내부적으로는 동일한 Firewall Engine에 의해서 관리
NAT 로그
NAT Rule도 Firewall Rule과 마찬가지로 Logging을 활성화하면 Edge Node의 /var/log/firewallpkt.log 에서 확인 가능합니다.
/var/log/firewallpkt.log 2024-01-28T09:13:54.685Z edge-node-01.contoso.com NSX 5320 FIREWALL [nsx@6876 comp="nsx-edge" subcomp="datapathd" s2comp="firewallpkt" level="INFO"] <4 c8f68ee26b454017:ba3c1d676b05f4a6> INET reason-match RDR 536870912 IN 60 PROTO 1 192.168.1.2->172.31.1.51-OR 10.31.1.51 2024-01-28T09:14:09.979Z edge-node-01.contoso.com NSX 5320 FIREWALL [nsx@6876 comp="nsx-edge" subcomp="datapathd" s2comp="firewallpkt" level="INFO"] <4 c8f68ee26b454017:ba3c1d676b05f4a6> INET TERM RDR 536870912 IN PROTO 1 192.168.1.2->172.31.1.51-OR 10.31.1.51 |
위 로그에 대한 해석 방법입니다.
자세한 NAT 관련 테스트 내용은 아래 문서를 참고할 수 있습니다.
https://haewon83.tistory.com/179
'Networking' 카테고리의 다른 글
What does "No-neighbor" mean? (1) | 2024.02.24 |
---|---|
[NSX] Failed to bring up one of vNICs after vMotion of VM edge (0) | 2024.02.13 |
[NSX] Distributed Firewall (1) | 2024.01.26 |
[NSX] BGP Basic Check (0) | 2024.01.20 |
[NSX] Logical Routing (1) | 2024.01.15 |