Multiple IPs in a single instance of Google Compute Engine

I am trying to have my GCE instance listen on multiple IP addresses (for SEO reasons - to host multiple sites with low traffic in a single instance).

The ultimate goal: mydomain.com points to IP1, myotherdomain.es points to IP2, the GCE instance will listen on both IP1 and IP2 and accordingly serve the content.

I added a target instance pointing to my primary instance, and it managed to create a redirect rule as follows:

gcloud compute forwarding-rules create another-ip --port 80 --target-instance MY_TARGET_INSTANCE_URL 

In fact, he created an ephemeral IP address; I tried to promote it to static, but I exceeded my quota (now I am in my free trial for 2 months).

Is it correct? Will I be able to create any number of static IP addresses and point them to my only instance after the trial version is completed? I also could not find out anything about pricing: I know that the IP assigned to the active instance is free, but what about the extra ones?

Since this is a necessary configuration for the site I manage, I would like to make sure that it works before moving everything to GCE.

+5
source share
2 answers

You can get multiple external IP addresses for a single virtual machine instance with forwarding rules.

  • By default, the VM will be assigned an ephemeral external IP address, you can promote it to a static external IP address, which will remain unchanged after stopping and rebooting.
  • Additional external IP addresses must be bound to forwarding rules that point to a virtual machine. You can also use (or promote) static IP addresses.

The command you can use:

  • Create a TargetInstance for the virtual machine instance:

     gcloud compute target-instances create <target-instance-name> --instance <instance-name> --zone=<zone> 
  • Create a ForwardingRule pointing to TargetInstance:

     gcloud compute forwarding-rules create <forwarding-rule-name> --target-instance=<target-instance-name> --ip-protocol=TCP --ports=<ports> 

See Protocol Forwarding .

+5
source

I also need 2 static ips for a single engine engine instance, but the google quota does not allow this.

You can see your quotas from https://console.cloud.google.com/iam-admin/quotas

enter image description here

0
source

Source: https://habr.com/ru/post/1257974/


All Articles