- Create a VPC Network
- Creating firewall-rules
- Configuring network tags
- …
Create a VPC Network
Given that:
tdc-shared-services
: The Data Center shared service projecttdc-shared-vpc
: The Data Center shared Virtual Private Cloud--region
: Iowa, us-central1tdc-shared-vpc-subnet
: The Data Center shared Virtual Private Cloud SubnetMTU
: Maximum transmission unit
gcloud compute networks create tdc-shared-vpc --project=tdc-shared-services --description=The\ tdc-shared-vpc\ to\ share\ acrossing\ all\ the\ project\ in\ us-central --subnet-mode=custom --mtu=1500 --bgp-routing-mode=regional
Create subnet:
gcloud compute networks subnets create NAME --project=tdc-shared-services --range=IP_RANGE --network=tdc-shared-vpc --region=REGION
Example:
gcloud compute networks subnets create tdc-shared-vpc-subnet --project=tdc-shared-services --description=The\ tdc-shared-vpc-subnet\ on\ us-central\ -\ Iowa\ \(IA\),\ default\ IP\ range\ 10.128.0.0/20 --range=10.128.0.0/20 --network=tdc-shared-vpc --region=us-central1 --enable-private-ip-google-access
Creating firewall-rules
To create a rule that allowing the 21
port and public to the internet:
ftp-rule-allow-tcp-21
: The name of the rule0.0.0.0/0
: Source IP rangeftp-allow-tcp-21
: the network tags to be added to resourcestcp:21
: TCP/UDP following by port number
gcloud compute firewall-rules create ftp-rule-allow-tcp-21 --source-ranges 0.0.0.0/0
--target-tags nam-le-allow-tcp-21 --allow tcp:21
// Add this tag to the instance usage
gcloud compute instances add-tags catdcwebt1 --tags ftp-allow-tcp-21
Configuring network tags
Tags enable you to make firewall rules and routes applicable to specific VM instances.
Adding tags when creating a VM:
gcloud compute instances create VM_NAME --tags TAGS
Adding tags to existing VM:
gcloud compute instances add-tags VM_NAME --tags TAGS
Removing tags from existing VM:
gcloud compute instances remove-tags VM_NAME --tags TAGS
Example:
gcloud compute instances add-tags catdcwebt1 --tags ftp-allow-tcp-21
Create firewall rule
gcloud compute --project=tdc-test-311308 firewall-rules create default-allow-http --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:80 --source-ranges=0.0.0.0/0 --target-tags=http-server
gcloud compute --project=tdc-test-311308 firewall-rules create default-allow-https --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:443 --source-ranges=0.0.0.0/0 --target-tags=https-server
We will have an example to peer two VPC later.
2021/11/17 at 9:13 pm
Last modified on October 10th, 2024 at 12:35 pm
Nam Le
lequocnam
0 responds