
儘管GCP文件聲稱在製定防火牆規則時支援IPv6位址(https://cloud.google.com/vpc/docs/firewalls)我似乎無法實現它。從這個文檔:
- 防火牆規則支援 IPv4 連線。啟用了 IPv6 的 VPC 網路也支援 IPv6 連線。依位址指定入口規則的來源或出口規則的目標時,可以使用 CIDR 表示法指定 IPv4 或 IPv6 位址或區塊。
- 每個防火牆規則可以包含 IPv4 或 IPv6 範圍,但不能同時包含兩者。
但是,當我嘗試使用 IPv6 位址建立防火牆規則時,出現錯誤並且不允許我保存它,如下面的螢幕截圖所示。
上面的範例顯示了我嘗試過的兩個範例,但我已經嘗試過使用單一位址、帶或不帶 CIDR 區塊等。而且都被拒絕了。我已確認 VPC 子網路已啟用 IPv6。
我錯過了什麼嗎?
答案1
GUI 也不適合我,但我能夠使用等效的 gcloud 指令成功建立防火牆規則。
為了進行測試,我建立了一個新的 VPC、新的子網路和新的防火牆規則:
error@cloudshell:~ (strange-passage-193919)$ gcloud compute networks create ipv6test --project=strange-passage-193919 --subnet-mode=custom --mtu=1460 --bgp-routing-mode=regional
Created [https://www.googleapis.com/compute/v1/projects/strange-passage-193919/global/networks/ipv6test].
NAME SUBNET_MODE BGP_ROUTING_MODE IPV4_RANGE GATEWAY_IPV4
ipv6test CUSTOM REGIONAL
Instances on this network will not be reachable until firewall rules
are created. As an example, you can allow all internal traffic between
instances as well as SSH, RDP, and ICMP by running:
$ gcloud compute firewall-rules create <FIREWALL_NAME> --network ipv6test --allow tcp,udp,icmp --source-ranges <IP_RANGE>
$ gcloud compute firewall-rules create <FIREWALL_NAME> --network ipv6test --allow tcp:22,tcp:3389,icmp
error@cloudshell:~ (strange-passage-193919)$ gcloud compute networks subnets create ipv6test --project=strange-passage-193919 --range=10.16.0.0/20 --network=ipv6test --region=us-west2
Created [https://www.googleapis.com/compute/v1/projects/strange-passage-193919/regions/us-west2/subnetworks/ipv6test].
NAME REGION NETWORK RANGE STACK_TYPE IPV6_ACCESS_TYPE IPV6_CIDR_RANGE EXTERNAL_IPV6_CIDR_RANGE
ipv6test us-west2 ipv6test 10.16.0.0/20 IPV4_ONLY
error@cloudshell:~ (strange-passage-193919)$ gcloud compute networks subnets update ipv6test --project=strange-passage-193919 --stack-type=IPV4_IPV6 --ipv6-access-type=EXTERNAL --region=us-west2
Updated [https://www.googleapis.com/compute/v1/projects/strange-passage-193919/regions/us-west2/subnetworks/ipv6test].
error@cloudshell:~ (strange-passage-193919)$ gcloud compute --project=strange-passage-193919 firewall-rules create ruletest --direction=INGRESS --priority=1000 --network=ipv6test --action=ALLOW --rules=tcp:22 --source-ranges=2001:db8::/32
Creating firewall...⠹Created [https://www.googleapis.com/compute/v1/projects/strange-passage-193919/global/firewalls/ruletest].
Creating firewall...done.
NAME NETWORK DIRECTION PRIORITY ALLOW DENY DISABLED
ruletest ipv6test INGRESS 1000 tcp:22 False
error@cloudshell:~ (strange-passage-193919)$