In GCP Console, create VPC networks named vpn-1 and vpn-2 in us-east1 and europe-west1
In Cloud Shell:
gcloud compute target-vpn-gateways \
create vpn-1 \
--network vpn-network-1 \
--region us-east1
gcloud compute target-vpn-gateways \
create vpn-2 \
--network vpn-network-2 \
--region europe-west1
List VPN gateways
gcloud compute target-vpn-gateways list
gcloud compute addresses create --region us-east1 vpn-1-static-ip
gcloud compute addresses create --region europe-west1 vpn-2-static-ip
Make note of addresses
gcloud compute addresses list
For ESP, UDP500 and UDP4500 protocols
gcloud compute \
forwarding-rules create vpn-1-esp \
--region us-east1 \
--ip-protocol ESP \
--address $STATIC_IP_VPN_1 \
--target-vpn-gateway vpn-1
gcloud compute \
forwarding-rules create vpn-2-esp \
--region europe-west1 \
--ip-protocol ESP \
--address $STATIC_IP_VPN_2 \
--target-vpn-gateway vpn-2
gcloud compute \
forwarding-rules create vpn-1-udp500 \
--region us-east1 \
--ip-protocol UDP \
--ports 500 \
--address $STATIC_IP_VPN_1 \
--target-vpn-gateway vpn-1
gcloud compute \
forwarding-rules create vpn-2-udp500 \
--region europe-west1 \
--ip-protocol UDP \
--ports 500 \
--address $STATIC_IP_VPN_2 \
--target-vpn-gateway vpn-2
gcloud compute \
forwarding-rules create vpn-1-udp4500 \
--region us-east1 \
--ip-protocol UDP --ports 4500 \
--address $STATIC_IP_VPN_1 \
--target-vpn-gateway vpn-1
gcloud compute \
forwarding-rules create vpn-2-udp4500 \
--region europe-west1 \
--ip-protocol UDP --ports 4500 \
--address $STATIC_IP_VPN_2 \
--target-vpn-gateway vpn-2
Verify above in VPC Network -> External IP addreses
Network 1 to network 2
gcloud compute \
vpn-tunnels create tunnel1to2 \
--peer-address $STATIC_IP_VPN_2 \
--region us-east1 \
--ike-version 2 \
--shared-secret gcprocks \
--target-vpn-gateway vpn-1 \
--local-traffic-selector 0.0.0.0/0 \
--remote-traffic-selector 0.0.0.0/0
Network 2 to network 1
gcloud compute \
vpn-tunnels create tunnel2to1 \
--peer-address $STATIC_IP_VPN_1 \
--region europe-west1 \
--ike-version 2 \
--shared-secret gcprocks \
--target-vpn-gateway vpn-2 \
--local-traffic-selector 0.0.0.0/0 \
--remote-traffic-selector 0.0.0.0/0
Verify
gcloud compute vpn-tunnels list
VPN's are now peered, but there are no routes between the two yet. Run below to add
gcloud compute \
routes create route1to2 \
--network vpn-network-1 \
--next-hop-vpn-tunnel tunnel1to2 \
--next-hop-vpn-tunnel-region us-east1 \
--destination-range 10.1.3.0/24
gcloud compute \
routes create route2to1 \
--network vpn-network-2 \
--next-hop-vpn-tunnel tunnel2to1 \
--next-hop-vpn-tunnel-region europe-west1 \
--destination-range 10.5.4.0/24
Now you should be able to ping internal addresses in each VPN-network from another.