0

I am building an application in GCP using CentOS7. The CentOS7 server has a GRE tunnel (gre1) to a server on premise.

Out of the box, the CentOS7 instance comes with a default route via eth0. To make my application work correctly I modify the CentOS route table.

ip route x.x.x.x/32 (my public) via 10.0.0.1 dev eth0 ip route default replace 0.0.0.0/0 via 172.16.0.1 dev gre1

These new routes allow me to maintain an ssh connection with the server while the server it's has a default route sending all traffic down the GRE tunnel. This works great... until I reboot.

When I reboot I lose all network connectivity to/from the CentOS7 instance.

This approach works fine on AWS and Azure servers, but GCP seems to be different

How can I change the default route on a GCP CentOS7 instance?

Thank you.

1 Answer 1

0

There is no way to set up your desired configuration using routing configuration on the hosts. Instead you need to configure routing in GCE itself, as described here1. Conceptually you can think of this as configuring the routing table on the gateway. You don't need any additional configuration on the hosts because as explained above, they send all outgoing packets to the gateway.

If you really need to make your application work by using specific route table in your VM configuration, then you might create a startup-script and add the "ip route x.x.x.x/32 (my public) via 10.0.0.1 dev eth0 ip route default replace 0.0.0.0/0 via 172.16.0.1 dev gre1" line there. In this way, any time server is rebooted, your VM Instance should take that route configuration. Additional information about startup-scrips can be found in this link2.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .