使用 IPv6 地址从本地主机访问 Google API

1. 简介

通过 Cloud VPN 隧道或 Cloud Interconnect VLAN 连接路由流量,本地主机的专用 Google 访问通道提供了一种让本地系统可以连接到 Google API 和服务的方法。本地主机的专用 Google 访问通道是通过互联网连接到 Google API 和服务的替代方案。

本地主机的专用 Google 访问通道要求您将对 Google API 的请求定向到虚拟 IP 地址 (VIP)。对于 IPv6,使用以下 IP 地址:

  • 对于 private.googleapis.com:2600:2d00:0002:2000::/64
  • 对于 restricted.googleapis.com:2600:2d00:0002:1000::/64

您选择的 VIP 决定了您可以访问哪些服务。在此 Codelab 中,我们将使用 private.googleapis.com。如需了解详情,请参阅网域选项

此 Codelab 介绍了如何为使用 IPv6 地址的本地主机启用专用 Google 访问通道。您将设置一个名为 on-premises-vpc 的 VPC 网络来表示本地环境。对于您的部署,本地 VPC 将不存在,而是使用混合网络连接到本地数据中心或云服务提供商。

构建内容

在此 Codelab 中,您将构建一个端到端 IPv6 网络,该网络演示了如何使用 CNAME *.googleapis.com 到 private.googleapis.com IPv6 地址 2600:2d00:0002:2000::/64 实现本地对 Cloud Storage API 的访问,如图 1 所示。

图 1

a0fc56abf24f3535.png

学习内容

  • 如何创建双栈 VPC 网络
  • 如何创建具有 IPv6 的高可用性 VPN
  • 如何更新 DNS 以访问专用 Google 访问通道
  • 如何建立和验证专用 Google 访问通道连接

所需条件

  • Google Cloud 项目

2. 准备工作

更新项目以支持 Codelab

此 Codelab 使用了 $variables 来帮助在 Cloud Shell 中实现 gcloud 配置。

在 Cloud Shell 中,执行以下操作:

gcloud config list project
gcloud config set project [YOUR-PROJECT-NAME]
projectname=YOUR-PROJECT-NAME
echo $projectname

3. 创建 transit-vpc

f6932f551b5acac0.png

创建中转 VPC 网络

在 Cloud Shell 中,执行以下操作:

gcloud compute networks create transit-vpc --project=$projectname --subnet-mode=custom --mtu=1460 --enable-ula-internal-ipv6 --bgp-routing-mode=regional

4. 创建本地网络

58d75cbc9cb20a51.png

此 VPC 网络表示本地环境。

创建本地 VPC 网络

在 Cloud Shell 中,执行以下操作:

gcloud compute networks create on-premises-vpc --project=$projectname --subnet-mode=custom --mtu=1460 --enable-ula-internal-ipv6 --bgp-routing-mode=regional

创建子网

在 Cloud Shell 中,执行以下操作:

gcloud compute networks subnets create on-premises-subnet1-us-central1 --project=$projectname --range=172.16.10.0/27 --stack-type=IPV4_IPV6 --ipv6-access-type=INTERNAL --network=on-premises-vpc --region=us-central1

5. 为 transit-vpc 和 本地-vpc 创建高可用性 VPN

为传输 VPC 创建高可用性 VPN 网关

a0fc56abf24f3535.png

每个网关创建后,系统会自动分配两个外部 IPv4 地址,每个地址对应一个网关接口。记下这些 IP 地址,以便稍后在配置步骤中使用。

在 Cloud Shell 中,创建栈类型为 IPV4_IPV6 的高可用性 VPN 网关。

gcloud compute vpn-gateways create transit-vpc-vpngw \
   --network=transit-vpc\
   --region=us-central1 \
   --stack-type=IPV4_IPV6

为本地 VPC 创建高可用性 VPN 网关

在 Cloud Shell 中,创建栈类型为 IPV4_IPV6 的高可用性 VPN 网关

