Creating virtual routers

Prerequisites

To create a virtual router

Admin panel

  1. On the Compute > Network > Routers tab, click Add router.
  2. In the Add router window:

    1. Specify a router name.
    2. From the Network drop-down menu, select a physical network through which external access will be provided via an external gateway. The new external gateway will pick an unused IP address from the selected physical network.
    3. In the Add internal interfaces section, select one or more virtual networks to connect to a router via internal interfaces. The new internal interfaces will attempt to use the gateway IP address of the selected virtual networks by default.
    4. Select or deselect the SNAT check box to enable or disable SNAT on the external gateway of the router. With SNAT enabled, the router replaces VM private IP addresses with the public IP address of its external gateway.

  3. Click Create.

Command-line interface

Use the following command:

vinfra service compute router create [--external-gateway <network>]
                                     [--enable-snat | --disable-snat]
                                     [--fixed-ip <fixid-ip>]
                                     [--internal-interface <network=network,ip-addr=ip-addr> |
                                     <network>] <router-name>
--external-gateway <network>
Specify a physical network to be used as the router’s external gateway (name or ID)
--enable-snat
Enable source NAT on the external gateway
--disable-snat
Disable source NAT on the external gateway
--fixed-ip <fixid-ip>
Desired IP on the external gateway
--internal-interface <network=network,ip-addr=ip-addr>|<network>

Specify an internal interface. This option can be used multiple times.

  • network: name of a virtual network.
  • ip-addr: an unused IP address from the selected virtual network to assign to the interface; specify if the default gateway of the selected virtual network is in use.
<router-name>
Virtual router name

For example, to create a router myrouter between the physical network public and the virtual network private with enabled SNAT on the external gateway, run:

# vinfra service compute router create myrouter --external-gateway public \
--internal-interface private --enable-snat
+-----------------------+--------------------------------------------------+
| Field                 | Value                                            |
+-----------------------+--------------------------------------------------+
| external_gateway_info | enable_snat: true                                |
|                       | ip_addresses:                                    |
|                       | - 10.94.129.76                                   |
|                       | network_id: 720e45bc-4225-49de-9346-26513d8d1262 |
| id                    | b9d8b000-5d06-4768-9f65-2715250cda53             |
| name                  | myrouter                                         |
| project_id            | 894696133031439f8aaa7e4868dcbd4d                 |
| routes                | []                                               |
| status                | ACTIVE                                           |
+-----------------------+--------------------------------------------------+

The created router will appear in the vinfra service compute router list output:

# vinfra service compute router list -c id -c external_gateway_info -c name 
-c status +---------------------+---------------------------------+----------+--------+ | id | external_gateway_info | name | status | +---------------------+---------------------------------+----------+--------+ | b9d8b000-5d06-<...> | enable_snat: true | myrouter | ACTIVE | | | ip_addresses: | | | | | - 10.94.129.76 | | | | | network_id: 720e45bc-4225-<...> | | | +---------------------+---------------------------------+----------+--------+