Changing the information of a virtual router (attaching to an external network)

This section explains how to connect a virtual router to an external network by updating its settings.



  1. Set the environment variables below as follows:
    $ ROUTER_ID=<targetVirtualRouterId>
    $ EXT_NET_ID=<externalNetworkIdToBeConnected>

    The external network ID can be checked using the API executed in step 3 of Creating a network.

    $ curl -Ss $NETWORK/v2.0/networks -X GET -H "X-Auth-Token: $OS_AUTH_TOKEN" | jq .

    Subnets with names that start with "inf_az1_ext_net01" and "inf_az2_ext_net01" are created associated with the default external network.

  2. Execute the following API:
    $ curl -Ss $NETWORK/v2.0/routers/$ROUTER_ID -X PUT \
    -H "X-Auth-Token: $OS_AUTH_TOKEN" -H "Content-Type: application/json" \
    -d '{"router": {"external_gateway_info":
    { "network_id":  "'$EXT_NET_ID'"}}}' | jq .

    The following response is output:

    {
      "router": {
        "status": "ACTIVE",
        "external_gateway_info": {
          "network_id": "<specifiedExternalNetworkId>",
          "enable_snat": true
        },
        "name": "<specifiedVirtualRouterName>",
        "admin_state_up": true,
        "tenant_id": "<projId>",
        "routes": [],
        "id": "<specifiedVirtualRouterId>",
        "availability_zone": "<availabilityZone>"
      }
    }

    For the availability zones, AZ1 is expressed as "jp-east-1a", and AZ2 is expressed as "jp-east-1b".