Configuring Elastic IPs¶
Equinix Metal provides you the ability to assign Elastic IP addresses statically to your servers through the console and API.
IP Addresses that can be used as Elastic IPs:
- Addresses in Reserved Public IPv4 subnets
- Global Anycast IP Addresses
- Private IPv4 Addresses
- Public IPv6 Addresses
All IP addresses have to be in the same Metro and Project as the servers you are assigning them to, with the exception of Global Anycast IP addresses (which can be used globally).
Adding Elastic IP Addresses to an Existing Server¶
From the server's Network tab, in the Elastic IPs section, click + Assign New Elastic. A slide-out appears that allows you to select the subnet and IP Addresses to assign.
You can assign an Elastic IP to a server with the metal ip assign
command. Provide the IP address and CIDR you would like to assign to the server to the --address
flag.
metal ip assign --device-id <UUID> --address 198.51.100.3/31
The response to the assignment command contains a UUID in the ID column. If you later wish to unassign the Elastic IP, you will need this UUID.
+--------------------------------------+----------------+--------+----------------------+
| ID | ADDRESS | PUBLIC | CREATED |
+--------------------------------------+----------------+--------+----------------------+
| c6377504-b6cd-4bf9-aaea-ebba769e0b7e | 198.51.100.3 | true | 2022-12-21T16:28:58Z |
+--------------------------------------+----------------+--------+----------------------+
To assign an Elastic IP to a server in the API, send a POST
request to the /devices/{id}/ips
endpoint. The server's UUID is specified in the path, and the IP address and CIDR are passed in the body of the request.
curl -X POST \
-H "Content-Type: application/json" \
-H "X-Auth-Token: <API_TOKEN>" \
"https://api.equinix.com/metal/v1/devices/{id}/ips" \
-d '{
"address": "198.51.100.3/31"
}'
You can assign a single IP address from a subnet by sending in just that IP. You can assign the whole subnet by sending in the whole size of the subnet or you can specify any smaller size subnet. Full parameter options are available in the API Reference.
Note - in the response to the assignment request, there will be a UUID in the "id"
field. If you later wish to unassign the Elastic IP, you will need this UUID.
Host IP Configuration¶
Unlike management IPs, elastic IPs are not automatically configured on your servers. As a security measure, as we do not maintain access to servers to update their network configuration files once the operating system is installed. You have to add new IP addresses to the server's network configuration yourself.
Using a sample IP address of 198.51.100.3
, the following configuration changes will make the IP address usable on your server:
To configure temporarily (won't come back up on reboot):
sudo ip addr add 198.51.100.3 dev lo
To make permanent, add to /etc/network/interfaces
:
auto lo:0
iface lo:0 inet static
address 198.51.100.3
netmask 255.255.255.255
To configure temporarily (won't come back up on reboot):
sudo ip addr add 198.51.100.3 dev lo
To make permanent, add to /etc/netplan/00-elastic.yaml
:
network:
version: 2
renderer: networkd
ethernets:
lo:
addresses:
- 127.0.0.1/8
- 198.51.100.3/32
then either sudo netplan try
or sudo netplan apply
Keeping Track of Elastic IP Addresses¶
To check the status of subnets and IP addresses in the console, click your Project's IPs tab. Click on the Actions menu of the IP block and you can see which subnets and IPs are assigned to which servers.
For a server-level view, navigate to the server's Network tab. Under the Elastic IPs section, you can see the Elastic IPs assigned to that server.
All of the reserved block IP Address information for a Project is available from the metal ip get
command.
`metal ip get -p <project-uuid>`
To check for available subnets and IP address in a particular reserved IP block, use the metal ip available
command. The --reservation-id
can be obtained from the metal ip get -p <project-uuid>
command.
metal ip available --reservation-id <reservation_UUID> --cidr <size_of_subnet>
You can check a server's assigned IP addresses in the "ip_addresses"
object of the response from the metal device get
command, using the --output json
flag to get the full response.
device get -i <device-id> --output json
Example response (truncated):
{
"id": "d97f0c03-10d2-4667-9465-7f7a27a4f7a7",
....
"ip_addresses": [
{
"id": "4cc7f67b-522e-4b6c-82a5-3b2505be326a",
"address": "198.51.100.3",
"gateway": "198.51.100.2",
"network": "198.51.100.1",
"address_family": 4,
"netmask": "255.255.255.252",
"public": true,
....
"metro": {
"id": "2991b022-b8c4-497e-8db7-5a407c3a209b",
"name": "Silicon Valley",
"code": "sv",
"country": "US"
},
}
]
....
}
You can check the status of subnets and IP addresses in your project's subnets and IP blocks by sending a GET
request to the /ips/{id}
endpoint. The UUID of the IP address, whether it is a reserved IP or a management IP block, goes in the path.
curl -X GET \
-H "Content-Type: application/json" \
-H "X-Auth-Token: <API_TOKEN>" \
"https://api.equinix.com/metal/v1/ips/{id}"
The response will include which IPs and subnets are being used out of the IP address block specified.
For a server-level view, send a GET
request to the /devices/{id}/ips
endpoint.
curl -X GET \
-H "Content-Type: application/json" \
-H "X-Auth-Token: <API_TOKEN>" \
"https://api.equinix.com/metal/v1/devices/{id}/ips"
Unassigning an Elastic IP Address¶
To unassign a subnet or IP address from a server, navigate to the server's Network tab. Under the Elastic IPs section, select the Elastic IPs, and click Detach to unassign it from the server.
Unassign an Elastic IP address using the metal ip unssign
command. You can get the assignment-id
from the response of the original assignment command response or from the "id"
field in the "ip_addresses"
object of the response from the device get -i <device-id> -o json
command.
ip unassign --id <assignment-id>
Send a DELETE
request to the /ips/{id}
endpoint. The id
is the UUID of the assignment, which you can get from the response of the original assignment request or from the "assignment" field of the response from the /ips/{id}
endpoint.
curl -X DELETE \
-H "Content-Type: application/json" \
-H "X-Auth-Token: <API_TOKEN>" \
"https://api.equinix.com/metal/v1/ips/{id}"
Other Subnets and IP Address Options¶
Assigning an IP or subnet statically is not the only way to use the IP addresses in your reserved subnets and management blocks.
- If you have reserved public IPv4 addresses, you can assign those addresses and subnets to servers at provision time.
- You can announce IP addresses using BGP.
In addition, Equinix Metal offers Metal Gateways, which provides a public or private IPv4 address as a gateway for a subnet.