3.11. Managing Virtual Routers¶
3.11.1. vinfra service compute router create¶
Create a virtual router:
usage: 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 public 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 private virtual network.ip-addr
: an unused IP address from the selected private network to assign to the interface; specify if the default gateway of the selected private network is in use.
<router-name>
- Virtual router name
Example:
# 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 |
+-----------------------+--------------------------------------------------+
This command creates a router myrouter
between the public network public
and the private network private
with enabled SNAT on the external gateway.
3.11.2. vinfra service compute router list¶
List virtual routers:
usage: vinfra service compute router list
Example:
# 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-<...> | | |
+---------------------+---------------------------------+----------+--------+
This command lists virtual routers used in the compute cluster. (The output is abridged to fit on page.)
3.11.3. vinfra service compute router show¶
Display information about a virtual router:
usage: vinfra service compute router show <router>
<router>
- Virtual router name
Example:
# vinfra service compute router show myrouter
+-----------------------+--------------------------------------------------+
| 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 |
+-----------------------+--------------------------------------------------+
This command shows the details of the virtual router myrouter
.
3.11.4. vinfra service compute router set¶
Modify virtual router parameters:
usage: vinfra service compute router set [--name <name>] [--external-gateway <network> |
--no-external-gateway] [--fixed-ip <fixed-ip>]
[--enable-snat | --disable-snat]
[--route <destination=destination,nexthop=nexthop> |
--no-route] <router>
--name <name>
- Virtual router name
--external-gateway <network>
- Specify a public 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
--route <destination=destination,nexthop=nexthop>
A static route for the router. This option can be used multiple times.
destination
: destination subnet range in CIDR notation.nexthop
: next hop IP address from one of the networks that the router is connected to.
--no-route
- Clear routes associated with the router
<router>
- Virtual router name or ID
Example:
# 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 |
+-----------------------+--------------------------------------------------+
This command disables SNAT on the external gateway of the virtual router myrouter
.
3.11.5. vinfra service compute router iface add¶
Add an interface to a virtual router:
usage: 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
Example:
# 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 |
+--------------------------------------+-------------+-----------------+--------+
This command adds an interface from the virtual network private2
to the virtual router myrouter
with the IP address 192.168.30.3
.
3.11.6. vinfra service compute router iface list¶
List router interfaces:
usage: vinfra service compute router iface list router
router
- Virtual router name or ID
Example:
# vinfra service compute router iface list myrouter
+-------------------------------------------------+-------------+-----------------+--------+
| network_id | is_external | ip_addresses | status |
+-------------------------------------------------+-------------+-----------------+--------+
| 720e45bc-4225-49de-9346-26513d8d1262 (public) | True | - 10.94.129.76 | ACTIVE |
| e6f146ce-a6d0-48b2-9e4f-64a128ce97ae (private) | False | - 192.168.128.1 | ACTIVE |
| 86803e07-a6d7-4809-9566-1cbe4a89adfd (private2) | False | - 192.168.30.3 | ACTIVE |
+-------------------------------------------------+-------------+-----------------+--------+
This command lists interfaces of the virtual router myrouter
.
3.11.7. vinfra service compute router iface remove¶
Remove an interface from a virtual router:
usage: vinfra service compute router iface remove --interface <network> router
--interface <network>
- Network name or ID
router
- Virtual router name or ID
Example:
# 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 |
+--------------------------------------+-------------+-----------------+--------+
This command removes the interface from the virtual network private2
from the virtual router myrouter
.
3.11.8. vinfra service compute router delete¶
Delete a virtual router:
usage: vinfra service compute router delete <router>
<router>
- Virtual router ID or name
Example:
# vinfra service compute router delete myrouter
Operation successful
This command deletes the virtual router myrouter
.