Managing router interfaces

Prerequisites

To add an external router interface

Admin panel

  1. If you already have an external gateway, remove the existing one first.
  2. On the Routers screen, click the router name to open the list of its interfaces.
  3. Click Add on the toolbar, or click Add interface if there are no interfaces to show.
  4. In the Add interface window, do the following:

    1. Select External gateway.
    2. From the Network drop-down menu, select a physical network to connect to the router. The new interface will pick an unused IP address from the selected physical network. You can also provide a specific IP address from the selected physical network to assign to the interface in the IP address field.
    3. 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.

  5. Click Add.

Command-line interface

Use the following command:

vinfra service compute router iface add [--ip-address <ip-address>]
                                        --interface <network> router
--ip-address <ip-address>
IP address
--interface <network>
Network name or ID
router
Virtual router name or ID

For example, to add an external interface from the physical network public to the virtual router myrouter with the IP address 10.94.129.76, run:

# vinfra service compute router iface add myrouter --interface public \
--ip-address 10.94.129.76
+--------------------------------------+-------------+-----------------+--------+
| network_id                           | is_external | ip_addresses    | status |
+--------------------------------------+-------------+-----------------+--------+
| 720e45bc-4225-49de-9346-26513d8d1262 | True        | - 10.94.129.76  | ACTIVE |
| e6f146ce-a6d0-48b2-9e4f-64a128ce97ae | False       | - 192.168.128.1 | ACTIVE |
+--------------------------------------+-------------+-----------------+--------+

The added interface will appear in the vinfra service compute router iface list output:

# vinfra service compute router iface list myrouter
+--------------------------------+-------------+-----------------+--------+
| network_id                     | is_external | ip_addresses    | status |
+--------------------------------+-------------+-----------------+--------+
| 720e45bc-4225-<...> (public)   | True        | - 10.94.129.76  | ACTIVE |
| e6f146ce-a6d0-<...> (private)  | False       | - 192.168.128.1 | ACTIVE |
+--------------------------------+-------------+-----------------+--------+

To add an internal router interface

Admin panel

  1. On the Routers screen, click the router name to open the list of its interfaces.
  2. Click Add.
  3. In the Add interface window, select a network to connect to the router from the Network drop-down menu. The new interface will attempt to use the gateway IP address of the selected virtual network by default. If it is in use, specify an unused IP address from the selected virtual network to assign to the interface in the IP address field.

  4. Click Add.

Command-line interface

Use the following command:

vinfra service compute router iface add [--ip-address <ip-address>]
                                        --interface <network> router
--ip-address <ip-address>
IP address
--interface <network>
Network name or ID
router
Virtual router name or ID

For example, to add an interface from the virtual network private2 to the virtual router myrouter with the IP address 192.168.30.3, run:

# vinfra service compute router iface add myrouter --interface private2 \
--ip-address 192.168.30.3
+--------------------------------------+-------------+-----------------+--------+
| network_id                           | is_external | ip_addresses    | status |
+--------------------------------------+-------------+-----------------+--------+
| 720e45bc-4225-49de-9346-26513d8d1262 | True        | - 10.94.129.76  | ACTIVE |
| e6f146ce-a6d0-48b2-9e4f-64a128ce97ae | False       | - 192.168.128.1 | ACTIVE |
| 86803e07-a6d7-4809-9566-1cbe4a89adfd | False       | - 192.168.30.3  | DOWN   |
+--------------------------------------+-------------+-----------------+--------+

The added interface will appear in the vinfra service compute router iface list output:

# vinfra service compute router iface list myrouter
+--------------------------------+-------------+-----------------+--------+
| network_id                     | is_external | ip_addresses    | status |
+--------------------------------+-------------+-----------------+--------+
| 720e45bc-4225-<...> (public)   | True        | - 10.94.129.76  | ACTIVE |
| e6f146ce-a6d0-<...> (private)  | False       | - 192.168.128.1 | ACTIVE |
| 86803e07-a6d7-<...> (private2) | False       | - 192.168.30.3  | ACTIVE |
+--------------------------------+-------------+-----------------+--------+

To edit external interface parameters

Admin panel

  1. Click the ellipsis icon next to the external interface, and then click Edit.
  2. In the Edit interface window, change the IP address or configure SNAT.
  3. Click Save to save your changes.

Command-line interface

Use the following command:

vinfra service compute router set [--external-gateway <network> |
                                  --no-external-gateway]
                                  [--fixed-ip <fixed-ip>]
                                  [--enable-snat | --disable-snat]
                                  <router>
--external-gateway <network>
Specify a physical network to be used as the router’s external gateway (name or ID)
--no-external-gateway
Remove the external gateway from the router
--enable-snat
Enable source NAT on the external gateway
--disable-snat
Disable source NAT on the external gateway
--fixed-ip <fixed-ip>
Desired IP on the external gateway
<router>
Virtual router name or ID

For example, to disable SNAT on the external gateway of the virtual router myrouter, run:

# vinfra service compute router set myrouter --disable-snat --external-gateway public
+-----------------------+--------------------------------------------------+
| Field                 | Value                                            |
+-----------------------+--------------------------------------------------+
| external_gateway_info | enable_snat: false                               |
|                       | 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                                           |
+-----------------------+--------------------------------------------------+

To remove a router interface

Admin panel

  1. Select the interface you want to remove.
  2. Click the ellipsis icon next to it, and then click Delete.
  3. In the confirmation window, click Delete.

Command-line interface

Use the following command:

vinfra service compute router iface remove --interface <network> router
--interface <network>
Network name or ID
router
Virtual router name or ID

For example, to remove the interface from the virtual network private2 from the virtual router myrouter, run:

# vinfra service compute router iface remove myrouter --interface private2
+--------------------------------------+-------------+-----------------+--------+
| network_id                           | is_external | ip_addresses    | status |
+--------------------------------------+-------------+-----------------+--------+
| 720e45bc-4225-49de-9346-26513d8d1262 | True        | - 10.94.129.76  | ACTIVE |
| e6f146ce-a6d0-48b2-9e4f-64a128ce97ae | False       | - 192.168.128.1 | ACTIVE |
+--------------------------------------+-------------+-----------------+--------+