Skip to content

Routers CLI reference

See https://docs.openstack.org/ocata/cli-reference/neutron.html.

These commands allow you to create, list, show details of, update, and delete routers, as well as add or remove interfaces and set or clear the external gateway for routers in the Network service. The <router_id_or_name>, <external_network_id_or_name>, <subnet_id_or_name>, and <port_id> in the commands are placeholders that should be replaced with the actual IDs or names of the routers, external networks, subnets, and ports.

List routers

Bash
openstack router list

Show router details

Bash
openstack router show <router_id_or_name>

Create a router

Bash
openstack router create <router_name>

Optionally, you can specify an external network for the router's gateway at creation time.

Bash
openstack router create --external-gateway <external_network_id_or_name> <router_name>

Update a router

Bash
openstack router set --name <new_router_name> <router_id_or_name>
To update the external gateway of the router:
Bash
openstack router set --external-gateway <external_network_id_or_name> <router_id_or_name>

Delete a router

Bash
openstack router delete <router_id_or_name>

Add an interface to a router

Using a subnet ID.

Bash
openstack router add subnet <router_id_or_name> <subnet_id_or_name>

Using a port ID:

Bash
openstack router add port <router_id_or_name> <port_id>

Remove an interface from a router

Using a subnet ID:

Bash
openstack router remove subnet <router_id_or_name> <subnet_id_or_name>

Using a port ID

Bash
openstack router remove port <router_id_or_name> <port_id>

Clear the external gateway from a Router

Bash
openstack router unset --external-gateway <router_id_or_name>