gcloud compute vpn-gateways create on-premises-vpc-vpngw \
   --network=on-premises-vpc\
   --region=us-central1 \
   --stack-type=IPV4_IPV6

验证高可用性 VPN 网关创建

使用控制台,依次前往“混合连接”→“VPN”→“CLOUD VPN 网关”。

c8eed6ca929935bc.png

为 transit-vpc 创建 Cloud Router

在 Cloud Shell 中,创建位于 us-central1 中的 Cloud Router

gcloud compute routers create transit-vpc-cr-us-central1 \
   --region=us-central1 \
   --network=transit-vpc\
   --asn=65001

为本地 VPC 创建 Cloud Router

在 Cloud Shell 中,创建位于 us-central1 中的 Cloud Router

gcloud compute routers create on-premises-vpc-cr-us-central1 \
   --region=us-central1 \
   --network=on-premises-vpc \
   --asn=65002

为 transit-vpc 创建 VPN 隧道

您将在每个高可用性 VPN 网关上创建两个 VPN 隧道。

创建 VPN 隧道 0

在 Cloud Shell 中,创建 tunnel0:

gcloud compute vpn-tunnels create transit-vpc-tunnel0 \
    --peer-gcp-gateway on-premises-vpc-vpngw \
    --region us-central1 \
    --ike-version 2 \
    --shared-secret [ZzTLxKL8fmRykwNDfCvEFIjmlYLhMucH] \
    --router transit-vpc-cr-us-central1 \
    --vpn-gateway transit-vpc-vpngw \
    --interface 0

创建 VPN 隧道 1

在 Cloud Shell 中,创建 tunnel1:

gcloud compute vpn-tunnels create transit-vpc-tunnel1 \
    --peer-gcp-gateway on-premises-vpc-vpngw \
    --region us-central1 \
    --ike-version 2 \
    --shared-secret [bcyPaboPl8fSkXRmvONGJzWTrc6tRqY5] \
    --router transit-vpc-cr-us-central1 \
    --vpn-gateway transit-vpc-vpngw \
    --interface 1

为本地 VPC 创建 VPN 隧道

您将在每个高可用性 VPN 网关上创建两个 VPN 隧道。

创建 VPN 隧道 0

在 Cloud Shell 中,创建 tunnel0:

gcloud compute vpn-tunnels create on-premises-tunnel0 \
    --peer-gcp-gateway transit-vpc-vpngw \
    --region us-central1 \
    --ike-version 2 \
    --shared-secret [ZzTLxKL8fmRykwNDfCvEFIjmlYLhMucH] \
    --router on-premises-vpc-cr-us-central1 \
    --vpn-gateway on-premises-vpc-vpngw \
    --interface 0

创建 VPN 隧道 1

在 Cloud Shell 中,创建 tunnel1:

gcloud compute vpn-tunnels create on-premises-tunnel1 \
    --peer-gcp-gateway transit-vpc-vpngw \
    --region us-central1 \
    --ike-version 2 \
    --shared-secret [bcyPaboPl8fSkXRmvONGJzWTrc6tRqY5] \
    --router on-premises-vpc-cr-us-central1 \
    --vpn-gateway on-premises-vpc-vpngw \
    --interface 1

验证 VPN 隧道创建

使用控制台,依次前往“混合连接”→“VPN”→“CLOUD VPN 隧道”。

85fd5aef4b2c4010.png

创建 BGP 会话

在本部分中,您将配置 Cloud Router 接口和 BGP 对等端。

创建允许 IPv6 流量的 VPN 隧道时,请在运行 add-bgp-peer 命令时指定 --enable-ipv6

为传输 VPC 创建 BGP 接口和对等互连

在 Cloud Shell 中,创建 BGP 接口:

gcloud compute routers add-interface transit-vpc-cr-us-central1 \
    --interface-name if-tunnel1-to-onpremise \
    --ip-address 169.254.1.1 \
    --mask-length 30 \
    --vpn-tunnel transit-vpc-tunnel0 \
    --region us-central1

