简体   繁体   中英

Enable outgoing traffic on google compute engine machine without assigning an external ip

I have two machines on google compute engine,

machine 1 xxxx machine 2 yyyy

Machine 1 has an external ip address and machine 2 no.

I need from mahcine 2 consume some services on internet on port 80 and 443 using a third party library.

In GCE by default instances without an external IP addresses could not send packets outside the network

Routing Packets to the Internet

Currently, any packets sent to the Internet must be sent by an instance that has an
external IP address. If you create a route that sends packets to the Internet from a 
particular instance, that instance must also have an external IP. If you create a route 
that sends packets to the Internet gateway, but the source instance doesn't have an
external IP address, the packet will be dropped.

In machine 1 a setup a squid proxy for http and https connections but third party library does not allow to setup a proxy and do not take care about http_proxy and https_proxy variables.

Is there a way to create default gateway on machine 1 and setup in machine 2 ? Any other solution?

You can use add a route that is going to NAT the packages to your machine 1. Visit https://developers.google.com/compute/docs/networking#addingroute for more info. You will also need to configure your IP tables, so traffic gets routed to your Machine 1. You can also visit this topic at Google Groups ( https://groups.google.com/forum/#!topic/gce-discussion/EhyHCh6YkyM ) where this process is explained in more detail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM