OpenStack-12-增加flat网段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack-12-增加flat网段相关的知识,希望对你有一定的参考价值。

参考技术A 使用OpenStack虚机启动的网卡是临时的,虚拟机重启就失效了,虚拟机挂起也会失效,网卡重启也会失效

测试环境: 分别在三台机器上增加一个网卡,选择lan网段,地址172.16.0.0/24

(一)增加一个flat网络原因

(二)添加网卡eth1

控制节点:

计算节点1:

计算节点2:

互相进行ping测试,测试连通性

(三)控制节点配置
1:控制节点

a:

b:

c:重启
systemctl restart neutron-server.service neutron-linuxbridge-agent.service

(四)计算节点配置
a:

b:重启

(五)创建网络
1、命令行创建:
neutron net-create --shared --provider:physical_network net172_16_0
--provider:network_type flat jiage

neutron subnet-create --name jiage
--allocation-pool start=172.16.0.1,end=172.16.0.250
--dns-nameserver 223.5.5.5 --gateway 172.16.0.254
jiage 172.16.0.0/24

查看创建的网络和子网详情

2、web页面创建网络:
管理员-网络-创建网络(供应商:平面)

创建子网

创建实例测试网络是否可用:项目-实例-创建实例(创建过程中可以选择刚创建的网络)

目前网络内网是通的,但是外网不通.因为指定的网关真实并不存在
需要创建一个linux系统作为路由器使用:

openstack--neutron--flat

控制节点的配置项:
#使用core plugin使用ml2
[[email protected] ~]# grep ‘^[a-z]‘ /etc/neutron/neutron.conf 
auth_strategy = keystone
core_plugin = ml2
service_plugins =

#ml2加载指定网络类型
#加载指定的plugin-agent:Linuxbridge
[[email protected] ~]# grep ‘^[a-z]‘ /etc/neutron/plugins/ml2/ml2_conf.ini 
type_drivers = local,flat,vlan,gre,vxlan,geneve
tenant_network_types = flat
mechanism_drivers = linuxbridge,openvswitch
extension_drivers = port_security
flat_networks = public
enable_ipset = true

#在哪个网口实现映射
[[email protected] ~]# grep ‘^[a-z]‘ /etc/neutron/plugins/ml2/linuxbridge_agent.ini 
physical_interface_mappings = public:ens33
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
enable_security_group = true
enable_vxlan = false

#创建Network
[[email protected] ~]# neutron net-create --shared --provider:physical_network public  --provider:network_type flat  flat_net_provider
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2017-08-08T09:23:25                  |
| description               |                                      |
| id                        | 43ad5825-5b55-4c1c-9fc4-a8c6e2ae129c |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| mtu                       | 1500                                 |
| name                      | flat_net_provider                    |
| port_security_enabled     | True                                 |
| provider:network_type     | flat                                 |
| provider:physical_network | public                               |
| provider:segmentation_id  |                                      |
| router:external           | False                                |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | 3e83baa0b3d64188b036ce423002aac7     |
| updated_at                | 2017-08-08T09:23:27                  |
+---------------------------+--------------------------------------+

[[email protected] ~]# neutron subnet-create --name flat_subnet_provider   --allocation-pool start=192.168.142.200,end=192.168.142.230   --gateway 192.168.142.2 flat_net_provider  192.168.142.0/24
Created a new subnet:
+-------------------+--------------------------------------------------------+
| Field             | Value                                                  |
+-------------------+--------------------------------------------------------+
| allocation_pools  | {"start": "192.168.142.200", "end": "192.168.142.230"} |
| cidr              | 192.168.142.0/24                                       |
| created_at        | 2017-08-08T09:30:05                                    |
| description       |                                                        |
| dns_nameservers   |                                                        |
| enable_dhcp       | True                                                   |
| gateway_ip        | 192.168.142.2                                          |
| host_routes       |                                                        |
| id                | dc748e16-472f-44b4-98da-629af8e9ce8d                   |
| ip_version        | 4                                                      |
| ipv6_address_mode |                                                        |
| ipv6_ra_mode      |                                                        |
| name              | flat_subnet_provider                                   |
| network_id        | 43ad5825-5b55-4c1c-9fc4-a8c6e2ae129c                   |
| subnetpool_id     |                                                        |
| tenant_id         | 3e83baa0b3d64188b036ce423002aac7                       |
| updated_at        | 2017-08-08T09:30:05                                    |
+-------------------+--------------------------------------------------------+
#底层网络变化
[[email protected] ~]# brctl show
bridge name     bridge id               STP enabled     interfaces
brq43ad5825-5b          8000.000c298c71a6       no              ens33
                                                        tapb8945f76-d5
