Virtual Networking
Create Virtual Networking Create an openrc File Create a file called ~/openrc. This file contains the OpenStack admin credentials that are used when interacting with the OpenStack environment on the command line. export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=password export OS_AUTH_URL="http://10.10.10.10:5000/v2.0/" export SERVICE_ENDPOINT="http://10.10.10.10:35357/v2.0" export SERVICE_TOKEN=password Source the credentials into your environment: $ source ~/openrc Configure the Bash shell to load these credentials upon each login: $ echo "source ~/openrc" >> ~/.bashrc The following bash script creates an internal network for the "demo" project. #!/bin/bash TENANT_NAME="demo" TENANT_NETWORK_NAME="demo-net" TENANT_SUBNET_NAME="${TENANT_NETWORK_NAME}-subnet" TENANT_ROUTER_NAME="demo-router" FIXED_RANGE="10.5.5.0/24" NETWORK_GATEWAY="10.5.5.1" TENANT_ID=$(keystone tenant-list | grep " $TENANT_NAME " | awk '{print $2}') TENANT_NET_ID=$(neutron net-create --tenant_id $TENANT_ID \ $TENANT_NETWORK_NAME --provider:network_type gre \ --provider:segmentation_id 1 | grep " id " | awk '{print $4}') TENANT_SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID \ --ip_version 4 --name $TENANT_SUBNET_NAME $TENANT_NET_ID $FIXED_RANGE \ --gateway $NETWORK_GATEWAY --dns_nameservers list=true 8.8.8.8 | \ grep " id " | awk '{print $4}') ROUTER_ID=$(neutron router-create --tenant_id $TENANT_ID \ $TENANT_ROUTER_NAME | grep " id " | awk '{print $4}') neutron router-interface-add $ROUTER_ID $TENANT_SUBNET_ID
L3 Configuration The OpenStack Networking L3 service enables instances to have external network access. If this service is not configured, your instances can only communicate with each other. Note that this configuration is highly dependant on your environment. For example, make note of the subnet-create command below. You must verify your own network settings for the external subnet (10.0.0.0/24 in this case) as well as an allocation pool. The allocation pool is used to provide each Project with an IP address to access the external network. The pool consists of 50 IPs and therefore only 50 projects can get a gateway IP. Create an external network: $ neutron net-create public --router:external=True Create a subnet for the external network: $ neutron subnet-create --ip_version 4 \ --gateway 10.0.0.1 public 10.0.0.0/24 \ --allocation-pool start=10.0.0.200,end=10.0.0.250 --disable-dhcp \ --name public-subnet Set the gateway of the demo router to the public network: $ neutron router-gateway-set demo-router public