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. |
-
In the Public IPs dashboard, check the box of the public IP you want to link.
The public IP is selected.You can also link a public IP to a VM in the VMs dashboard.
-
Click Link to VM.
The LINK TO VM dialog box appears. -
From the list, select the VM you want to link the public IP to.
-
(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. -
Click Link.
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. |
-
In the Public IPs dashboard, check the box of the public IP you want to link.
The public IP is selected. -
Click Link to NIC.
The LINK TO NIC dialog box appears. -
From the list, select the NIC you want to link the public IP to.
-
Click Link.
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. |
$ osc-cli api LinkPublicIp --profile "default" \
--PublicIp "192.0.2.0" \
--VmId "i-12345678"
$ 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 theVmId
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 thePublicIpId
parameter. -
PublicIpId
: (optional) The allocation ID of the public IP. This parameter is required unless you use thePublicIp
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.-
RequestId
: The ID of the request.
-
{
"ResponseContext": {
"RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
},
"LinkPublicIpId": "eipassoc-12345678"
}
{
"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, use the associate-address command following this syntax:
$ 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 toallow-reassociation
, the EIP is disassociated from any current instance or network interface and reassociated with the specified one. If set tono-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 tono-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 thenetwork-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. For more information, see Installing and Configuring AWS CLI.
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.
{
"AssociationId": "eipassoc-12345678"
}
A tag is added to the VM with |
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.