#创建主机                                                       
[[email protected] ~]# openstack server create --flavor m1.nano --image cirros   --nic net-id=43ad5825-5b55-4c1c-9fc4-a8c6e2ae129c  --security-group default --key-name my-key instance-of-flat-0809-01
+--------------------------------------+-----------------------------------------------+
| Field                                | Value                                         |
+--------------------------------------+-----------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                        |
| OS-EXT-AZ:availability_zone          |                                               |
| OS-EXT-SRV-ATTR:host                 | None                                          |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                          |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000015                             |
| OS-EXT-STS:power_state               | 0                                             |
| OS-EXT-STS:task_state                | scheduling                                    |
| OS-EXT-STS:vm_state                  | building                                      |
| OS-SRV-USG:launched_at               | None                                          |
| OS-SRV-USG:terminated_at             | None                                          |
| accessIPv4                           |                                               |
| accessIPv6                           |                                               |
| addresses                            |                                               |
| adminPass                            | 3y7ZpxJNjQ8q                                  |
| config_drive                         |                                               |
| created                              | 2017-08-09T03:01:26Z                          |
| flavor                               | m1.nano (0)                                   |
| hostId                               |                                               |
| id                                   | 0010799f-ee85-4259-bcda-f5eec2cb2e12          |
| image                                | cirros (af67976a-92ea-4d08-8296-86cb76e3954b) |
| key_name                             | my-key                                        |
| name                                 | instance-of-flat-0809-01                      |
| os-extended-volumes:volumes_attached | []                                            |
| progress                             | 0                                             |
| project_id                           | 3e83baa0b3d64188b036ce423002aac7              |
| properties                           |                                               |
| security_groups                      | [{u‘name‘: u‘default‘}]                       |
| status                               | BUILD                                         |
| updated                              | 2017-08-09T03:01:28Z                          |
| user_id                              | 2614b525036b47e6a9a5b51ff385a06d              |
+--------------------------------------+-----------------------------------------------+
[[email protected] ~]# openstack server list
+--------------------------------------+--------------------------+---------+-----------------------------------+
| ID                                   | Name                     | Status  | Networks                          |
+--------------------------------------+--------------------------+---------+-----------------------------------+
| 0010799f-ee85-4259-bcda-f5eec2cb2e12 | instance-of-flat-0809-01 | ACTIVE  | flat_net_provider=192.168.142.202 |
| 7226e76d-85c0-439f-9599-36d986dfe831 | instance-of-flat-01      | ERROR   |                                   |
| 2a657897-4fa5-4d8b-ab22-c508110a061e | instance-test-local-03   | SHUTOFF | second_local_net=172.16.1.102     |
| fb206d8d-453c-4b14-8945-f7c8526c7747 | instance-test-local-02   | SHUTOFF | first_local_net=172.16.1.13       |
| 617c6ead-d85d-45cf-9d40-1354eaf758d5 | instance-test-local-01   | SHUTOFF | first_local_net=172.16.1.12       |
+--------------------------------------+--------------------------+---------+-----------------------------------+
[[email protected] ~]# ping 192.168.142.202
PING 192.168.142.202 (192.168.142.202) 56(84) bytes of data.
64 bytes from 192.168.142.202: icmp_seq=1 ttl=64 time=10.7 ms
64 bytes from 192.168.142.202: icmp_seq=2 ttl=64 time=4.78 ms
^C
--- 192.168.142.202 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 4.788/7.763/10.739/2.976 ms

[[email protected] ~]# ssh [email protected]
[email protected]‘s password: 
$ ifconfig 
eth0      Link encap:Ethernet  HWaddr FA:16:3E:AF:0D:64  
          inet addr:192.168.142.202  Bcast:192.168.142.255  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:feaf:d64/64 Scope:Link
 					......
#主机查看实例
[[email protected] ~]# virsh list
 Id    名称                         状态
----------------------------------------------------
 1     instance-00000015              running
#查看虚拟机的网卡信息
[[email protected] ~]# virsh domiflist instance-00000015
接口     类型     源        型号      MAC
-------------------------------------------------------
tapd618b2cd-e7 bridge     brq43ad5825-5b virtio      fa:16:3e:af:0d:64

[[email protected] ~]# brctl show
bridge name     bridge id               STP enabled     interfaces
brq43ad5825-5b          8000.000c298c71a6       no              ens33
                                                        tapb8945f76-d5 #dhcp的网卡接口
                                                        tapd618b2cd-e7 #实例的网卡接口
#停止控制节点的nova-computer服务,新建一个实例创建在计算节点192.168.142.167的上

# 192.168.142.202连接 192.168.142.204,OK可以通信
$ ifconfig 
eth0      Link encap:Ethernet  HWaddr FA:16:3E:AF:0D:64  
          inet addr:192.168.142.202  Bcast:192.168.142.255  Mask:255.255.255.0
$ ping 192.168.142.204
PING 192.168.142.204 (192.168.142.204): 56 data bytes
64 bytes from 192.168.142.204: seq=0 ttl=64 time=15.811 ms
                                                      
                     

  

 

以上是关于OpenStack-12-增加flat网段的主要内容,如果未能解决你的问题,请参考以下文章

Openstack 之 kolla 新增flat网络

搭建open***

linux增加网段的方法route-eth0

第5章 IP地址和子网划分_超网合并网段

mysql长连接跨网段问题

Linux 如何实现 VLAN - 每天5分钟玩转 OpenStack(12)