Member-only story

Port forwarder to connect private cloud sql instance

Rajathithan Rajasekar
3 min readNov 20, 2019

--

Google cloud cloud sql instance private service access is implemented as a VPC peering connection between your VPC network and the google services VPC network.

The advantage of this , is your application traffic is never exposed to the internet, especially if your application resides in on-premise and wants to communicate with the cloud sql instance in GCP cloud over an interconnect or a VPN.

The challenge was to send the traffic to the DB instance where the network is VPC peered with google service network, the routes are not transitive in a VPC peered network, so a port forwarder came to the rescue . In this post we will see how to configure a port forwarder in the google compute engine instance.

Port forwarder for google cloud sql instance

Create a compute engine with Ubuntu 16.04 LTS minimial image and ip port forwarding enabled.

Enable forwarding in the kernel

sudo nano /etc/sysctl.conf#uncomment the below line
net.ipv4.ip_forward=1
====================================================================sudo su
echo 1 >| /proc/sys/net/ipv4/ip_forward
exit

Configure the IP Tables

sudo iptables -Fsudo iptables -F -t nat

--

--

Rajathithan Rajasekar
Rajathithan Rajasekar

Written by Rajathithan Rajasekar

I like to write code in Python . Interested in cloud , dataAnalysis, computerVision, ML and deepLearning. https://rajathithanrajasekar.medium.com/membership

No responses yet