Managing router interfaces
Prerequisites
- You have a virtual router created, as described in Creating virtual routers.
To add an external router interface
Admin panel
- If you already have an external gateway, remove the existing one first.
- On the Routers screen, click the router name to open the list of its interfaces.
- Click Add on the toolbar, or click Add interface if there are no interfaces to show.
-
In the Add interface window, do the following:
- Select External gateway.
- 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.
-
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.
- 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
- On the Routers screen, click the router name to open the list of its interfaces.
- Click Add.
-
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.
- 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
- Click the ellipsis icon next to the external interface, and then click Edit.
- In the Edit interface window, change the IP address or configure SNAT.
- 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
- Select the interface you want to remove.
- Click the ellipsis icon next to it, and then click Delete.
- 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 | +--------------------------------------+-------------+-----------------+--------+