在 Cloud Shell 中,创建 BGP 对等方:

gcloud compute routers add-bgp-peer transit-vpc-cr-us-central1 \
    --peer-name bgp-on-premises-tunnel0 \
    --interface if-tunnel1-to-onpremise \
    --peer-ip-address 169.254.1.2 \
    --peer-asn 65002 \
    --region us-central1 \
    --enable-ipv6 \
    --ipv6-nexthop-address 2600:2d00:0:3:0:0:0:1 \
    --peer-ipv6-nexthop-address 2600:2d00:0:3:0:0:0:2

在 Cloud Shell 中,创建 BGP 接口:

gcloud compute routers add-interface transit-vpc-cr-us-central1 \
    --interface-name if-tunnel2-to-onpremise \
    --ip-address 169.254.2.1 \
    --mask-length 30 \
    --vpn-tunnel transit-vpc-tunnel1 \
    --region us-central1

在 Cloud Shell 中,创建 BGP 对等方:

gcloud compute routers add-bgp-peer transit-vpc-cr-us-central1 \
    --peer-name bgp-on-premises-tunnel2 \
    --interface if-tunnel2-to-onpremise \
    --peer-ip-address 169.254.2.2 \
    --peer-asn 65002 \
    --region us-central1 \
    --enable-ipv6 \
    --ipv6-nexthop-address 2600:2d00:0:3:0:0:0:11 \
    --peer-ipv6-nexthop-address 2600:2d00:0:3:0:0:0:12

为本地 VPC 创建 BGP 接口和对等互连

在 Cloud Shell 中,创建 BGP 接口:

gcloud compute routers add-interface on-premises-vpc-cr-us-central1\
    --interface-name if-tunnel1-to-hub-vpc \
    --ip-address 169.254.1.2 \
    --mask-length 30 \
    --vpn-tunnel on-premises-tunnel0 \
    --region us-central1

在 Cloud Shell 中,创建 BGP 对等方:

gcloud compute routers add-bgp-peer on-premises-vpc-cr-us-central1 \
    --peer-name bgp-transit-vpc-tunnel0 \
    --interface if-tunnel1-to-hub-vpc \
    --peer-ip-address 169.254.1.1 \
    --peer-asn 65001 \
    --region us-central1 \
    --enable-ipv6 \
    --ipv6-nexthop-address 2600:2d00:0:3:0:0:0:2 \
    --peer-ipv6-nexthop-address 2600:2d00:0:3:0:0:0:1

在 Cloud Shell 中,创建 BGP 接口:

gcloud compute routers add-interface on-premises-vpc-cr-us-central1\
    --interface-name if-tunnel2-to-hub-vpc \
    --ip-address 169.254.2.2 \
    --mask-length 30 \
    --vpn-tunnel on-premises-tunnel1 \
    --region us-central1

在 Cloud Shell 中,创建 BGP 对等方:

gcloud compute routers add-bgp-peer  on-premises-vpc-cr-us-central1\
    --peer-name bgp-transit-vpc-tunnel1\
    --interface if-tunnel2-to-hub-vpc \
    --peer-ip-address 169.254.2.1 \
    --peer-asn 65001 \
    --region us-central1 \
    --enable-ipv6 \
    --ipv6-nexthop-address 2600:2d00:0:3:0:0:0:12 \
    --peer-ipv6-nexthop-address 2600:2d00:0:3:0:0:0:11

前往混合连接 → VPN,查看 VPN 隧道详情。

e100e31ea22c8124.png

验证 transit-vpc 是否已通过高可用性 VPN 获知 IPv4 和 IPv6 路由

由于高可用性 VPN 隧道和 BGP 会话已建立,因此 transit-vpc 会获知来自本地-vpc 的路由。使用控制台,依次前往“VPC 网络”→“VPC 网络”→“transit-vpc”→“路由”。

观察下面所示的已学习的 IPv4 和 IPv6 动态路由:

216bde7d08d75ec4.png

验证本地 VPC 是否未通过高可用性 VPN 获知路由

