A public IPv4 address belongs to a project until you release it, across stops, starts and terminations. It’s associated with at most one network interface at a time, and an interface has at most one. Every interface has public IPv6 already, so IPv4 is optional. In the console, open Compute, then IPv4 addresses.
Get an address
- At launch: check Public IPv4 address (
networkInterfaces[].ipv4: true). - With a new interface: Public IPv4 address on Create network interface
(
ipv4: { allocate: true }). - On its own: Allocate IPv4 address, or
AllocateIpv4Address with a
name, orezgh compute ipv4-addresses allocate web-public.
An address allocated at launch or with an interface has autoRelease: true, shown as Released
with its interface: Yes: deleting the interface, or terminating the instance that created it,
releases the address. Set autoRelease: false with
UpdateIpv4Address (ezgh compute ipv4-addresses update <address> --auto-release=false) to keep it. One you allocated on its own
is kept.
Associate and disassociate
Associate (AssociateIpv4Address) attaches the
address to an interface that has none (409 interface_has_ipv4 otherwise). On a
private interface the address is mapped to its
primary private address, and its VPC needs a Network Gateway
(409 vpc_has_no_gateway); association.privateIpv4Address is the private address. The address
carries traffic while the subnet’s route table routes 0.0.0.0/0
to the gateway; on a private interface, ezgh compute ipv4-addresses associate says whether it
does (ezgh 0.38.0 or later). An address that’s
already associated elsewhere is 409 address_associated, unless you set
allowReassociation: true (--allow-reassociation) to move it.
ezgh compute ipv4-addresses associate web-public --network-interface eni_7hq2m0x9ka3c
ezgh compute ipv4-addresses disassociate web-public
ezgh compute ipv4-addresses release web-publicassociation.state is associating until the address is reachable, then associated; on an
interface whose instance is stopped, it completes at once. Disassociate
(DisassociateIpv4Address) is disassociating until
it’s withdrawn.
The guest configures the address at its next start. If you associate it while the instance runs, stop and start the instance; a reboot isn’t enough.
Release
Release (ReleaseIpv4Address) gives the address back.
It must be disassociated first (409 address_associated). You may not get the same address
again.
Pricing
A public IPv4 address is $1 per address-month, charged by the hour while it’s allocated, associated or not. A month is 730 hours.
Limits
The organization’s IPv4 addresses per organization quota counts allocated addresses, associated or not, and IPv4 address allocations per hour counts every allocation, at launch and with interfaces included. See Quotas and limits.