CLI Client: Networks
This page describes how to use the Openstack CLI client to manage networks.
List Networks
openstack network list
List all networks accessible by your project.
The following filters are available:
--external
: networks connected to the public Internet.--internal
: private networks--share
: networks shared between multiple projects.
Create a Private Network
openstack network create <new-network-name>
openstack subnet create --use-default-subnet-pool --network <new-network-name> <new-subnet-name>
To create a working private network. First create a private network. Then create (at least) 1 subnet attached to the private network.
If you do not have special subnet configuration requirements, we recommend using the --use-default-subnet-pool
option in your openstack subnet create
command to get a pre-configured /25 subnet, capable of accommodating up to 126 instances (1 IP address is reserved for the router, 1 for broadcast address).
If you need specific subnet configurations, see all the available options by running the openstack subnet create -h
command.
For enable inbound or outbound access (which should be almost all use cases), you need to connect the private network to the public Internet. Create a router to connect the private network to the public Internet (i.e. the public
network).
Delete a Network
openstack subnet delete <subnet-name-or-id>
openstack network delete <network-name-or-id>
To delete a network, first delete the subnet and then the network. All the instances and routers connected to the subnet need to be deleted first before the subnet is deleted.
List Routers
openstack router list
List all routers in your project.
Create a Router
openstack router create --external-gateway public <new-router-name>
Create a router. To connect the router to the public Internet, make sure to specify the --external-gateway public
option. Source NAT (SNAT) is enabled for the new router by default.
Next connect a subnet to the new router so the router can start routing traffic to the connected subnet.
Connect a Router to a Subnet
openstack router add subnet <router-name-or-ip> <subnet-name-or-ip>
Connect the specified router to the specified subnet. If the router's external gateway is defined, the connected subnet should now have outbound access to the public Internet.
Delete a Router
openstack router delete <router-name>
Delete the specified router.
List Floating IP Addresses
openstack floating ip list
List all the floating addresses currently allocated to your project.
Create a Floating IP Address
openstack floating ip create <network-name-or-id>
Create a floating IP address on the specified network. To create a floating IP address on the public Internet, use public
for network name, i.e. openstack floating ip create public
.
Delete a Floating IP Address
openstack floating ip delete <IP-or-id>
Delete a floating IP address from the project.
Note
Once a floating IP address is deleted from the project, you will not able to get it back. If a floating IP is deleted by mistake, contact CAC Help for assistance.
Assign a Floating IP Address to an Instance
openstack server add floating ip <instance-name-or-id> <IP-or-id>
Assign a floating IP address to an instance. This command has 2 prerequisites:
- The instance must be connected to a private network.
- A router must connect the instance's private network and the
public
network with SNAT enabled (default setting).
Remove a Floating IP Address from an Instance
openstack server remove floating ip <instance-name-or-id> <IP-address>
Unassign the specified floating IP address from the instance. IP addresses are limited resources. If you no longer need the floating IP, please delete the floating IP to make it available for others.