transit-vpc 没有子网,因此 Cloud Router 不会向本地 VPC 通告任何子网。使用控制台,依次前往“VPC 网络”→“VPC 网络”→“本地-vpc”→“路由”。

6. 宣传 IPv6 private.googleapis.com VIP

如需从本地访问专用 Google 访问通道,您需要从传输 VPC 创建自定义路由通告。IPv6 地址 2600:2d00:0002:2000:: 将通告到本地环境,并且在本地 DNS 更新后,工作负载将使用该地址访问 Google API(例如 Cloud Storage、Cloud BigQuery 和 Cloud Bigtable)。

在此 Codelab 中,您将启用对大多数 Google API 和服务的 API 访问权限,无论这些 Google API 和服务是否受 VPC Service Controls 支持。

在控制台中,依次前往“混合连接”→“Cloud Router”→“transit-vpc-cr-us-central1”,然后选择“修改”。

3e36e3b5ea741ec5.png

在“通告的路由”部分中,选择创建自定义路由选项,根据以下示例更新相应字段,选择完成,然后点击保存

9283aba7b214f70d.png

验证本地 VPC 是否正在学习 IPv6 路由

现在,IPv6 private.googleapis.com VIP 已从 transit-vpc 通告,本地-vpc 将已获知该 VIP 的 IPv6 动态路由。使用控制台,依次前往“VPC 网络”→“VPC 网络”→“本地-vpc”→“路由”。

观察从传输 VPC 通告的 IPv6 路由:

caf3b79b035b2a20.png

7. 使用专用 Google 访问通道与 Google API 建立通信

在下一部分中,我们将使用 IPv6 private.googleapis.com VIP 访问 Cloud Storage 并验证连接。为此,我们需要在本地 VPC 中执行以下操作。

  • 创建一条入站防火墙规则,以允许 Identity-Aware Proxy (IAP) 进行 SSH 访问。
  • 创建 Cloud Router 和 Cloud NAT 以下载 tcpdump 和 dnsutils。
  • 为 googleapis.com 创建专用 Cloud DNS 区域。
  • 创建 Cloud Storage 存储桶。

创建 IAP 防火墙规则

如需允许 IAP 连接到您的虚拟机实例,请创建一个防火墙规则,该规则应:

  • 适用于您希望使用 IAP 可访问的所有虚拟机实例。
  • 允许来自 IP 范围 35.235.240.0/20 的入站流量。此范围包含 IAP 用于 TCP 转发的所有 IP 地址。

在 Cloud Shell 中,创建 IAP 防火墙规则。

gcloud compute firewall-rules create ssh-iap-on-premises-vpc \
    --network on-premises-vpc \
    --allow tcp:22 \
    --source-ranges=35.235.240.0/20

Cloud Router 和 NAT 配置

在 Codelab 中,Cloud NAT 用于软件软件包安装,因为虚拟机实例没有外部 IP 地址。

在 Cloud Shell 中,创建 Cloud Router。

gcloud compute routers create on-premises-cr-us-central1-nat --network on-premises-vpc --region us-central1

在 Cloud Shell 中,创建 NAT 网关。

gcloud compute routers nats create on-premises-nat-us-central1 --router=on-premises-cr-us-central1-nat --auto-allocate-nat-external-ips --nat-all-subnet-ip-ranges --region us-central1

创建测试实例,即本地测试箱

创建测试实例,用于测试和验证与 IPv6 private.googleapis.com VIP 的连接。

在 Cloud Shell 中,创建实例。

gcloud compute instances create on-premises-testbox \
    --project=$projectname \
    --machine-type=e2-micro \
    --stack-type=IPV4_IPV6 \
    --image-family debian-10 \
    --no-address \
    --image-project debian-cloud \
    --zone us-central1-a \
    --subnet=on-premises-subnet1-us-central1 \
    --metadata startup-script="#! /bin/bash
      sudo apt-get update
      sudo apt-get install tcpdump -y
      sudo apt-get install dnsutils -y"

