IBM Cloud Docs
Creating network interfaces with floating IP addresses

Creating network interfaces with floating IP addresses

You can reserve a floating IP address, then add it to a network interface to allow traffic from the internet to access your VPC public gateway, virtual server instance, or Bare Metal server.

Adding floating IP addresses to network interfaces with the UI

You can add floating IP addresses to network interfaces with the UI.

Adding a floating IP address to a virtual server instance with the UI

To add a floating IP to a network interface to allow internet traffic to access your VSI, perform the following procedure:

  1. In the IBM Cloud console, go to Navigation Menu icon menu icon > Infrastructure VPC icon > Compute > Virtual server instances.

  2. Click the name of a virtual server instance that includes the network interface that you want to edit. Or you can add a new network interface to the virtual server instance.

  3. On the instance details page, find the Network interfaces section.

  4. If you are adding a floating IP address to the virtual server instance for the first time, identify the primary network interface in the Network interfaces section of the Instance details page.

    By default, the first interface is named eth0. Initially associating the floating IP address with the primary network interface helps establish the data path. Later, you can associate the floating IP to a different network interface if you desire.

  5. Click the Edit icon Edit icon to edit the primary network interface.

  6. On the Edit network interface page, locate the Floating IP address field.

  7. You can select an existing floating IP address to add to the network interface, or you can reserve a new floating IP and add it to the network interface. To do so:

    1. Select Reserve a new floating IP.
    2. Enter your geography, region, and zone information.
    3. Provide the details for the floating IP, including its name and resource group.
    4. (Optional) Add any tags you want associated with the IP.
    5. (Optional) Add access management tags to resources to help organize access control relationships. The only supported format for access management tags is key:value. For more information, see Controlling access to resources by using tags.
    6. Select Reserve.
  8. After making your selections, click Save.

Adding a floating IP address to a Bare Metal server with the UI

To add your floating IP to a network interface to allow internet traffic to access your Bare Metal server, perform the following procedure:

To associate multiple floating IPs to a network interface, make sure that both Allow IP spoofing and Enable infrastructure NAT are disabled on the network interface. Note that Enable infrastructure NAT is not supported on LinuxONE Bare Metal servers.

  1. In the IBM Cloud console, go to Navigation Menu icon menu icon > Infrastructure VPC icon > Compute > Bare Metal server.

  2. Under the Network interfaces section of the Bare metal server details page, click the Edit icon Edit icon of the interface you want to associate the floating IP with.

  3. On the Edit network interface page, locate the Floating IP address field.

  4. You can select an existing floating IP address to add to the network interface, or you can reserve a new floating IP and add it to the network interface. To do so:

    1. Select Reserve a new floating IP.
    2. Enter your geography, region, and zone information.
    3. Provide the details for the floating IP, including its name and resource group.
    4. Add any tags you want associated with the IP.
    5. Select Reserve.

    Associating a floating IP to the secondary network interface only works when you configure a default gateway to the secondary network interface within the operating system.

  5. After making your selections, click Save.

Adding a floating IP address to a virtual network interface with the UI

  1. In the IBM Cloud console, go to Navigation Menu icon menu icon > Infrastructure VPC icon > Compute > Virtual network interfaces.

  2. Click the name of the virtual network interface in the table to view its Details page.

  3. In the Floating IPs section, click Attach.

    • If a floating IP is already attached, the virtual network interface will not be accepted as a file share mount target.
    • If infrastructure NAT is enabled, at most one floating IP can be attached.
  4. In the Attach floating IP side panel, do one of the following:

    • Click Reserve new floating IP to create floating IP, complete the information, and then click Reserve.
    • Select an existing floating IP address from the menu, then click Attach.

Adding floating IP addresses to network interfaces with the CLI

You can add floating IP addresses to network interfaces with the CLI.

Adding a floating IP address to a virtual server instance with the CLI

Before you begin, set up your CLI environment.

First get the instance, in order to retrieve the NIC name:

ibmcloud is instance my-instance

Next, create a floating IP that targets that instance and the NIC:

ibmcloud is floating-ip-reserve my-ip --nic eth0 --in my-instance

Adding a floating IP address to a Bare Metal server with the CLI

Before you begin, set up your CLI environment.

First get the instance, in order to retrieve the NIC name:

ibmcloud is bare-metal-server my-instance

Next, create a floating IP that targets that instance and the NIC:

ibmcloud is floating-ip-reserve my-ip --nic eth0 --in my-bare-metal-server

Adding a floating IP address to a virtual network interface with the CLI

Before you begin, set up your CLI environment.

You can directly associate a floating IP to a VNI with the following command:

ibmcloud is floating-ip-reserve my-ip --nic 72b27b5c-f4b0-48bb-b954-5becc7c1dcb3

Adding floating IP addresses to network interfaces with the API

You can add floating IP addresses to network interfaces with the API.

Adding a floating IP address to a virtual server instance with the API

To add a floating IP address to a virtual server instance with the API, follow these steps:

  1. Set up your API environment.

  2. If you do no know the VNIC ID of your VSI, acquire it with the following command:

    curl -H "Authorization: Bearer $TOKEN" -X POST "https://us-south.iaas.cloud.ibm.com/v1/instances/$INSTANCE/network_interfaces?generation=2&version=2019-10-01"
    
  3. Then create the floating IP with the following command:

    curl -H "Authorization: Bearer $TOKEN" -X POST "https://us-south.iaas.cloud.ibm.com/v1/floating_ips?generation=2&version=2019-10-01" -d '{"name":"my-floating-ip", "target":{"id":"69e55145-cc7d-4d8e-9e1f-cc3fb60b1793"}}'
    

Adding a floating IP address to a Bare Metal server with the API

To add a floating IP address to a virtual server instance with the API, follow these steps:

  1. Set up your API environment.

  2. If you do no know the VNIC ID of your VSI, acquire it with the following command:

    curl -H "Authorization: Bearer $TOKEN" -X POST "https://us-south.iaas.cloud.ibm.com/v1//bare_metal_servers/$SERVER_ID/network_interfaces?generation=2&version=2019-10-01"
    
  3. Then create the floating IP with the following command:

    curl -H "Authorization: Bearer $TOKEN" -X POST "https://us-south.iaas.cloud.ibm.com/v1/floating_ips?generation=2&version=2019-10-01"  -d '{"name":"my-floating-ip", "target":{"id":"69e55145-cc7d-4d8e-9e1f-cc3fb60b1793"}}'
    

Adding a floating IP address to a virtual network interface with the API

To add a floating IP address to a virtual server instance with the API, follow these steps:

  1. Set up your API environment.

  2. Run the following command to create your floating UP:

    curl -H "Authorization: Bearer $TOKEN" -X POST "https://us-south.iaas.cloud.ibm.com/v1/floating_ips?generation=2&version=2019-10-01" d '{"name":"my-floating-ip", "target":{"id":"69e55145-cc7d-4d8e-9e1f-cc3fb60b1793"}}'
    

Creating a public gateway for VPC with a floating IP address

A public gateway allows all attached resources to communicate with the public internet. Your public gateway automatically assigns a floating IP to a subnet to allow internet traffic to access it.

To create a public gateway with a floating IP, refer to Creating public gateways.