How to add extra private IP's to a GCP instance? - google-cloud-platform

I want to add multiple routable ip addresses to an ubuntu 14.04 GCP instance. What is the simplest method for achieving this?
Note: External IP addresses are disabled on my gcp instances.
Correct me if I am wrong, but the solution described in this post that uses gcloud routes seems to change the network and firewall configuration to add extra IP addresses to instances. I am looking for a different solution.
I would like to add IP addresses to instances without changing the networks or firewalls of a gcp project at all.
I would like to add random available IP addresses on the current network of a gcp instance and avoid manually assigning an IP address or IP address range to my instances?
I am really looking for a solution that is similar to openstacks nova add-fixed-ip command that does just this. You can find a description of nova add-fixed-ip here: https://ask.openstack.org/en/question/65198/how-to-assign-static-private-ip-address-to-a-running-guest-vm/

Related

How to deal in AWS routing if we need to use a loopback interface in a EC2 instance

I am relatively new in AWS. I am trying some thing basic like this:
One Ubuntu instance is connected with a vSRX instance. Say Ubuntu instance eth1 ip is like 20.0.0.100 and vSRX corresponding interface ip is 20.0.0.101. Now I want to configure a loopback interface (its a virtual interface) inside the vSRX and assign a ip 99.99.99.99. Obviously this 99… network info is not available with AWS. My question is how can I build that knowledge in aws routing and make sure that to reach 99.99.99.99 go via 20.0.0.101 as next-hop? Is this possible?
Thanks in advance
I was thinking of creating a subnet in my VPC first with 99… network. But I unnecessary so not want to burn larger no of ip. And I believe /32 is not an acceptable CIDR in aws. And my journey stopped here. I am thinking of trying to configure CIDR of 99.99.99.96/29 but after that should I add that as local in route ? How could I specify that to reach 99 series go via a specific ip?

Assigning domain name to Google Cloud VM

I'm attempting to assign a domain name to my Google Cloud VM external IP. I was following some walkthroughs and getting a bit confused. I set up apache with a simple "Hello" message when you visit my external IP. The walkthroughs I'm following are providing steps to reserve a new static external IP and creating a DNS zone.
Could someone provide clarification on why I would need to secure a new static external IP address when it appears I already have one assigned?
As discussed by #Ferregina Pelona in the comment section. The public IP that your VM already has is an ephimeral one which means that if the VM is stopped or restarted, there is a possibility this public IP changes. The problem will be that if it changes, your DNS will continue pointing to the old one which means your site will be not accesible until you update the DNS with the new IP. Reserving the public IP will warranty your VM always has the same IP.
Also, added by #DazWilkin. it should be more explicit in the documentation but I assume (!) it's an ephemeral IP. I submitted doc feedback for this.
I assume you're following a guide like [1]
The tutorial demonstrates the following steps when assigning a domain to a VM which would act as a server:
-Register a domain name using Google Domains or Cloud Domains
-Create a virtual machine (VM) instance
-Run a basic Apache web server
-Set up your domain using Cloud DNS
-Update name servers
-Verify your setup
However, there is a very important note that I believe clarifies completely the scenario you faced and the questions regarding this which states:
Note:By default, the VM instance that you create receives an ephemeral external IP address. Ephemeral external IP addresses are lost whenever the VM instance shuts down or reboots for any reason (for example, maintenance). To avoid shutdowns and reboots, use a static external IP address for web hosting. For instructions about how to reserve a static external IP address, see Reserving a static external IP address.
My suggestion would be that you try always to find an official docummentation according to the configuration/products you're expecting to use so as shown in this section, these are the advices that could avoid you yo fall into errors while moving forward. I hops this info make sense for you...
Cheers,

Google Cloud managed instance group issue with plesk

I'm losing my mind over this so i thought I would ask about it. I have a VM instance that I was asked to put into managed instance group so that later on we can stuff like load balancing and Cloud armor.
This Vm instance has plesk panel that is configured with a website on it which is configured with a public domain to point to it.
I shut down the vm instance, create an image, then create instance template and finally create the managed instance group. The problem is that the instances that launch will have their internal and external ip addresses different then the original vm obviously so none of them will work until I ssh inside the vm instances and do some repairs like : Plesk repair all and that doesn't fix everything.
Essentially lets say original vm has internal ip : 11.11.11.1 and external ip : 20.20.20.1
when i create the managed instance group the first vm launching from the template will have
internal ip : 11.11.11.2 and external ip 20.20.20.2
but the config for plesk was setup for the first set of ips, so every instance created will be usesless as a webserver till they are fixed
Ive watched a lot of the tutorials on Managed vm instance groups, but none of them solve this issue. I'm trying to create a managed instance group of webservers that will go into a load balancer later.The tutorials online show just some simple start up script with one page being load balanced...
Any help is appreciated.
Thank you
As long as you want to host a single VM in Managed Instance Group, you can create an instance template that is bound to specific internal and/or external IP.
You can follow by analogy this example of creation MIGs with fixed IP addresses:
https://cloud.google.com/vpc/docs/special-configurations#configuring_the_gateways
As I don't know Plesk, please clarify in your question:
whether you need to host more than 1 VM in the group
whether Plask needs to know each individual VM by its both external & internal IP. It seems more natural to point Plesk to the loadbalancer's IP that routes the traffic to one of the VMs in the group.
why the solution with registration in startup-script didn't worked out.
Use :
plesk bin reconfigurator --autoconfigure
place on startup script of instance template

Assign a public IP to a nested VM on GCP without using proxy or port forwarding

I have a KVM instance deployed on GCP. There are nested VMs deployed on this KVM instance.
I would like to assign unique public IP addresses to these Nested VMs without the use of Proxies and port forwarding.
I was thinking of using alias IPs as described here
I can then assign a unique alias IP to each of the Nested VMs and the nested VMs will now be in the same subnet as the hypervisor itself.
However I'm not sure how to assign a public IP address to these alias IPs. Is it possible?
Or is there a way to achieve the goal: Assigning public IP to nested VMs
This is not possible today without some customization. One possible workaround is documented here.
After several attempt to replicate this setup to see if it was possible, it does not appear to be so. Additionally, it is unlikely this kind of setup would be supported by Google even if you happen to get it working by some kind of customization, etc.
However, if there was a partial solution it would be around IP aliasing and/or bridging, like the document you attached.
I did also find this community article that may be helpful.

AWS Best practice - When external ip address on stop/start

Here's what's bothering me. Is there a better way than sending emails to devs that the ip address for their dev server has changed after the instance is stopped and started?
I was thinking of a single small instance that has an elastic ip which the devs can log in using terminal, and ssh again to the internal ip address of the dev server. Is that effective?
Does it mean that the devs need to be informed of the change every time?
It's unclear exactly what you are saying "there's a new public dns for the server"? -thanks for the comment, that's clearer what you mean! It's the aws domain name in the format "ec2-54-222-213-143.eu-west-1.compute.amazonaws.com" you are referring to
You are asking how can these name/address changes be managed?
Generally speaking for fixing these kinds of problems there are a couple of things to be aware of
Firstly, if it is the public ip address that is changing instead of an ephemeral public ip address use an elastic ip. This will stay the same and can be transferred from an old instance to a new instance. Please read http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html about the differences between "Elastic IP" and normal public IP addresses on AWS
Secondly, if you are concerned about maintenance of the dns records that map the ip addresses to the domain names then it is possible to automate the updates to aws route53. I have used the aws cli command "route53 change-resource-record-sets" for this and also CloudFormation
Automating events to occur on instance start up does take a little research of the available APIs and hooks for example see this answer with a simple use of cloud-init Using cloud-init user data