创建 Cloud DNS 专用区域

我们将使用 Cloud DNS 为 *.googleapis.com 创建专用可用区和记录,以下是所需步骤。

在 Cloud Shell 中,创建专用 DNS 区域 v6-googleapis.com。

gcloud dns --project=$projectname managed-zones create v6-googleapis --description="" --dns-name="googleapis.com." --visibility="private" --networks="on-premises-vpc"

在 Cloud Shell 中,为 private.googleapis.com 创建 AAAA 记录,指向 IPv6 地址 2600:2d00:0002:2000::

gcloud dns --project=$projectname record-sets create private.googleapis.com. --zone="v6-googleapis" --type="AAAA" --ttl="300" --rrdatas="2600:2d00:0002:2000::"

在 Cloud Shell 中,创建一个 CNAME,使 *.googleapis.com 指向 private.googleapis.com。

gcloud dns --project=$projectname record-sets create *.googleapis.com. --zone="v6-googleapis" --type="CNAME" --ttl="300" --rrdatas="private.googleapis.com."

验证 Cloud DNS 专用区域

依次前往“网络服务”→“Cloud DNS”→“v6-googleapis”。

455e355195a2a48f.png

创建 Cloud Storage 存储分区

在 Cloud Shell 中,创建一个 Cloud Storage 存储分区,并将 bucket_name 替换为您偏好的全局唯一名称;如果该名称已被使用,请尝试使用其他名称。

gsutil mb  -l us-central1 -b on gs://bucket_name

8. 使用 IPv6 地址访问和验证 Google API

在下一部分中,您将通过 SSH 连接到两个 Cloud Shell 终端。第一个终端用于使用 tcpdump 验证 IPv6 查找,第二个终端用于访问 Cloud Storage 存储分区。

在 Cloud Shell 中,通过 SSH 连接到本地测试实例 on-premises-testbox

 gcloud compute ssh --zone "us-central1-a" "on-premises-testbox" --project "$projectname"

在 Cloud Shell 终端 1 中,启动 tcpdump 并监控端口 53 的 DNS 流量。

sudo tcpdump -nn -i ens4 port 53

示例如下。

user@on-premises-testbox:~$ sudo tcpdump -nn -i ens4 port 53

选择“+”打开新的 Cloud Shell 终端。新标签页打开后,更新项目名称变量。

在 Cloud Shell 中,更新项目名称变量。

gcloud config list project
gcloud config set project [YOUR-PROJECT-NAME]
projectname=YOUR-PROJECT-NAME
echo $projectname

在 Cloud Shell 2 中,执行 SSH 命令以连接到本地测试实例 on-premises-testbox

gcloud compute ssh --zone "us-central1-a" "on-premises-testbox" --project "$projectname"

执行 dig 以验证 DNS 查找

在 Cloud Shell 终端 2 中,针对 storage.googleapis.com 执行 dig 命令。

dig AAAA storage.googleapis.com

检查 ANSWER SECTION,专用 DNS 区域 storage.googleapis.com CNAME 到 private.googleapis.com AAAA 2600:2d00:2:2000::,示例如下:

user@on-premises-testbox:~$ dig AAAA storage.googleapis.com

; <<>> DiG 9.11.5-P4-5.1+deb10u8-Debian <<>> AAAA storage.googleapis.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2782
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;storage.googleapis.com.                IN      AAAA

;; ANSWER SECTION:
storage.googleapis.com. 300     IN      CNAME   private.googleapis.com.
private.googleapis.com. 300     IN      AAAA    2600:2d00:2:2000::

;; Query time: 9 msec
;; SERVER: 169.254.169.254#53(169.254.169.254)
;; WHEN: Mon Feb 20 01:56:33 UTC 2023
;; MSG SIZE  rcvd: 101

在 Cloud Shell 终端 1 中,检查 tcpdump,进一步确认 DNS 解析为 AAAA 记录 2600:2d00:2:2000::

