0
0
GCPcloud~10 mins

VPC peering in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - VPC peering
Create VPC Network A
Request Peering from A to B
Accept Peering in B
Peering Connection Established
Traffic Allowed Between A and B
This flow shows how two VPC networks request and accept peering to connect privately.
Execution Sample
GCP
gcloud compute networks peerings create peer-a-to-b \
  --network=vpc-a --peer-network=vpc-b

gcloud compute networks peerings create peer-b-to-a \
  --network=vpc-b --peer-network=vpc-a
Commands to create mutual VPC peering connections between two networks.
Process Table
StepActionNetwork A StateNetwork B StatePeering Status
1Create VPC Network AExists, no peeringNot createdNo peering
2Create VPC Network BExists, no peeringExists, no peeringNo peering
3Request peering from A to BPeering request sentNo peeringPending acceptance
4Accept peering in BPeering request sentPeering acceptedActive
5Create peering from B to APeering acceptedPeering request sentPending acceptance
6Accept peering in APeering acceptedPeering acceptedActive
7Peering connection establishedConnected to BConnected to AActive
8Traffic allowed between A and BCan route to BCan route to AActive
💡 Peering is active after mutual acceptance, allowing private traffic.
Status Tracker
VariableStartAfter Step 3After Step 4After Step 5After Step 6Final
Network A Peering StateNoneRequest sentRequest sentAcceptedAcceptedActive
Network B Peering StateNoneNoneAcceptedRequest sentAcceptedActive
Peering StatusNo peeringPending acceptanceActivePending acceptanceActiveActive
Key Moments - 3 Insights
Why do we need to create peering from both VPCs instead of just one?
Because VPC peering in GCP requires mutual peering connections for bidirectional communication, as shown in steps 3-6 in the execution_table.
What happens if one side does not accept the peering request?
The peering status remains pending and no traffic is allowed, as seen after step 3 before acceptance in step 4.
Does peering automatically allow all traffic between VPCs?
No, routing and firewall rules must allow traffic; peering only establishes the private connection, as implied after step 7 and 8.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the peering status after step 4?
APending acceptance
BNo peering
CActive
DDisconnected
💡 Hint
Check the 'Peering Status' column at step 4 in the execution_table.
At which step do both networks have accepted peering requests?
AStep 6
BStep 3
CStep 5
DStep 7
💡 Hint
Look at 'Network A Peering State' and 'Network B Peering State' columns in execution_table.
If Network B never accepts the peering request, what will be the final peering status?
AActive
BPending acceptance
CNo peering
DDisconnected
💡 Hint
Refer to the state after step 3 and before step 4 in execution_table.
Concept Snapshot
VPC Peering in GCP:
- Create two VPC networks.
- Request peering from one to the other.
- Accept peering on the other side.
- Repeat for mutual peering.
- Once active, private traffic can flow between VPCs.
- Routing and firewall rules must allow traffic.
Full Transcript
VPC peering connects two separate virtual networks privately. First, you create two VPCs. Then, one network requests peering to the other. The other network must accept this request. For full communication, both sides create and accept peering connections. After mutual acceptance, the peering is active, allowing private traffic between the networks. However, routing and firewall rules must be configured to permit this traffic. If one side does not accept, the peering remains pending and no connection is established.