Modifier une route

Vous pouvez modifier une route que vous avez créée dans une route table en la remplaçant par une autre. Cette action modifie automatiquement la façon dont le trafic est routé pour les Subnets associés à cette route table.

Mettre à jour une route avec OSC CLI

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

The UpdateRoute command replaces an existing route within a route table in a Net.
You must specify one of the following elements as the target:

  • Net peering

  • NAT virtual machine (VM)

  • Internet service

  • Virtual gateway

  • NAT service

  • Network interface card (NIC)

The routing algorithm is based on the most specific match.

Request sample: Updating a route to a virtual gateway
$ osc-cli api UpdateRoute --profile "default" \
    --RouteTableId "rtb-12345678" \
    --DestinationIpRange "198.51.100.0/24" \
    --GatewayId "vgw-12345678"

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

  • DestinationIpRange: The IP range used for the destination match, in CIDR notation (for example, 10.0.0.0/24).

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

  • GatewayId: (optional) The ID of an internet service or virtual gateway attached to your Net.

  • NatServiceId: (optional) The ID of a NAT service.

  • NetPeeringId: (optional) The ID of a Net peering.

  • NicId: (optional) The ID of a network interface card (NIC).

  • RouteTableId: The ID of the route table.

  • VmId: (optional) The ID of a NAT VM in your Net.

The UpdateRoute command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • RouteTable: Information about the route table.

    • LinkRouteTables: One or more associations between the route table and Subnets.

      • LinkRouteTableId: The ID of the association between the route table and the Net or Subnet.

      • Main: If true, the route table is the main one.

      • NetId: The ID of the Net, if the route table is not explicitly linked to a Subnet.

      • RouteTableId: The ID of the route table.

      • SubnetId: The ID of the Subnet, if the route table is explicitly linked to a Subnet.

    • NetId: The ID of the Net for the route table.

    • RoutePropagatingVirtualGateways: Information about virtual gateways propagating routes.

      • VirtualGatewayId: The ID of the virtual gateway.

    • RouteTableId: The ID of the route table.

    • Routes: One or more routes in the route table.

      • CreationMethod: The method used to create the route.

      • DestinationIpRange: The IP range used for the destination match, in CIDR notation (for example, 10.0.0.0/24).

      • DestinationServiceId: The ID of the OUTSCALE service.

      • GatewayId: The ID of the internet service or virtual gateway attached to the Net.

      • NatServiceId: The ID of a NAT service attached to the Net.

      • NetAccessPointId: The ID of the Net access point.

      • NetPeeringId: The ID of the Net peering.

      • NicId: The ID of the NIC.

      • State: The state of a route in the route table (always active).

      • VmAccountId: The account ID of the owner of the VM.

      • VmId: The ID of a VM specified in a route in the table.

    • Tags: One or more tags associated with the route table.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