user@on-premises-testbox:~$ sudo tcpdump -nn -i ens4 port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens4, link-type EN10MB (Ethernet), capture size 262144 bytes
01:56:33.473208 IP 172.16.10.3.41476 > 169.254.169.254.53: 2782+ [1au] AAAA? storage.googleapis.com. (63)
01:56:33.482580 IP 169.254.169.254.53 > 172.16.10.3.41476: 2782 2/0/1 CNAME private.googleapis.com., AAAA 2600:2d00:2:2000:: (101)

根据 dig 和 tcpdump,我们可以得出结论:对 storage.googleapis.com 的 DNS 解析是通过 2600:2d00:2:2000::(private.googleapis.com 的 IPv6 地址)实现的。

执行 gsutil list 以验证对 Cloud Storage 的访问权限

在 Cloud Shell 终端 2 中,使用 gsutil 对之前创建的存储分区执行列表操作。将 bucket_name 更改为您之前创建的存储分区。

gsutil -d ls gs://bucket_name

使用 Cloud Storage 存储分区 codelab-ipv6 的示例,检查指示 storage.googleapis.comHTTP/1.1 200 OK 的调试输出。

user@on-premises-testbox:~$ gsutil -d ls gs://codelab-ipv6
***************************** WARNING *****************************
*** You are running gsutil with debug output enabled.
*** Be aware that debug output includes authentication credentials.
*** Make sure to remove the value of the Authorization header for
*** each HTTP request printed to the console prior to posting to
*** a public medium such as a forum post or Stack Overflow.
***************************** WARNING *****************************
gsutil version: 5.19
checksum: 49a18b9e15560adbc187bab09c51b5fd (OK)
boto version: 2.49.0
python version: 3.9.16 (main, Jan 10 2023, 02:29:25) [Clang 12.0.1 ]
OS: Linux 4.19.0-23-cloud-amd64
multiprocessing available: True
using cloud sdk: True
pass cloud sdk credentials to gsutil: True
config path(s): /etc/boto.cfg
gsutil path: /usr/lib/google-cloud-sdk/bin/gsutil
compiled crcmod: True
installed via package manager: False
editable install: False
shim enabled: False
Command being run: /usr/lib/google-cloud-sdk/platform/gsutil/gsutil -o GSUtil:default_project_id=myprojectid -o GoogleCompute:service_account=default -d ls gs://codelab-ipv6
config_file_list: ['/etc/boto.cfg']
config: [('working_dir', '/mnt/pyami'), ('debug', '0'), ('https_validate_certificates', 'true'), ('working_dir', '/mnt/pyami'), ('debug', '0'), ('default_project_id', 'myproject'), ('default_api_version', '2')]
DEBUG 0220 02:01:14.713012 multiprocess_file_storage.py] Read credential file
INFO 0220 02:01:14.714742 base_api.py] Calling method storage.objects.list with StorageObjectsListRequest: <StorageObjectsListRequest
 bucket: 'codelab-ipv6'
 delimiter: '/'
 maxResults: 1000
 projection: ProjectionValueValuesEnum(noAcl, 1)
 versions: False>
INFO 0220 02:01:14.715939 base_api.py] Making http GET to https://storage.googleapis.com/storage/v1/b/codelab-ipv6/o?alt=json&fields=prefixes%2Citems%2Fname%2CnextPageToken&delimiter=%2F&maxResults=1000&projection=noAcl&versions=False
INFO 0220 02:01:14.716369 base_api.py] Headers: {'accept': 'application/json',
 'accept-encoding': 'gzip, deflate',
 'content-length': '0',
 'user-agent': 'apitools Python/3.9.16 gsutil/5.19 (linux) analytics/disabled '
               'interactive/True command/ls google-cloud-sdk/416.0.0'}
