OpenStack Juno : Neutron Networking2015/01/09 |
Configure virtual networking by OpenStack Network Service (Neutron).
For example, configure VLAN networking on here.
Furthermore, this example is based on the environment that Network Node has 3 network interfaces and also Compute Node has 2 network interfaces.
Before it, Configure basic settings on Control Node, Network Node, Compute Node. | +-------------+ +----+----+ | Name Server | | Gateway | +------+------+ +----+----+ |10.0.0.10 |10.0.0.1 | | +------------+-----------------+------------------------+ | | | | | | | 10.0.0.200-10.0.0.254 eth0|10.0.0.30 | 10.0.0.50| eth0 +--------+-------+ +--------+---------+ | +-----------+----------+ | Virtual Router | | [ Control Node ] | | | [ Network Node ] | +--------+-------+ | Keystone | | | DHCP Agent | 192.168.100.1 | Glance | | eth2| L3 Agent |eth1 | 192.168.100.0/24 | Nova API | | | L2 Agent | | +-----------------+ | Neutron Server | | | Metadata Agent | | +---| Virtual Machine | +------------------+ | +----------------------+ | | +-----------------+ | | | +-----------------+ | +----------------------+ +-------+---| Virtual Machine | | eth0| [ Compute Node ] |eth1 | +-----------------+ +-----| Nova Compute | | +-----------------+ 10.0.0.51| L2 Agent | |---| Virtual Machine | +----------------------+ | +-----------------+ | +-----------------+ +---| Virtual Machine | +-----------------+ |
[1] | Change settings like follows on Control Node. |
[root@dlp ~(keystone)]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # line 36: add [ml2_type_vlan] network_vlan_ranges = physnet1:1000:2999
# add follows to the end
[ovs]
tenant_network_type = vlan bridge_mappings = physnet1:br-eth1 systemctl restart neutron-server |
[2] | Change settings like follows on both Network Node and Compute Node. |
[root@network ~]# ovs-vsctl add-br br-eth1 # add a bridge [root@network ~]# ovs-vsctl add-port br-eth1 eth1 # add eth1 to the port of the bridge above
[root@network ~]#
vi /etc/neutron/plugins/ml2/ml2_conf.ini # line 36: add [ml2_type_vlan] network_vlan_ranges = physnet1:1000:2999
# add follows to the end
[ovs]
tenant_network_type = vlan bridge_mappings = physnet1:br-eth1 systemctl restart neutron-openvswitch-agent |
[3] | Create and define a bridge for external network on Network Node. |
[root@network ~]# ovs-vsctl add-br br-ext [root@network ~]# ovs-vsctl add-port br-ext eth2
[root@network ~]#
vi /etc/neutron/l3_agent.ini # line 47: add external_network_bridge = br-ext
systemctl restart neutron-l3-agent |
[4] | Create a Virtual router. It's OK to work on any node. (This example is on Control Node) |
# create a virtual router [root@dlp ~(keystone)]# neutron router-create router01 Created a new router: +-----------------------+--------------------------------------+ | Field | Value | +-----------------------+--------------------------------------+ | admin_state_up | True | | distributed | False | | external_gateway_info | | | ha | False | | id | a0d08cb3-bf96-4872-ab95-b24a697b080a | | name | router01 | | routes | | | status | ACTIVE | | tenant_id | e8f6ac69de5f46afa189fcefd99c8a1a | +-----------------------+--------------------------------------+[root@dlp ~(keystone)]# Router_ID=`neutron router-list | grep router01 | awk '{ print $2 }'` |
[5] | Create internal network and associate with the router above. |
# create internal network [root@dlp ~(keystone)]# neutron net-create int_net Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | id | a185fc16-d406-4ff5-8cd5-293208b640fe | | name | int_net | | provider:network_type | vlan | | provider:physical_network | physnet1 | | provider:segmentation_id | 1000 | | router:external | False | | shared | False | | status | ACTIVE | | subnets | | | tenant_id | e8f6ac69de5f46afa189fcefd99c8a1a | +---------------------------+--------------------------------------+ # create subnet in the internal network [root@dlp ~(keystone)]# neutron subnet-create \ --gateway 192.168.100.1 --dns-nameserver 10.0.0.1 int_net 192.168.100.0/24 Created a new subnet: +-------------------+------------------------------------------------------+ | Field | Value | +-------------------+------------------------------------------------------+ | allocation_pools | {"start": "192.168.100.2", "end": "192.168.100.254"} | | cidr | 192.168.100.0/24 | | dns_nameservers | 10.0.0.1 | | enable_dhcp | True | | gateway_ip | 192.168.100.1 | | host_routes | | | id | 222d0323-7ca9-431d-89f2-6466b2d9d0a1 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | | | network_id | a185fc16-d406-4ff5-8cd5-293208b640fe | | tenant_id | e8f6ac69de5f46afa189fcefd99c8a1a | +-------------------+------------------------------------------------------+
[root@dlp ~(keystone)]#
Int_Subnet_ID=`neutron net-list | grep int_net | awk '{ print $6 }'`
# set internal network to the router above [root@dlp ~(keystone)]# neutron router-interface-add $Router_ID $Int_Subnet_ID Added interface 344bf2ea-a32f-40df-8cc1-864f1056cb4c to router a0d08cb3-bf96-4872-ab95-b24a697b080a. |
[6] | Create external network and associate with the router above. |
# create external network [root@dlp ~(keystone)]# neutron net-create ext_net --router:external=True Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | id | bd216cab-c07b-4475-90ef-e9ad402bd57b | | name | ext_net | | provider:network_type | vlan | | provider:physical_network | physnet1 | | provider:segmentation_id | 1001 | | router:external | True | | shared | False | | status | ACTIVE | | subnets | | | tenant_id | e8f6ac69de5f46afa189fcefd99c8a1a | +---------------------------+--------------------------------------+ # create subnet in external network [root@dlp ~(keystone)]# neutron subnet-create ext_net \ --allocation-pool start=10.0.0.200,end=10.0.0.254 \ --gateway 10.0.0.1 --dns-nameserver 10.0.0.1 10.0.0.0/24 --disable-dhcp Created a new subnet: +-------------------+----------------------------------------------+ | Field | Value | +-------------------+----------------------------------------------+ | allocation_pools | {"start": "10.0.0.200", "end": "10.0.0.254"} | | cidr | 10.0.0.0/24 | | dns_nameservers | 10.0.0.1 | | enable_dhcp | False | | gateway_ip | 10.0.0.1 | | host_routes | | | id | 9e3aa059-de50-4bf6-8f92-98bfbee7ad7d | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | | | network_id | bd216cab-c07b-4475-90ef-e9ad402bd57b | | tenant_id | e8f6ac69de5f46afa189fcefd99c8a1a | +-------------------+----------------------------------------------+
[root@dlp ~(keystone)]#
Ext_Net_ID=`neutron net-list | grep ext_net | awk '{ print $2 }'` # set gateway to the router above [root@dlp ~(keystone)]# neutron router-gateway-set $Router_ID $Ext_Net_ID Set gateway for router a0d08cb3-bf96-4872-ab95-b24a697b080a |
[7] | Create and start Virtual machine Instance. |
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# Int_Net_ID=`neutron net-list | grep int_net | awk '{ print $2 }'` nova image-list +--------------------------------------+---------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------+--------+--------+ | 4a663fce-97eb-42d3-93d6-415e477bc0a4 | CentOS7 | ACTIVE | | +--------------------------------------+---------+--------+--------+[root@dlp ~(keystone)]# nova boot --flavor 2 --image CentOS7 --security_group default --nic net-id=$Int_Net_ID CentOS_70 [root@dlp ~(keystone)]# nova list +-----------+-----------+--------+------------+-------------+-----------------------+ | ID | Name | Status | Task State | Power State | Networks | +-----------+-----------+--------+------------+-------------+-----------------------+ | 33bb9427- | CentOS_70 | ACTIVE | - | Running | int_net=192.168.100.2 | +-----------+-----------+--------+------------+-------------+-----------------------+ |
[8] | Assign floating IP address to the Instance above. |
[root@dlp ~(keystone)]# neutron floatingip-create ext_net Created a new floatingip: +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | fixed_ip_address | | | floating_ip_address | 10.0.0.201 | | floating_network_id | bd216cab-c07b-4475-90ef-e9ad402bd57b | | id | da8eef0d-5bc8-488e-8fd4-0c6df1f5922a | | port_id | | | router_id | | | status | DOWN | | tenant_id | e8f6ac69de5f46afa189fcefd99c8a1a | +---------------------+--------------------------------------+
[root@dlp ~(keystone)]#
Device_ID=`nova list | grep CentOS_70 | awk '{ print $2 }'` [root@dlp ~(keystone)]# Port_ID=`neutron port-list -- --device_id $Device_ID | grep 192.168.100.2 | awk '{ print $2 }'` [root@dlp ~(keystone)]# Floating_ID=`neutron floatingip-list | grep 10.0.0.201 | awk '{ print $2 }'`
[root@dlp ~(keystone)]#
neutron floatingip-associate $Floating_ID $Port_ID Associated floating IP da8eef0d-5bc8-488e-8fd4-0c6df1f5922a # confirm settings [root@dlp ~(keystone)]# neutron floatingip-show $Floating_ID +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | fixed_ip_address | 192.168.100.2 | | floating_ip_address | 10.0.0.201 | | floating_network_id | bd216cab-c07b-4475-90ef-e9ad402bd57b | | id | da8eef0d-5bc8-488e-8fd4-0c6df1f5922a | | port_id | d4f17f91-c4e9-45ec-af2d-223907e891ea | | router_id | a0d08cb3-bf96-4872-ab95-b24a697b080a | | status | ACTIVE | | tenant_id | e8f6ac69de5f46afa189fcefd99c8a1a | +---------------------+--------------------------------------+ |
[9] | Configure security settings like follows to access with SSH and ICMP. |
# permit SSH [root@dlp ~(keystone)]# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | tcp | 22 | 22 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+ # permit ICMP [root@dlp ~(keystone)]# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | icmp | -1 | -1 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+[root@dlp ~(keystone)]# nova secgroup-list-rules default +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | tcp | 22 | 22 | 0.0.0.0/0 | | | icmp | -1 | -1 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+ |
[10] | It's possible to login to the Instance to connect to the IP address with SSH like follows. |
[root@dlp ~(keystone)]# ssh 10.0.0.201 The authenticity of host '10.0.0.201 (10.0.0.201)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:76:84:a6. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.0.0.201' (RSA) to the list of known hosts. root@192.168.100.2's password: Last login: Thu Jan 8 22:37:16 2015 [root@localhost ~]# # just logined
|
Sponsored Link |