How to create an outgoing connection load balancer with Google Compute Engine instance - google-compute-engine

I am trying to create an instance of an Google Compute Engine instance which can make use of multiple ip addresses to randomize the outgoing connection ip address.
Is it possible to assign multiple external ip addresses to one NIC in Google Compute Engine?
How do I setup rules so that outgoing connections use different ip addresses at random?
Thank you in advance for any assistance.

Related

Google Cloud VPS Compute Engine without a Domain

I have a VPS with Google Cloud Compute Engine which I can reach through an external IP. Next to my external IP I can reach my VPS through: 122.xx.xx.34.bc.googleusercontent.com
Is Google also offering an option to reach your website through NAME.bc.googleusercontent.com or something different than an IP.
I don't want use cheap domain name or free domain name as .tk
You can use any domain name to reach your VM instance that you run on Google Compute Engine. To do it follow steps below:
register domain name at any domain name registrar
set up DNS servers for your domain name (usually DNS hosting service provided by domain name registrar)
reserve external static IP for your VM (optional, but could be helpful)
create A record that point to external IP of your VM
wait 24-72 hours for propagating domain names
reach you service via domain name like https://domain.name
In addition, you can register your domain name at Google Domains and use Google Cloud DNS as DNS service for your domain.
You're not able to use NAME.bc.googleusercontent.com because 122.xx.xx.34.bc.googleusercontent.com is a PTR record.

Google Compute Engine How to bind new external IP address to the instance

I need to get new external IP address every time when I recreate my instance.
Current implementation may use previous ips.
How can I achieve the goal with static or ephemeral ips?
Or how can I get GCE ips pool?
I am adding bellow information with Kolban.
For the external IP Google cloud has two categories:
Static external IP addresses
Ephemeral external IP addresses
The basic difference between these two are Static one is long term assignment until hey are explicitly released from that assignment, and remain attached to a resource until they are explicitly detached. Where, Ephemeral remain attached to a VM instance only until the VM is stopped and restarted or the instance is terminated. If an instance is stopped, any ephemeral external IP addresses that are assigned to the instance are released back into the general Compute Engine pool and become available for use by other projects.
As you are wishing for the new IP address for your instance, it seems Ephemeral external IP addresses is a better choice. But you can use the Static external IP addresses to create an IP pool anyway and rotate your reserved static external IP address, which has cost implications.
The external IP are configured in the accessConfigs. You can see accessConfigs if you describe your instance by below command in cloud shell.
$ gcloud compute instances describe [INSTANCE_NAME] --zone=[ZONE]
You can create a new VM and assign a static IP with the help of the Document and below command.
$ gcloud compute instances create [INSTANCE_NAME] --private-network-ip [IP_ADDRESS]
OR
You can change or assign an external IP in your existing VM following the steps of the document (GCLOUD), which are:
[Optional] Reserve a static external IP address (if you want to have the reserve external IP and this has cost implications).
Delete existing access configs.
Add the new external IP address.
When you create a Compute Engine instance and give it a public IP address you have two choices for that IP. It can either be ephemeral ... this means that the IP address is assigned (randomly) by Google and may change the next time the Compute Engine is restarted. The alternative is that it is static. These are IP addresses that Google fixes for you and are explicitly yours until you release them. There is no charge for a static IP address if it is actively being used (eg has a Compute Engine running that is using it). However if unused, you are charged 24 cents a day (1 cent an hour).
If, for some reason, you need a new IP address for a compute engine on demand, you can reserve a new static IP address and associate that with your compute engine.
See also:
Reserving a static external IP address

Gcloud, Relase external IP

So I'm currently really new to google cloud platform and I have an issue to be solved.
I've already created a compute engine in gcloud. When it was created, it automatically assigned an external IP. I'd prefer the instances to not have any external IP.
I saw that you could put --no-address argument when creating the instances so it wouldn't be assigned an external IP, but how to release the external IP when the instance has already created?
> gcloud compute addresses list
NAME REGION ADDRESS STATUS
webserver europe-west1 130.211.70.XXX IN_USE
gcloud compute addresses delete 130....
Or use use 'network' tab in the web interface if it's a one-off need.

Hosting multiple websites in Google Compute Engine

We have 8 websites and 5 of them are small. I would like to host those 5 website in same instance but their ip must be same and static. I couldn't find a way how to allocate a static ip for each of them and how to host them in a single instance. They are PHP. Their db's are hosted in Google SQL.
Per the Google Compute Engine docs on static IP addresses:
An instance can have only one external IP address. If it already has an external IP address, you must first remove that address by deleting the old access configuration, then adding a new access configuration with the new external IP address.
That said, you don't need to have a separate static IP address per website—you can serve an arbitrary number of sites from a single VM by using a feature such as Apache virtual hosts which let you serve a different site depending on the hostname that is requested by the user.
This can be possible using Protocol Forwarding.
You can have different IP addresses for each website while using single Virtual Machine.
I had successfully hosted my 3 sites using method in past. If you need, I can write up a detail explanation on some blog.

On a google compute engine VM, is it possible to have a direct public ip instead of being behind a NAT?

Is it possible to have a public ip with direct access instead of being in NAT in a google compute engine virtual machine?
Thank you in advance.
You can have an external IP but by default the instance will have a NAT policy. If you need non-NAT'ed traffic, what you are looking for is a target instance because as stated in the documentation:
Target instances do not have a NAT policy applied to them.
After that, you can create forwarding rules to send traffic to your instance.
I hope it helps.
Static external IP addresses can be assigned to a compute engine VM.
You reserve a static external IP address in gcloud or through the API. After reserving the address, assign it to an instance during instance creation or to an existing instance. You will have to update the firewall to allow traffic on the port you want.
More info in the docs at:
https://cloud.google.com/compute/docs/instances-and-network#reservedaddress