INFO 0220 02:01:14.716875 base_api.py] Body: (none)
connect: (storage.googleapis.com, 443)
send: b'GET /storage/v1/b/codelab-ipv6/o?alt=json&fields=prefixes%2Citems%2Fname%2CnextPageToken&delimiter=%2F&maxResults=1000&projection=noAcl&versions=False HTTP/1.1\r\nHost: storage.googleapis.com\r\ncontent-length: 0\r\nuser-agent: apitools Python/3.9.16 gsutil/5.19 (linux) analytics/disabled
<SNIP>
reply: 'HTTP/1.1 200 OK\r\n'
header: X-GUploader-UploadID: ADPycdvunHlbN1WQBxDr_LefzLaH_HY1bBH22X7IxX9sF1G2Yo_7-nhYwjxUf6N7AF9Zg_JDwPxYtuNJiFutfd6qauEfohYPs7mE
header: Content-Type: application/json; charset=UTF-8
header: Date: Mon, 20 Feb 2023 02:01:14 GMT
header: Vary: Origin
header: Vary: X-Origin
header: Cache-Control: private, max-age=0, must-revalidate, no-transform
header: Expires: Mon, 20 Feb 2023 02:01:14 GMT
header: Content-Length: 3
header: Server: UploadServer
INFO 0220 02:01:14.803286 base_api.py] Response of type Objects: <Objects
 items: []
 prefixes: []>
user@on-premises-testbox:~$ 

在 Cloud Shell 终端 1 中,检查 tcpdump,进一步确认 DNS 解析为 AAAA 记录 2600:2d00:2:2000::

eepakmichael@on-premises-testbox:~$ sudo tcpdump -nn -i ens4 port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens4, link-type EN10MB (Ethernet), capture size 262144 bytes
02:01:14.725000 IP 172.16.10.3.48792 > 169.254.169.254.53: 7056+ A? storage.googleapis.com. (40)
02:01:14.725106 IP 172.16.10.3.48792 > 169.254.169.254.53: 50841+ AAAA? storage.googleapis.com. (40)
02:01:14.732516 IP 169.254.169.254.53 > 172.16.10.3.48792: 50841 2/0/0 CNAME private.googleapis.com., AAAA 2600:2d00:2:2000:: (90)

退出本地测试盒实例操作系统,返回到 Cloud Shell 提示。

9. 清理

在 Cloud Shell 中,执行以下操作:

gcloud compute vpn-tunnels delete transit-vpc-tunnel0 transit-vpc-tunnel1 on-premises-tunnel1   --region=us-central1 --quiet

gcloud compute vpn-tunnels delete on-premises-tunnel0 on-premises-tunnel1 --region=us-central1 --quiet

gcloud compute vpn-gateways delete on-premises-vpc-vpngw transit-vpc-vpngw --region=us-central1 --quiet

gcloud compute routers delete transit-vpc-cr-us-central1  on-premises-vpc-cr-us-central1 on-premises-cr-us-central1-nat --region=us-central1 --quiet

gcloud compute instances delete on-premises-testbox --zone=us-central1-a --quiet

gcloud compute networks subnets delete on-premises-subnet1-us-central1 --region=us-central1 --quiet

gcloud compute firewall-rules delete ssh-iap-on-premises-vpc --quiet

gcloud compute networks delete on-premises-vpc --quiet


gcloud compute networks delete transit-vpc --quiet

gsutil rb gs://bucket_name

gcloud dns record-sets delete *.googleapis.com. \
    --type=CNAME \
    --zone=v6-googleapis
        
gcloud dns record-sets delete private.googleapis.com. \
        --type=AAAA \
        --zone=v6-googleapis
        
gcloud dns managed-zones delete v6-googleapis

10. 恭喜

恭喜!您已成功配置并验证了专用 Google 访问通道 (IPv6)。

您创建了传输和本地基础架构,并创建了一个专用 DNS 区域,以使用 IPv6 解析 Google API 网域。您学习了如何使用 dig 和 Cloud Storage 测试和验证 IPv6 访问。

Cosmopup 认为 Codelab 非常棒!

8c2a10eb841f7b01.jpeg

后续操作

查看下列 Codelab…

深入阅读和视频

参考文档