VPC Networking
VPC Networking
gcloud compute networks create NAME --project=qwiklabs-gcp-02-a4fc478e2e74 --subnet-mode=custom --mtu=1460 --bgp-routing-mode=regional$gcloud compute networks subnets create NAME --project=qwiklabs-gcp-02-a4fc478e2e74 --range=IP_RANGE --network=NAME --region=REGION
gcloud compute networks create privatenet --subnet-mode=custom
Created [https://www.googleapis.com/compute/v1/projects/id/global/networks/privatenet].NAME: privatenetSUBNET_MODE: CUSTOMBGP_ROUTING_MODE: REGIONALIPV4_RANGE:GATEWAY_IPV4:Instances on this network will not be reachable until firewall rulesare created. As an example, you can allow all internal traffic betweeninstances as well as SSH, RDP, and ICMP by running:$ gcloud compute firewall-rules create <FIREWALL_NAME> --network privatenet --allow tcp,udp,icmp --source-ranges <IP_RANGE>$ gcloud compute firewall-rules create <FIREWALL_NAME> --network privatenet --allow tcp:22,tcp:3389,icmp
gcloud compute networks subnets create privatesubnet-us --network=privatenet --region=us-central1 --range=172.16.0.0/24
$ gcloud compute networks subnets create privatesubnet-us --network=privatenet --region=us-central1 --range=172.16.0.0/24Created [https://www.googleapis.com/compute/v1/projects/{ID}/regions/us-central1/subnetworks/privatesubnet-us].NAME: privatesubnet-usREGION: us-central1NETWORK: privatenetRANGE: 172.16.0.0/24STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:
gcloud compute networks subnets create privatesubnet-eu --network=privatenet --region=europe-west1 --range=172.20.0.0/20
CreatedNAME: privatesubnet-euREGION: europe-west1NETWORK: privatenetRANGE: 172.20.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:
gcloud compute networks list
gcloud compute networks listNAME: managementnetSUBNET_MODE: CUSTOMBGP_ROUTING_MODE: REGIONALIPV4_RANGE:GATEWAY_IPV4:NAME: mynetworkSUBNET_MODE: CUSTOMBGP_ROUTING_MODE: REGIONALIPV4_RANGE:GATEWAY_IPV4:NAME: privatenetSUBNET_MODE: CUSTOMBGP_ROUTING_MODE: REGIONALIPV4_RANGE:GATEWAY_IPV4:
gcloud compute networks list
gcloud compute networks listNAME: managementnetSUBNET_MODE: CUSTOMBGP_ROUTING_MODE: REGIONALIPV4_RANGE:GATEWAY_IPV4:NAME: mynetworkSUBNET_MODE: CUSTOMBGP_ROUTING_MODE: REGIONALIPV4_RANGE:GATEWAY_IPV4:NAME: privatenetSUBNET_MODE: CUSTOMBGP_ROUTING_MODE: REGIONALIPV4_RANGE:GATEWAY_IPV4:student_00_9ba26ddd28ee@cloudshell:~ (qwiklabs-gcp-02-a4fc478e2e74)$ gcloud compute networks subnets list --sort-by=NETWORKNAME: managementsubnet-usREGION: us-central1NETWORK: managementnetRANGE: 10.130.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: us-central1NETWORK: mynetworkRANGE: 10.128.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: europe-west1NETWORK: mynetworkRANGE: 10.132.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: us-west1NETWORK: mynetworkRANGE: 10.138.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-east1NETWORK: mynetworkRANGE: 10.140.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: us-east1NETWORK: mynetworkRANGE: 10.142.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-northeast1NETWORK: mynetworkRANGE: 10.146.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-southeast1NETWORK: mynetworkRANGE: 10.148.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: us-east4NETWORK: mynetworkRANGE: 10.150.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: australia-southeast1NETWORK: mynetworkRANGE: 10.152.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: europe-west2NETWORK: mynetworkRANGE: 10.154.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: europe-west3NETWORK: mynetworkRANGE: 10.156.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: southamerica-east1NETWORK: mynetworkRANGE: 10.158.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-south1NETWORK: mynetworkRANGE: 10.160.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: northamerica-northeast1NETWORK: mynetworkRANGE: 10.162.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: europe-west4NETWORK: mynetworkRANGE: 10.164.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: europe-north1NETWORK: mynetworkRANGE: 10.166.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: us-west2NETWORK: mynetworkRANGE: 10.168.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-east2NETWORK: mynetworkRANGE: 10.170.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: europe-west6NETWORK: mynetworkRANGE: 10.172.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-northeast2NETWORK: mynetworkRANGE: 10.174.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-northeast3NETWORK: mynetworkRANGE: 10.178.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: us-west3NETWORK: mynetworkRANGE: 10.180.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: us-west4NETWORK: mynetworkRANGE: 10.182.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-southeast2NETWORK: mynetworkRANGE: 10.184.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: europe-central2NETWORK: mynetworkRANGE: 10.186.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: northamerica-northeast2NETWORK: mynetworkRANGE: 10.188.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: asia-south2NETWORK: mynetworkRANGE: 10.190.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: australia-southeast2NETWORK: mynetworkRANGE: 10.192.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: mynetworkREGION: southamerica-west1NETWORK: mynetworkRANGE: 10.194.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: privatesubnet-usREGION: us-central1NETWORK: privatenetRANGE: 172.16.0.0/24STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:NAME: privatesubnet-euREGION: europe-west1NETWORK: privatenetRANGE: 172.20.0.0/20STACK_TYPE: IPV4_ONLYIPV6_ACCESS_TYPE:IPV6_CIDR_RANGE:EXTERNAL_IPV6_CIDR_RANGE:
Friewall
|--|--|
|Property |Value (type value or select option as specified)|
|Name| managementnet-allow-icmp-ssh-rdp|
|Network| managementnet|
|Targets| All instances in the network|
|Source filter |IPv4 Ranges|
|Source IPv4 ranges |0.0.0.0/0|
|Protocols and ports| Specified protocols and ports|
Equivalent Command line.
gcloud compute --project=qwiklabs-gcp-02-a4fc478e2e74 firewall-rules create managementnet-allow-icmp-ssh-rdp --direction=INGRESS --priority=1000 --network=managementnet --action=ALLOW --rules=tcp:22,tcp:3389,icmp --source-ranges=0.0.0.0/0
Create the firewall rules for privatenet
gcloud compute firewall-rules create privatenet-allow-icmp-ssh-rdp --direction=INGRESS --priority=1000 --network=privatenet --action=ALLOW --rules=icmp,tcp:22,tcp:3389 --source-ranges=0.0.0.0/0
gcloud compute firewall-rules create privatenet-allow-icmp-ssh-rdp --direction=INGRESS --priority=1000 --network=privatenet --action=ALLOW --rules=icmp,tcp:22,tcp:3389 --source-ranges=0.0.0.0/0Creating firewall...working..Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-02-a4fc478e2e74/global/firewalls/privatenet-allow-icmp-ssh-rdp].Creating firewall...done.NAME: privatenet-allow-icmp-ssh-rdpNETWORK: privatenetDIRECTION: INGRESSPRIORITY: 1000ALLOW: icmp,tcp:22,tcp:3389DENY:
gcloud compute firewall-rules list --sort-by=NETWORK
NAME: managementnet-allow-icmp-ssh-rdpNETWORK: managementnetDIRECTION: INGRESSPRIORITY: 1000ALLOW: tcp:22,tcp:3389,icmpDENY:DISABLED: FalseNAME: privatenet-allow-icmp-ssh-rdpNETWORK: privatenetDIRECTION: INGRESSPRIORITY: 1000ALLOW: icmp,tcp:22,tcp:3389DENY:DISABLED: FalseTo show all fields of the firewall, please show in JSON format: --format=jsonTo show all fields in table format, please see the examples in --help.
Create the managementnet-us-vm instance
gcloud command line
gcloud compute instances create managementnet-us-vm --project=qwiklabs-gcp-02-a4fc478e2e74 --zone=us-central1-c --machine-type=n1-standard-1 --network-interface=network-tier=PREMIUM,subnet=managementsubnet-us --metadata=enable-oslogin=true --maintenance-policy=MIGRATE --service-account=392250948586-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --create-disk=auto-delete=yes,boot=yes,device-name=managementnet-us-vm,image=projects/debian-cloud/global/images/debian-10-buster-v20220118,mode=rw,size=10,type=projects/qwiklabs-gcp-02-a4fc478e2e74/zones/us-central1-c/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any
추가 생성
gcloud compute instances create privatenet-us-vm --zone=us-central1-c --machine-type=f1-micro --subnet=privatesubnet-us --image-family=debian-10 --image-project=debian-cloud --boot-disk-size=10GB --boot-disk-type=pd-standard --boot-disk-device-name=privatenet-us-vm
목록 확인
gcloud compute instances list --sort-by=ZONE