Linking a Public IP with a VM or a Network Interface

You can link a public IP with a virtual machine (VM) or a network interface, either in the public Cloud or in a Net.

In the public Cloud, the public IP replaces the public IP of the VM. In a Net, it links a public IP to the VM or the network interface. For more information, see About Public IPs > Public IP Association.

You can also link a public IP with a NAT service. However, you can do so only when creating the NAT service. For more information, see Creating a NAT Service.

Linking a Public IP Using Cockpit v2

Linking a Public IP to a VM

Before you begin: To link a public IP to a VM, ensure that the Net has an Internet service attached. For more information, see Attaching an Internet Service to a Net.

  1. Click inside the Public IPs dashboard to make checkboxes appear.

    You can also link a public IP to a VM in the VMs dashboard.

  2. Check the box of the public IP you want to link.
    The public IP is selected and an action menu appears.

  3. Click IconLink Link to VM.
    The LINK TO VM dialog box appears.

  4. From the list, select the VM you want to link the public IP to.

  5. (optional) Select the Auto-link the selected VM box to automatically link the public IP to the selected VM at every VM restart.

    A tag is added to the VM with osc.fcu.eip.auto-attach as Key and your public IP as Value. The public IP is linked to your VM every time it is restarted. For more information, see Configuring a VM with User Data and OUTSCALE Tags.

  6. Click Link to VM.
    The public IP is linked to the VM.

Linking a Public IP to a NIC

Before you begin: To link a public IP to a NIC, ensure that the Net has an Internet service attached. For more information, see Attaching an Internet Service to a Net.

  1. Click inside the Public IPs dashboard to make checkboxes appear.

  2. Check the box of the public IP you want to link.
    The public IP is selected and an action menu appears.

  3. Click IconLink Link to NIC.
    The LINK TO NIC dialog box appears.

  4. From the list, select the NIC you want to link the public IP to.

  5. Click Link to NIC.
    The public IP is linked to the NIC.

Linking a Public IP Using OSC CLI

Before you begin: To link a public IP to a VM or a network interface in a Net, ensure that the Net has an Internet service attached. For more information, see Attaching an Internet Service to a Net.

The LinkPublicIp command associates a public IP with a virtual machine (VM) or a network interface card (NIC), in the public Cloud or in a Net. You can associate a public IP with only one VM or network interface at a time.
To associate a public IP in a Net, ensure that the Net has an Internet service attached. For more information, see the LinkInternetService method.
By default, the public IP is disassociated every time you stop and start the VM. For a persistent association, you can add the osc.fcu.eip.auto-attach tag to the VM with the public IP as value. For more information, see the CreateTags method.

You can associate a public IP with a network address translation (NAT) service only when creating the NAT service. To modify its public IP, you need to delete the NAT service and re-create it with the new public IP. For more information, see the CreateNatService method.

Request sample: Linking a public IP to a VM
$ osc-cli api LinkPublicIp --profile "default" \
    --PublicIp "192.0.2.0" \
    --VmId "i-12345678"
Request sample: Linking a public IP to a NIC
$ osc-cli api LinkPublicIp --profile "default" \
    --PublicIp "192.0.2.0" \
    --NicId "eni-12345678"

This command contains the following attributes that you need to specify:

  • AllowRelink: (optional) If true, allows the public IP to be associated with the VM or NIC that you specify even if it is already associated with another VM or NIC. If false, prevents the public IP from being associated with the VM or NIC that you specify if it is already associated with another VM or NIC. (By default, true in the public Cloud, false in a Net.)

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • NicId: (optional) (Net only) The ID of the NIC. This parameter is required if the VM has more than one NIC attached. Otherwise, you need to specify the VmId parameter instead. You cannot specify both parameters at the same time.

  • PrivateIp: (optional) (Net only) The primary or secondary private IP of the specified NIC. By default, the primary private IP.

  • PublicIp: (optional) The public IP. This parameter is required unless you use the PublicIpId parameter.

  • PublicIpId: (optional) The allocation ID of the public IP. This parameter is required unless you use the PublicIp parameter.

  • VmId: (optional) The ID of the VM.

    • In the public Cloud, this parameter is required.

    • In a Net, this parameter is required if the VM has only one NIC. Otherwise, you need to specify the NicId parameter instead. You cannot specify both parameters at the same time.

The LinkPublicIp command returns the following elements:

  • LinkPublicIpId: (Net only) The ID representing the association of the public IP with the VM or the NIC.

  • ResponseContext: Information about the context of the response.

Result sample: Linking a public IP to a VM
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LinkPublicIpId": "eipassoc-12345678"
}
Result sample: Linking a public IP to a NIC
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LinkPublicIpId": "eipassoc-12345678"
}

Associating an EIP Using AWS CLI

Before you begin: To associate an EIP with an instance or a network interface in a VPC, ensure that the VPC has an Internet gateway attached. For more information, see Attaching an Internet Service to a Net.

To associate an EIP with an instance or a network interface, use the associate-address command following this syntax:

Request sample
$ aws ec2 associate-address \
    --profile YOUR_PROFILE \
    --allocation-id eipalloc-12345678 \
    [--public-ip NOT_SPECIFIED] \
    [--allow-reassociation | --no-allow-reassociation] \
    --instance-id i-12345678 \
    [--network-interface-id NOT_SPECIFIED] \
    --private-ip-address 10.0.0.0 \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • (optional) allocation-id: The allocation ID of the EIP in your account.

  • (optional) public-ip: The EIP.

    • In the public Cloud, you need to specify the public-ip attribute.

    • In a Net, you need to specify the allocation-id attribute.

  • (optional) allow-reassociation | no-allow-reassociation: If set to allow-reassociation, the EIP is disassociated from any current instance or network interface and reassociated with the specified one. If set to no-allow-reassociation, an error message is returned if you try to reassociate an EIP that is already associated.

    By default, this attribute is set to allow-reassociation in the public Cloud, and to no-allow-reassociation in a VPC.

  • (optional) instance-id: The ID of the instance you want to associate the EIP with, if the instance has only one network interface.

  • (optional) network-interface-id: The ID of the network interface you want to associate the EIP with, if the instance has several network interfaces.

    • In the public Cloud, you need to specify the instance-id attribute.

    • In a VPC, you need to specify the instance-id attribute if the instance has only one network interface. If the instance has more than one network interface attached, you need to specify the network-interface-id attribute instead.

  • (optional) private-ip-address: The primary or secondary private IP of the specified network interface (by default, the primary private IP).

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

In the public Cloud, the associate-address command returns no element. In a VPC, it returns the following element:

  • (VPC only) AssociationId: The ID of the association of the EIP with the instance or the network interface.

Result sample
{
    "AssociationId": "eipassoc-12345678"
}

A tag is added to the VM with osc.fcu.eip.auto-attach as Key and your public IP as Value. The public IP is associated to your VM every time it is restarted. For more information, see Configuring a VM with User Data and OUTSCALE Tags.

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.