Result sample: Updating a route to a virtual gateway
{
  "RouteTable": {
    "Routes": [
      {
        "DestinationIpRange": "10.0.0.0/16",
        "CreationMethod": "CreateRouteTable",
        "State": "active"
      },
      {
        "GatewayId": "vgw-12345678",
        "DestinationIpRange": "198.51.100.0/24",
        "CreationMethod": "CreateRoute",
        "State": "active"
      }
    ],
    "LinkRouteTables": [
      {
        "RouteTableId": "rtb-12345678",
        "Main": false,
        "SubnetId": "subnet-12345678",
        "LinkRouteTableId": "rtbassoc-12345678"
      }
    ],
    "NetId": "vpc-12345678",
    "Tags": [],
    "RoutePropagatingVirtualGateways": [],
    "RouteTableId": "rtb-12345678"
  },
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Mettre à jour une route avec oapi-cli

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

The UpdateRoute command replaces an existing route within a route table in a Net.
You must specify one of the following elements as the target:

  • Net peering

  • NAT virtual machine (VM)

  • Internet service

  • Virtual gateway

  • NAT service

  • Network interface card (NIC)

The routing algorithm is based on the most specific match.

Request sample: Updating a route to a virtual gateway
$ oapi-cli --profile "default" UpdateRoute \
    --RouteTableId "rtb-12345678" \
    --DestinationIpRange "198.51.100.0/24" \
    --GatewayId "vgw-12345678"

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

  • DestinationIpRange: The IP range used for the destination match, in CIDR notation (for example, 10.0.0.0/24).

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

  • GatewayId: (optional) The ID of an internet service or virtual gateway attached to your Net.

  • NatServiceId: (optional) The ID of a NAT service.

  • NetPeeringId: (optional) The ID of a Net peering.

  • NicId: (optional) The ID of a network interface card (NIC).

  • RouteTableId: The ID of the route table.

  • VmId: (optional) The ID of a NAT VM in your Net.

The UpdateRoute command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • RouteTable: Information about the route table.

    • LinkRouteTables: One or more associations between the route table and Subnets.

      • LinkRouteTableId: The ID of the association between the route table and the Net or Subnet.

      • Main: If true, the route table is the main one.

      • NetId: The ID of the Net, if the route table is not explicitly linked to a Subnet.

      • RouteTableId: The ID of the route table.

      • SubnetId: The ID of the Subnet, if the route table is explicitly linked to a Subnet.

    • NetId: The ID of the Net for the route table.

    • RoutePropagatingVirtualGateways: Information about virtual gateways propagating routes.

      • VirtualGatewayId: The ID of the virtual gateway.

    • RouteTableId: The ID of the route table.

    • Routes: One or more routes in the route table.

      • CreationMethod: The method used to create the route.

      • DestinationIpRange: The IP range used for the destination match, in CIDR notation (for example, 10.0.0.0/24).

      • DestinationServiceId: The ID of the OUTSCALE service.

      • GatewayId: The ID of the internet service or virtual gateway attached to the Net.

      • NatServiceId: The ID of a NAT service attached to the Net.

      • NetAccessPointId: The ID of the Net access point.

      • NetPeeringId: The ID of the Net peering.

      • NicId: The ID of the NIC.

      • State: The state of a route in the route table (always active).

      • VmAccountId: The account ID of the owner of the VM.

      • VmId: The ID of a VM specified in a route in the table.

    • Tags: One or more tags associated with the route table.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

Result sample: Updating a route to a virtual gateway
{
  "RouteTable": {
    "Routes": [
      {
        "DestinationIpRange": "10.0.0.0/16",
        "CreationMethod": "CreateRouteTable",
        "State": "active"
      },
      {
        "GatewayId": "vgw-12345678",
        "DestinationIpRange": "198.51.100.0/24",
        "CreationMethod": "CreateRoute",
        "State": "active"
      }
    ],
    "LinkRouteTables": [
      {
        "RouteTableId": "rtb-12345678",
        "Main": false,
        "SubnetId": "subnet-12345678",
        "LinkRouteTableId": "rtbassoc-12345678"
      }
    ],
    "NetId": "vpc-12345678",
    "Tags": [],
    "RoutePropagatingVirtualGateways": [],
    "RouteTableId": "rtb-12345678"
  },
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Modifier une route avec AWS CLI

Avant de commencer : Installez et configurez AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

Pour remplacer une route dans une route table, utilisez la commande replace-route en suivant cette syntaxe :

Exemple de requête
$ aws ec2 replace-route \
    --profile YOUR_PROFILE \
    --route-table-id rtb-87654321 \
    --destination-cidr-block 0.0.0.0/0 \
    --gateway-id igw-1234abcd \
    --instance-id NOT_SPECIFIED \
    --network-interface-id NOT_SPECIFIED \
    --vpc-peering-connection-id NOT_SPECIFIED \
    --nat-gateway-id NOT_SPECIFIED \
    --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.

  • route-table-id : L’ID de la route table dans laquelle vous souhaitez remplacer une route.

  • destination-cidr-block : La plage d’IP de destination, en notation CIDR.

  • (optionnel) gateway-id : L’ID de l’internet gateway ou de la virtual private gateway attachée au VPC à utiliser comme target pour la route.

  • (optionnel) instance-id : L’ID d’une instance dans le VPC à utiliser comme target pour la route.

    L’instance doit avoir une seule interface réseau attachée (la principale, et aucune flexible network interface). Si l’instance a plusieurs interfaces réseau attachées, utilisez l’attribut network-interface-id afin de spécifier laquelle vous souhaitez utiliser comme target pour la route.

  • (optionnel) network-interface-id : L’ID d’une interface réseau à utiliser comme target pour la route (l’interface réseau principale ou une flexible network interface).

  • (optionnel) vpc-peering-connection-id : L’ID d’une VPC peering connection à utiliser comme target pour la route.

  • (optionnel) nat-gateway-id : L’ID d’une NAT gateway à utiliser comme target pour la route.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête. Pour en savoir plus, voir Installer et configurer AWS CLI.

La route est modifiée selon la destination et la target spécifiées.

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.