이 페이지에서는 전역 네트워크 방화벽 정책과 리전 네트워크 방화벽 정책 구현 예시를 보여줍니다. 사용자가 전역 네트워크 방화벽 정책 및 리전 네트워크 방화벽 정책에 설명된 개념에 익숙하다는 가정 하에 쓰여진 내용입니다.
Virtual Private Cloud(VPC) 네트워크에 전역 네트워크 방화벽 정책 하나와 여러 리전 네트워크 방화벽 정책을 연결할 수 있습니다. 전역 네트워크 방화벽 정책은 VPC 네트워크의 모든 리전에 있는 모든 서브네트워크에 적용됩니다. 리전 네트워크 방화벽 정책은 대상 리전에 있는 VPC 네트워크의 서브네트워크에만 적용됩니다.
그림 1은 VPC 네트워크의 전역 네트워크 방화벽 정책과 리전 네트워크 방화벽 정책의 범위를 설명합니다.
그림 1. 전역 및 리전 네트워크 방화벽 정책의 범위
예시: 특정 포트를 제외한 모든 외부 연결 거부
이 사용 사례에서 전역 네트워크 방화벽 정책은 대상 포트 80, 443, 22의 연결을 제외한 외부 인터넷 소스의 모든 연결을 차단합니다. 80, 443 또는 22 이외의 포트에서 인그레스 인터넷 연결이 차단됩니다. 규칙 적용은 포트 80, 443 또는 22의 모든 연결에서 리전 네트워크 방화벽 정책에 위임됩니다.
이 예시에서는 리전 네트워크 방화벽 정책이 region-a에 적용되며 이 정책은 소스 10.2.0.0/16의 내부 트래픽과 모든 소스의 포트 443 및 80에 대한 인그레스 트래픽을 허용합니다. 그림 2는 이 사용 사례의 구성 설정을 설명합니다.
그림 2. 특정 목적지 포트를 제외한 모든 외부 연결을 거부합니다.
VM에 적용되는 유효 정책
이 섹션에서는 계층 구조에서 규칙을 평가한 후 이 예시에 적용 가능한 유효한 네트워크 방화벽 정책을 설명합니다.
인그레스 연결
10.0.0.0/8의 모든 인그레스 연결은 우선순위가 가장 높은 전역 네트워크 방화벽 정책 규칙 delegate-internal-traffic과 일치하며 전역 네트워크 방화벽 정책의 나머지 규칙을 우회합니다. 리전 네트워크 방화벽 정책 규칙에서 10.2.0.0/16의 인그레스 연결이 허용되며 나머지 연결은 묵시적 인그레스 deny 규칙에 따라 평가됩니다.
10.0.0.0/8 이외의 소스 IP 범위와 목적지 포트 22, 80, 443을 사용한 인그레스 연결은 리전 네트워크 방화벽 정책 규칙 수준으로 위임됩니다. 리전 네트워크 방화벽 정책 규칙에서 포트 80 및 443은 허용되지만 포트 22는 허용되지 않습니다.
이그레스 연결
전역 네트워크 방화벽 정책 규칙에 일치하는 항목이 없습니다. 따라서 이그레스 연결을 허용하는 암시적 시스템 규칙이 적용됩니다.
구성 방법
다음 규칙을 포함하는 전역 네트워크 방화벽 정책을 만듭니다.
gcloud compute network-firewall-policies create \
"example-firewall-policy-global" --global \
--description "Global network firewall policy with rules that apply to all VMs in the VPC network"
gcloud compute network-firewall-policies create \
example-firewall-policy-regional --region=region-a \
--description "Regional network firewall policy with rules that apply to all VMs in region-a"
리전 네트워크 방화벽 정책을 VPC 네트워크와 연결하여 특정 리전 내의 해당 네트워크 내에서 모든 VM에 대한 정책 규칙을 활성화합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eGlobal network firewall policies apply to all subnetworks in all regions of a VPC network, while regional network firewall policies apply only to subnetworks in the target region.\u003c/p\u003e\n"],["\u003cp\u003eA global network firewall policy can block all connections from external internet sources except for specified ports, delegating control of those ports to regional policies.\u003c/p\u003e\n"],["\u003cp\u003eIngress connections from specific IP ranges can be delegated by global network firewall policy rules, while connections from other sources can be directed to regional policy evaluation based on destination ports.\u003c/p\u003e\n"],["\u003cp\u003eEgress connections are allowed by default if no matching rules are found in the global network firewall policy, which implies that the implicit system rules are applied.\u003c/p\u003e\n"],["\u003cp\u003eThe provided example demonstrates how to create and associate both global and regional network firewall policies, including rules to manage ingress traffic, delegate connections, and block unwanted external connections.\u003c/p\u003e\n"]]],[],null,["# Global and regional network firewall policy examples\n\nThis page shows examples of global network firewall policy and regional network\nfirewall policy implementations. It assumes that you are familiar with the\nconcepts described in [Global network firewall policies](/firewall/docs/network-firewall-policies)\nand [Regional network firewall policies](/firewall/docs/regional-firewall-policies).\n\nYou can attach one global network firewall policy and multiple regional network\nfirewall policies to a Virtual Private Cloud (VPC) network. A global network\nfirewall policy applies to all subnetworks in all regions of the VPC\nnetwork. A regional network firewall policy applies to only the subnetworks\nof the VPC network in the target region.\n\nFigure 1 describes the scope of a global network firewall policy\nand a regional network firewall policy in a VPC network.\n[](/static/firewall/images/firewall-policies/network-firewall-policy-scope.svg) **Figure 1.** Scope of global and regional network firewall policies.\n\nExample: Deny all external connections except to specific ports\n---------------------------------------------------------------\n\nIn this use case, a global network firewall policy blocks all connections from\nexternal internet sources except for connections on destination ports `80`,\n`443`, and `22`. An ingress internet connection on ports other than `80`,\n`443`, or `22` is blocked. The rules enforcement is delegated to the regional\nnetwork firewall policy for any connections on ports `80`, `443`, or `22`.\n\nIn this example, a regional network firewall policy applies to `region-a`, which\nallows internal traffic from source `10.2.0.0/16` and ingress traffic to ports\n`443` and `80` from any source. Figure 2 describes the\nconfiguration setup for this use case.\n[](/static/firewall/images/firewall-policies/network-firewall-policy-example-01.svg) **Figure 2.** Deny all external connections except to specific destination ports.\n\n### Effective policy applied in VMs\n\nThis section describes the effective network firewall policy applicable in this\nexample after evaluating the rules across the hierarchy.\n\n**Ingress connections**\n\n- Any ingress connections from `10.0.0.0/8` match the highest priority global\n network firewall policy rule `delegate-internal-traffic` and bypass the rest\n of the rules in the global network firewall policy. In the regional network\n firewall policy rule, ingress connections from `10.2.0.0/16` are allowed, and\n the rest of the connections are evaluated against the implied ingress `deny`\n rule.\n\n- Ingress connections with a source IP range other than `10.0.0.0/8`, and\n destination ports `22`, `80`, and `443`, are delegated to the regional network\n firewall policy rule level. In the regional network firewall policy rule,\n ports `80` and `443` are allowed, but port `22` is not.\n\n**Egress connection**\n\n- There is no match across the global network firewall policy rules. Therefore, the implicit system rules apply, which allows egress connections.\n\n### How to configure\n\n1. Create a global network firewall policy that contains the following rule:\n\n ```\n gcloud compute network-firewall-policies create \\\n \"example-firewall-policy-global\" --global \\\n --description \"Global network firewall policy with rules that apply to all VMs in the VPC network\"\n ```\n2. Associate the policy with the VPC network:\n\n ```\n gcloud compute network-firewall-policies associations create \\\n --firewall-policy example-firewall-policy-global \\\n --network my-example-vpc \\\n --global-firewall-policy\n ```\n3. Add a rule to match any ingress connections from `10.0.0.0/8`:\n\n ```\n gcloud compute network-firewall-policies rules create 1000 \\\n --action goto_next \\\n --description \"delegate-internal-traffic\" \\\n --layer4-configs all \\\n --firewall-policy example-firewall-policy-global \\\n --src-ip-ranges 10.0.0.0/8 \\\n --global-firewall-policy\n ```\n4. Add a rule to delegate external traffic from specific ports:\n\n ```\n gcloud compute network-firewall-policies rules create 2000 \\\n --action goto_next \\\n --description \"delegate-external-traffic-spec-ports\" \\\n --layer4-configs tcp:80,tcp:443,tcp:22 \\\n --firewall-policy example-firewall-policy-global \\\n --src-ip-ranges 0.0.0.0/0 \\\n --global-firewall-policy\n ```\n5. Add a rule to block all remaining ingress traffic:\n\n ```\n gcloud compute network-firewall-policies rules create 3000 \\\n --action deny \\\n --description \"block-external-traffic-spec-ports\" \\\n --firewall-policy example-firewall-policy-global \\\n --src-ip-ranges 0.0.0.0/0 \\\n --layer4-configs all \\\n --global-firewall-policy\n ```\n6. Create a regional network firewall policy:\n\n ```\n gcloud compute network-firewall-policies create \\\n example-firewall-policy-regional --region=region-a \\\n --description \"Regional network firewall policy with rules that apply to all VMs in region-a\"\n ```\n7. Associate the regional network firewall policy with a VPC network\n to activate the policy rules for any VMs within that network within a specific region:\n\n ```\n gcloud compute network-firewall-policies associations create \\\n --firewall-policy example-firewall-policy-regional \\\n --network my-example-vpc \\\n --firewall-policy-region=region-a \n ```\n8. Add a rule to allow internal traffic for the regional network firewall policy:\n\n ```\n gcloud compute network-firewall-policies rules create 1000 \\\n --action allow \\\n --firewall-policy example-firewall-policy-regional \\\n --description allow-internal-traffic \\\n --direction INGRESS \\\n --src-ip-ranges 10.2.0.0/16 \\\n --layer4-configs all \\\n --firewall-policy-region=region-a \n ```\n9. Add a rule to allow external traffic from specific ports:\n\n ```\n gcloud compute network-firewall-policies rules create 2000 \\\n --action allow \\\n --firewall-policy example-firewall-policy-regional \\\n --description allow-external-traffic-spec-ports \\\n --direction INGRESS \\\n --layer4-configs=tcp:80,tcp:443 \\\n --src-ip-ranges 0.0.0.0/0 \\\n --firewall-policy-region=region-a\n ```\n\nWhat's next\n-----------\n\n- To create and modify global network firewall policies and rules, see\n [Use global network firewall policies and rules](/firewall/docs/use-network-firewall-policies).\n\n- To create and modify regional network firewall policies and rules, see\n [Use regional network firewall policies and rules](/firewall/docs/use-network-firewall-policies)."]]