Lier une IP publique à une VM ou à une interface réseau

Vous pouvez lier une IP publique à une machine virtuelle (VM) ou à une interface réseau, dans le Cloud public ou dans un Net.

Dans le Cloud public, l’IP publique remplace l’IP publique de la VM. Dans un Net, elle lie une IP publique à la VM ou à l’interface réseau. Pour en savoir plus, voir À propos des IP publiques > Association des IP publiques.

Vous pouvez également lier une IP publique à un NAT service. Cependant, cette action n’est possible que lors de la création du NAT service. Pour en savoir plus, voir Créer un NAT service.

Lier une IP publique avec Cockpit v2

Lier une IP publique à une VM

Avant de commencer : Pour lier une IP publique à une VM, assurez-vous que le VPC a un Internet service attaché. Pour en savoir plus, voir Attacher un Internet service à un Net.

  1. Cliquez à l’intérieur du dashboard Public IPs pour faire apparaître des cases à cocher.

    Vous pouvez également lier une IP publique à une VM dans le dashboard VMs.

  2. Cochez la case de l’IP publique que vous voulez lier.
    L’IP publique est sélectionnée et un menu d’actions apparaît.

  3. Cliquez sur IconLink Lier à une VM.
    La boîte de dialogue LIER À UNE VM apparaît.

  4. Dans la liste, sélectionnez la VM que vous voulez lier.

  5. (optionnel) Sélectionnez la case Lier automatiquement la VM sélectionnée pour lier automatiquement l’IP publique à la VM sélectionnée à chaque redémarrage de la VM.

    Un tag est ajouté à votre VM, avec osc.fcu.eip.auto-attach comme clé et votre IP publique comme valeur. L’IP publique est associée à votre VM au prochain démarrage. Pour en savoir plus, voir Configurer une VM avec les user data et les tags OUTSCALE.

  6. Cliquez sur Lier à la VM.
    L’IP publique est liée à la VM.

Lier une IP publique à une NIC

Avant de commencer : Pour lier une IP publique à une NIC, assurez-vous que le VPC a un Internet service attaché. Pour en savoir plus, voir Attacher un Internet service à un Net.

  1. Cliquez à l’intérieur du dashboard Public IPs pour faire apparaître des cases à cocher.

  2. Cochez la case de l’IP publique que vous voulez lier.
    L’IP publique est sélectionnée et un menu d’actions apparaît.

  3. Cliquez sur IconLink Lier à une NIC.
    La boîte de dialogue LIER À UNE NIC apparaît.

  4. Dans la liste, sélectionnez la NIC que vous voulez lier.

  5. Cliquez sur Lier à la NIC.
    L’IP publique est liée à la NIC.

Lier une IP publique avec OSC CLI

Avant de commencer : Pour lier une IP publique à un Net, assurez-vous que le Net a un Internet service attaché. Pour en savoir plus, voir Attacher un Internet service à un Net.

À ce jour, cette section est disponible en anglais uniquement.

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"
}

Associer une EIP avec AWS CLI

Avant de commencer : Pour associer une EIP dans un VPC, assurez-vous que le VPC a une Internet gateway attachée. Pour en savoir plus, voir Attacher un Internet service à un Net.

Pour associer une EIP à une instance ou une interface réseau, utilisez la commande associate-address en suivant cette syntaxe :

Exemple de requête
$ 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

Cette commande contient les attributs suivants que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • (optionnel) allocation-id : L’ID de l’allocation de l’EIP dans votre compte.

  • (optionnel) public-ip : L’EIP.

    • Dans le Cloud public, vous devez spécifier l’attribut public-ip.

    • Dans un Net, vous devez spécifier l’attribut allocation-id.

  • (optionnel) allow-reassociation | no-allow-reassociation : Si paramétré sur allow-reassociation, l’EIP est dissociée de l’instance ou interface réseau actuelle et réassociée avec celle que vous spécifiez. Si paramétré sur no-allow-reassociation, un message d’erreur est renvoyé lorsque vous essayez de réassocier une EIP qui est déjà associée.

    Par défaut, cet attribut est paramétré sur allow-reassociation dans le Cloud public, et sur no-allow-reassociation dans un VPC.

  • (optionnel) instance-id : L’ID de l’instance à laquelle vous voulez associer l’EIP, si l’instance n’a qu’une seule interface réseau.

  • (optionnel) network-interface-id : L’ID de l’interface réseau à laquelle vous voulez associer l’EIP, si l’instance a plusieurs interfaces réseau.

    • Dans le Cloud public, vous devez spécifier l’attribut instance-id.

    • Dans un VPC, vous devez spécifier l’attribut instance-id si l’instance a seulement une interface réseau. Si l’instance a plusieurs interfaces réseau attachées, vous devez au contraire spécifier l’attribut network-interface-id.

  • (optionnel) private-ip-address : L’IP privée, principale ou secondaire, de l’interface réseau (par défaut, principale).

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête.

Dans le Cloud public, la commande associate-address ne renvoie aucun élément. Dans un VPC, elle renvoie l’élément suivant :

  • (VPC uniquement) AssociationId : L’ID de l’association de l’EIP à l’instance ou à l’interface réseau.

Exemple de résultat
{
    "AssociationId": "eipassoc-12345678"
}

Un tag est ajouté à votre VM, avec osc.fcu.eip.auto-attach comme clé et votre IP publique comme valeur. L’IP publique est associée à votre VM au prochain démarrage. Pour en savoir plus, voir Configurer une VM avec les user data et les tags OUTSCALE.

Pages connexes

Méthodes API correspondantes

AWS™ et Amazon Web Services™ sont des marques de commerce d’Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.