按照本頁說明操作,即可查看 Compute 執行個體的網路介面、網路、子網路和 IP 位址。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Trusted Cloud by S3NS 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
- Set a default region and zone.
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
詳情請參閱 Trusted Cloud 驗證說明文件中的「Authenticate for using REST」。
必要的角色
如要取得查看執行個體網路設定所需的權限,請要求管理員授予您專案的 Compute 執行個體管理員 (v1) (
roles/compute.instanceAdmin.v1
) 或 Compute 網路管理員 (roles/compute.networkAdmin
) 身分與存取權管理角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。這個預先定義角色具備查看執行個體網路設定所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:
所需權限
如要查看執行個體的網路設定,您必須具備下列權限:
-
查看執行個體的網路設定:
compute.instances.get
在執行個體上 -
查看執行個體的 IP 位址:
compute.instances.list
在專案中
查看 IP 位址
您可以查看執行個體的內部和外部 IP 位址。IP 位址可以是 IPv4 或 IPv6 位址。
主控台
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
選用:使用「篩選」
方塊,限制顯示的執行個體數量。如果執行個體有外部 IP 位址,該位址會顯示在「外部 IP」欄下方。
如果「External IP」(外部 IP) 欄為空白,表示執行個體沒有外部 IP 位址。如果執行個體沒有外部 IP 位址,則可以指派一個。
視資料欄顯示選項而定,您可能會看到比上圖更多或更少的資料欄。
gcloud
您可以使用下列兩個指令查看執行個體的 IP 位址:
gcloud compute instances list
會顯示運算執行個體使用的所有 IP 位址,包括靜態和臨時 IP 位址。gcloud compute addresses list
會顯示指派給運算執行個體的所有保留 IP 位址。
這項工作說明如何使用
gcloud compute instances
指令查看 IP 位址。如要查看執行個體的內部和外部 IP 位址,請使用
gcloud compute instances list
指令。gcloud compute instances list
您可以附加
--filter
子句來限制指令傳回的執行個體數量,例如--filter='zone:us-central1-c'
。輸出結果會與下列內容相似:
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS webapp1 us-central1-c c3-highmem-88 true 192.0.2.11 RUNNING my-instance us-central1-c n4-standard-2 192.0.2.126 203.0.113.6 RUNNING my-dual-stack us-central1-a e2-micro 192.0.2.54 203.0.113.7 RUNNING 2001:db8:2:2:2:2:2:2/96 new-ipv6-only us-central1-a n4-standard-2 2001:db8:1:1:1:1:1:1/96 RUNNING
如果「外部 IP 位址」欄位空白,表示執行個體沒有該類型的已定義 IP 位址,您可以指派一個。
如要查看特定執行個體的內部或外部 IP 位址,請使用
gcloud compute instances describe
指令搭配--format
旗標來篩選輸出內容。內部位址
如要查看特定執行個體的內部 IP 位址,請使用下列任一指令:
IPv4 位址:
gcloud compute instances describe INSTANCE_NAME \ --zone=ZONE \ --format='get(networkInterfaces[0].networkIP)'
192.0.2.11
IPv6 位址:
gcloud compute instances describe INSTANCE_NAME \ --zone=ZONE \ --format='get(networkInterfaces[0].ipv6Address)'
2001:db8:2:2:2:2:2:2
外部地址
如要查看特定執行個體的外部 IP 位址,請使用下列任一指令:
IPv4 位址:
gcloud compute instances describe INSTANCE_NAME \ --zone=ZONE \ --format='get(networkInterfaces[0].accessConfigs[0].natIP)'
203.0.113.6
IPv6 位址:
gcloud compute instances describe INSTANCE_NAME \ --zone=ZONE \ --format='get(networkInterfaces[0].ipv6AccessConfigs[0].externalIpv6)'
2001:db8:3:3:3:3:3:3
更改下列內容:
INSTANCE_NAME
:您要查看內部或外部 IP 的執行個體名稱ZONE
:執行個體所在的可用區名稱
如果指令未傳回 IP 位址,表示執行個體未設定外部 IP 位址。
REST
對
instances.get
方法發出GET
要求。在要求中附加$fields
查詢參數,即可將輸出內容限制為僅包含感興趣的欄位。GET https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_NAME/zones/ZONE/instances/INSTANCE_NAME$fields=name,networkInterfaces.networkIP,networkInterfaces.accessConfigs.natIP,networkInterfaces.ipv6AccessConfigs.externalIpv6
更改下列內容:
PROJECT_NAME
:包含執行個體的專案名稱ZONE
:要查詢的執行個體所在區域INSTANCE_NAME
:要傳回的執行個體資源名稱
如果未設定任何 IP 位址,輸出內容就不會顯示該欄位。如果運算執行個體使用具有外部 IPv6 位址的雙堆疊網路,回應內文會類似於下列內容:
{ "name": "my-dual-stack-vm", "networkInterfaces": [ { "networkIP": "10.0.0.2", "accessConfigs": [ { "natIP": "104.155.21.204" } ], "ipv6AccessConfigs": [ { "externalIpv6": "2600:1900:4010:8b2:0:0:0:0" } ] } ] }
下列欄位包含必要資訊:
networkIP
:指派的內部 IPv4 位址natIP
:指派的外部 IPv4 位址externalIpv6
:指派的外部 IPv6 位址
Python
Java
查看執行個體的網路介面
每個運算執行個體至少有一個網路介面。您可以透過下列方式,查看執行個體網路介面的已設定屬性。
主控台
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
選用:使用「篩選」
方塊,限制顯示的執行個體數量。按一下要檢查的執行個體名稱。
在「網路」部分下方的「網路介面」中,您可以查看為執行個體建立的網路介面 (NIC)、與每個 NIC 相關聯的網路和子網路,以及指派的 IP 位址。
按一下 NIC 名稱,即可開啟「網路介面詳細資料」頁面。在這個頁面上,您可以查看 NIC 使用的防火牆和路徑,也可以對 NIC 執行連線測試。
gcloud
如要查看運算執行個體的網路介面 (NIC),請使用
gcloud compute instances describe
指令。您可以在指令中附加--format
選項,將傳回的資訊限制在特定欄位,並變更顯示方式,例如:gcloud compute instances describe INSTANCE_NAME --zone=ZONE \ --format="flattened(name,networkInterfaces[].name, networkInterfaces[].network.basename(), networkInterfaces[].stackType, networkInterfaces[].nicType)"
更改下列內容:
INSTANCE_NAME
:要查看的執行個體名稱ZONE
:要查看的執行個體所在區域
輸出結果會與下列內容相似:
name: my-multinic-vm networkInterfaces[0].name: nic0 networkInterfaces[0].network: default networkInterfaces[0].nicType: GVNIC networkInterfaces[0].stackType: IPV4_ONLY networkInterfaces[1].name: nic1 networkInterfaces[1].network: appnet-vpc-0 networkInterfaces[1].nicType: GVNIC networkInterfaces[1].stackType: IPV4_IPV6
REST
建構對
instances.get
方法的GET
要求。在要求中附加$fields
查詢參數,即可將輸出內容限制為僅networkInterfaces
屬性。GET https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_NAME/zones/ZONE/instances/INSTANCE_NAME?$fields=networkInterfaces
更改下列內容:
PROJECT_NAME
:包含執行個體的專案名稱ZONE
:要查詢的執行個體所在區域INSTANCE_NAME
:要傳回的執行個體資源名稱
輸出結果會與下列內容相似:
{ "networkInterfaces": [ { "kind": "compute#networkInterface", "network": "https://www.s3nsapis.fr/compute/v1/projects/my-project/global/networks/network-name-1", "subnetwork": "https://www.s3nsapis.fr/compute/v1/projects/my-project/regions/us-central1/subnetworks/subnet-name-1", "networkIP": "10.128.0.15", "name": "nic0", "accessConfigs": [ { "kind": "compute#accessConfig", "type": "ONE_TO_ONE_NAT", "name": "External NAT", "networkTier": "PREMIUM" } ], "fingerprint": "mBy9xvkWA9M=", "stackType": "IPV4_ONLY", "nicType": "GVNIC" }, { "kind": "compute#networkInterface", "network": "https://www.s3nsapis.fr/compute/v1/projects/my-project/global/networks/network-name-2", "subnetwork": "https://www.s3nsapis.fr/compute/v1/projects/my-project/regions/us-central1/subnetworks/subnet-name-2", "networkIP": "10.0.20.2", "name": "nic1", "accessConfigs": [ { "kind": "compute#accessConfig", "type": "ONE_TO_ONE_NAT", "name": "External NAT", "networkTier": "PREMIUM" } ], "ipv6AccessConfigs": [ { "kind": "compute#accessConfig", "type": "DIRECT_IPV6", "name": "external-ipv6", "externalIpv6": "2600:1900:4000:8447:0:0:0:0", "externalIpv6PrefixLength": 96, "publicPtrDomainName": "", "networkTier": "PREMIUM" } ], "fingerprint": "rx6hfNA94f4=", "stackType": "IPV4_IPV6", "ipv6AccessType": "EXTERNAL", "nicType": "GVNIC" } ] }
查看執行個體的 Dynamic Network Interface 設定
如果您為執行個體設定動態 NIC,可以使用下列其中一種方法查看動態 NIC 資訊。gcloud
如要查看運算執行個體的網路介面 (NIC),請使用
gcloud beta compute instances describe
指令。您可以在指令中附加--format
選項,將傳回的資訊限制在特定欄位,並變更顯示方式,例如:gcloud compute instances describe INSTANCE_NAME --zone=ZONE \ --format="flattened(name,networkInterfaces[].name, networkInterfaces[].network.basename(), networkInterfaces[].stackType, networkInterfaces[].parentNicName)"
輸出結果會與下列內容相似:
name: test-instance networkInterfaces[0].name: nic0 networkInterfaces[0].network: default networkInterfaces[0].nicType: GVNIC networkInterfaces[0].stackType: IPV4_ONLY networkInterfaces[1].name: nic1 networkInterfaces[1].network: prod-ipv6 networkInterfaces[1].nicType: GVNIC networkInterfaces[1].stackType: IPV4_IPV6 networkInterfaces[1].name: nic1.2 networkInterfaces[1].network: alt-ipv6-net networkInterfaces[1].nicType: GVNIC networkInterfaces[1].stackType: IPV4_IPV6 networkInterfaces[1].parentNicName: nic1
REST
建構對
instances.get
方法的GET
要求。在要求中附加$fields
查詢參數,即可將輸出內容限制為僅networkInterfaces
屬性。使用任何要求資料之前,請先替換以下項目:
PROJECT_ID
:包含執行個體的專案 IDZONE
:執行個體的區域INSTANCE_NAME
:執行個體的名稱
HTTP 方法和網址:
GET https://compute.s3nsapis.fr/compute/beta/projects/PROJECT_NAME/zones/ZONE/instances/INSTANCE_NAME?$fields=networkInterfaces
如要傳送要求,請展開以下其中一個選項:
您應該會收到如下的 JSON 回應:
{ "networkInterfaces": [ { "kind": "compute#networkInterface", "network": "https://www.s3nsapis.fr/compute/beta/projects/my-project/global/networks/network-name-1", "subnetwork": "https://www.s3nsapis.fr/compute/beta/projects/my-project/regions/us-central1/subnetworks/subnet-name-1", "networkIP": "10.128.0.15", "name": "nic0", "accessConfigs": [ { "kind": "compute#accessConfig", "type": "ONE_TO_ONE_NAT", "name": "External NAT", "networkTier": "PREMIUM" } ], "fingerprint": "mBy9xvkWA9M=", "stackType": "IPV4_ONLY", "nicType": "GVNIC" }, { "kind": "compute#networkInterface", "network": "https://www.s3nsapis.fr/compute/beta/projects/my-project/global/networks/network-name-2", "subnetwork": "https://www.s3nsapis.fr/compute/beta/projects/my-project/regions/us-central1/subnetworks/subnet-name-2", "networkIP": "10.0.20.2", "name": "nic1", "accessConfigs": [ { "kind": "compute#accessConfig", "type": "ONE_TO_ONE_NAT", "name": "External NAT", "networkTier": "PREMIUM" } ], "ipv6AccessConfigs": [ { "kind": "compute#accessConfig", "type": "DIRECT_IPV6", "name": "external-ipv6", "externalIpv6": "2600:1900:4000:8447:0:0:0:0", "externalIpv6PrefixLength": 96, "publicPtrDomainName": "", "networkTier": "PREMIUM" } ], "fingerprint": "rx6hfNA94f4=", "stackType": "IPV4_IPV6", "ipv6AccessType": "EXTERNAL", "nicType": "GVNIC", "parentNicName": "nic1" }, { "kind": "compute#networkInterface", "network": "https://www.s3nsapis.fr/compute/beta/projects/my-project/global/networks/network-name-3", "subnetwork": "https://www.s3nsapis.fr/compute/beta/projects/my-project/regions/us-central1/subnetworks/subnet-name-3", "networkIP": "10.0.26.2", "name": "nic1.1", "accessConfigs": [ { "kind": "compute#accessConfig", "type": "ONE_TO_ONE_NAT", "name": "External NAT", "networkTier": "PREMIUM" } ], "ipv6AccessConfigs": [ { "kind": "compute#accessConfig", "type": "DIRECT_IPV6", "name": "external-ipv6", "externalIpv6": "2600:1900:4000:8450:0:0:0:0", "externalIpv6PrefixLength": 96, "publicPtrDomainName": "", "networkTier": "PREMIUM" } ], "fingerprint": "rx6hfNA94f4=", "stackType": "IPV4_IPV6", "ipv6AccessType": "EXTERNAL", "nicType": "GVNIC", "parentNicName": "nic1" } ] }
查看網路中的所有運算執行個體
如要查看特定網路中的所有運算執行個體,請使用下列其中一種方法。
主控台
在 Trusted Cloud 控制台中,前往「VPC networks」(虛擬私有雲網路) 頁面。
選用步驟:使用「篩選」
方塊,限制顯示的電視網數量。按一下要列出運算執行個體的網路名稱。
選取「執行個體」分頁,即可查看該網路中的執行個體。
gcloud
如要查看使用特定網路的運算執行個體,請使用
gcloud compute instances list
指令。使用
--filter
旗標,只列出使用特定網路的執行個體。您也可以使用--format
標記限制結果並設定格式,例如:gcloud compute instances list \ --filter 'networkInterfaces[].network:NETWORK_NAME' \ --format="table(name:sort=1,machineType.basename(),zone.basename(),networkInterfaces[].subnetwork)"
輸出結果會與下列內容相似:
NAME: c2-tier1-multinic MACHINE_TYPE: c2-standard-30 ZONE: us-central1-c SUBNETWORK: ['https://www.s3nsapis.fr/compute/v1/projects/my-project/regions/us-central1/subnetworks/default', 'https://www.s3nsapis.fr/compute/v1/projects/my-project/regions/us-central1/subnetworks/webapps-external-subnet']
NAME: c3-with-lssd MACHINE_TYPE: c3-standard-4-lssd ZONE: us-central1-a SUBNETWORK: ['https://www.s3nsapis.fr/compute/v1/projects/my-project/regions/us-central1/subnetworks/default']
NAME: example-instance3 MACHINE_TYPE: n2-custom-2-163840-ext ZONE: us-central1-b SUBNETWORK: ['https://www.s3nsapis.fr/compute/v1/projects/my-project/regions/us-central1/subnetworks/default']
NAME: n4-test-windows MACHINE_TYPE: n4-standard-2 ZONE: us-central1-c SUBNETWORK: ['https://www.s3nsapis.fr/compute/v1/projects/my-project/regions/us-central1/subnetworks/default']判斷是否已啟用 Tier_1 網路
請使用下列其中一種方法,判斷執行個體是否已啟用各 VM 的 Tier_1 網路效能。
主控台
前往 Trusted Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
選用:使用「篩選」
方塊,限制顯示的執行個體數量。按一下要檢查的執行個體名稱。
在「Networking」(網路) 區段中,檢查「Total egress bandwidth tier」(總輸出頻寬層級) 的值:
TIER_1
:已啟用 Tier_1 網路。-
:未啟用 Tier_1 網路。
gcloud
如要查看執行個體的
networkPerformanceConfig
設定,請使用gcloud compute instances describe
指令。您可以在指令中附加--format
選項,將傳回的資訊限制在特定欄位,並變更顯示方式,例如:gcloud compute instances describe INSTANCE_NAME \ --zone=ZONE \ --format="text(name, networkPerformanceConfig)"
如果執行個體未設定 Tier_1 網路,輸出內容就不會包含
networkPerformanceConfig
欄位。如果執行個體已啟用 Tier_1 網路,輸出內容會類似如下:name: c2-tier1-multinic networkPerformanceConfig.totalEgressBandwidthTier: TIER_1
REST
建構對
instances.get
方法的GET
要求。在要求中附加$fields
查詢參數,即可將輸出內容限制為僅限name
、networkPerformanceConfig
和nicType
欄位。GET https://compute.s3nsapis.fr/compute/v1/projects/PROJECT_NAME/zones/ZONE/instances/INSTANCE_NAME?$fields=name,networkPerformanceConfig,networkInterfaces.nicType
更改下列內容:
PROJECT_NAME
:包含執行個體的專案名稱ZONE
:要查詢的執行個體所在區域INSTANCE_NAME
:要傳回的執行個體資源名稱
如果執行個體未設定 Tier_1 網路,輸出內容就不會包含
networkPerformanceConfig
欄位。如果執行個體已啟用 Tier_1 網路,輸出內容會類似如下:{ "name": "c2-tier1-multinic", "networkInterfaces": [ { "nicType": "GVNIC" }, { "nicType": "GVNIC" } ], "networkPerformanceConfig": { "totalEgressBandwidthTier": "TIER_1" } }
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-08 (世界標準時間)。"],[[["This guide details how to view network configurations, including interfaces, networks, subnets, and IP addresses for Google Cloud compute instances."],["Authentication is necessary for accessing Google Cloud services and APIs, with options provided for using the console, gcloud CLI, or REST API, and instructions given on how to complete this."],["You can view IP addresses (both internal and external, IPv4 or IPv6) for a compute instance through the Google Cloud console or using the `gcloud` command-line tool, and filter the output for specific addresses."],["Network interface details, including associated networks, subnets, and IP addresses, can be viewed via the Google Cloud console or by using the `gcloud` CLI with the `gcloud compute instances describe` command."],["You can determine whether Tier_1 networking is enabled for an instance through the Google Cloud console or the `gcloud` command, by inspecting the `networkPerformanceConfig` setting."]]],[]] -