skip to Main Content

we have a code that create staticIP in GCP/AWS/Azure, we are using the IaaS Sdk’s to create it, when we create it we are allocating it for our resources, now after some time we are deleting the resources that are using this staticIP, and now its "free"

After a sometime we need to attach new resource to allocate exact same IP’s that we created before.

we afraid that some process will allocate those IP, so my question is if there is a way to "reserve" those IP for limit time until the "Real" resources will allocate them again ?

3

Answers


  1. In GCP – I think it is possible to reserve a static IP address (through a console, glcoud CLI, Terraform or API), and later use it with one or another resource as needed. There may be different price (choose your region in the drop down list), depending on how the address is being used.

    Login or Signup to reply.
  2. You could reserve an external Static IP-reference and use Cloud NAT to make use of this IP Address.

    Basically, for example, you can provision multiple VMs with no external IP, and configure Cloud NAT to route all the external traffic through a single Static IP address.

    When all or some of your resources are deleted, the IP is still allocated to you.

    You can also specify a range of Internal IPs which correspond to your resources so only those resources utilize this Static IP.

    This will also work for Dataflow, Dataproc, GCE etc.

    Advantages:
    Let’s say you are using Dataflow to write data into a Postgres server which requires IP whitelisting, now due to autoscaling, determining IPs of each worker is not feasible, also having to Whitelist IP address for each Job run is not feasible too.

    Using Cloud NAT + Static IP solves this issue since you’d have to only whitelist a single IP and all the workers of Dataflow would use this IP address for data traffic flow

    Note: In case of port forwarding, you would either need to assign a
    static IP per resource or use Load Balancer

    Login or Signup to reply.
  3. As @al-dann said there is an option in gcp to reserve a static ip address.

    For existing ip:

    From your Google Cloud Platform dashboard, navigate to Networking > External IP addresses.the down arrow under the Type column and select Static for the External IP address that is connected to your instance (recommended method).

    For new ip:

    to reserve a new static IP address for your instance, instead of using the existing one, click the RESERVE STATIC ADDRESS button. If you choose this option, make sure the IP address matches the IP address in your website’s DNS records.make sure to attach the static IP address to the correct instance, then click the Reserve button

    For Change or assign an external IP address to an existing instance follow this doc.When you’re re-assigning IP addresses, it can sometimes take a while for the updates to reflect.

    For reserving external IP you must have been granted the orgpolicy.policyAdmin role on the organization.

    If you want to reserve a regional external IPv6 address you need to give alpha Alpha access to the feature in the gcp project by:

    gcloud alpha compute addresses create ADDRESS_NAME  
            --region=REGION 
            --subnet=SUBNET 
            --ip-version=IPV6 
            --endpoint-type=VM
    

    EDIT-1:

    You can reserve an ip address and assign to a VM of your choice, but charges will be higher for reserved static external IP that is not used.

    From this doc you can find

    If you reserve a static external IP address and do not assign it to a
    resource such as a VM instance or a forwarding rule, you are charged
    at a higher rate than for static and ephemeral external IP addresses
    that are in use.

    For Static IP addresses (assigned but unused) will be charged with $0.01 for every hour, you can find charges for various types from the table from the above doc.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search