Networking with CLI
This section covers essential networking concepts and operations in our OpenStack environment using the CLI, including creating private networks, configuring internet access, and managing security groups.
1. List Networks
To see all networks available to your project:
openstack network listYou will see the shared public network and your own networks if you have created any.
2. Creating a Network & Subnet
Step 1: Create the Network
openstack network create <network-name>Example:
openstack network create private-net-01Step 2: Create the Subnet
Every network needs a subnet to define the range of IP addresses.
openstack subnet create --network <network-name> --subnet-range <cidr> --dns-nameserver 8.8.8.8 <subnet-name>Example:
openstack subnet create --network private-net-01 --subnet-range 192.168.0.0/24 --dns-nameserver 8.8.8.8 subnet-192-168-0-x3. Connecting to the Internet (Router)
To give your instances internet access, you must connect your private network to a public router.
Step 1: Create a Router
openstack router create <router-name>Example:
openstack router create router-01Step 2: Set the External Gateway
Connect the router to the public external network.
openstack router set --external-gateway public router-01Step 3: Add Subnet to Router
Connect your private subnet to the router.
openstack router add subnet router-01 subnet-192-168-0-xYour private network is now bridged to the internet.
4. Floating IPs
Floating IPs are public IP addresses that you can dynamically assign to your instances to make them accessible from the internet.
Step 1: Create a Floating IP
To reserve a floating IP from the public pool:
openstack floating ip create publicThis command will output the details of the newly created floating IP, including the IP address itself.
Step 2: List Floating IPs
To see all floating IPs allocated to your project:
openstack floating ip listStep 3: Associate a Floating IP
To assign a floating IP to an instance:
openstack server add floating ip <server-name> <floating-ip>Example:
openstack server add floating ip my-web-server 203.0.113.10Step 4: Disassociate a Floating IP
To remove a floating IP from an instance:
openstack server remove floating ip <server-name> <floating-ip>Step 5: Delete a Floating IP
To release a floating IP back to the pool:
openstack floating ip delete <floating-ip>5. Other Key Network Components
- Security Groups:
openstack security group list - Load Balancing:
openstack loadbalancer list