说明
本文介绍了 1控制+1计算、1 控制+1计算+1网络 中的 Linux bridge 与 Openvswitch 实现 neutron 网络的配置与验证过程
1 控制 + 1 计算
Linux bridge
vlan network
-
配置 ml2 插件
[root@controller41 ~(keystone_admin)]# vim /etc/neutron/plugins/ml2/ml2_conf.ini [ml2] type_driver = local,flat,vlan,vxlan tenant_network_types = vlan,local,vxlan # 这里添加 vlan 类型 mechanism_drivers = linuxbridge,l2population extension_drivers = port_security [ml2_type_vlan] network_vlan_ranges = default:10:20 # default 只是一个 tag,也可以是其他的,10:20 表示 vlan 范围 --------------------- # 配置 linuxbridge_agent [root@controller41 ~(keystone_admin)]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini [linux_bridge] physical_interface_mappings = default:eth1 # default tag 要和上边 ml2 的对应,eth1 是 vlan 网络和物理网卡的对应端口 --------------------- # 配置完成后,重启服务 [root@controller41 ~(keystone_admin)]# systemctl restart neutron-server.service neutron-linuxbridge-agent.service
-
创建子网
-
检查状态
[root@controller41 ~(keystone_admin)]# openstack network show net4_vlan +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Field | Value | +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | nova | | created_at | 2020-07-26T09:11:13Z | | description | | | dns_domain | None | | id | 19b0727a-205f-4ccd-8cf7-22daf154d11a | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | None | | is_vlan_transparent | None | | location | cloud='', project.domain_id=, project.domain_name='Default', project.id='d6ebe861e11f4ce48e36452369b88edc', project.name='admin', region_name='RegionOne', zone= | | mtu | 1500 | | name | net4_vlan | | port_security_enabled | True | | project_id | d6ebe861e11f4ce48e36452369b88edc | | provider:network_type | vlan | | provider:physical_network | default | | provider:segmentation_id | 11 | | qos_policy_id | None | | revision_number | 2 | | router:external | Internal | | segments | None | | shared | True | | status | ACTIVE | | subnets | 0a7a27f8-29b0-4177-8972-3baefdb46a78 | | tags | | | updated_at | 2020-07-26T09:11:14Z | +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ # 查看网桥 # 注意 brq19b0 开头的是刚才配置的 vlan network,可以和上边的 show 命令的的 id 对应上 [root@controller41 ~(keystone_admin)]# brctl show bridge name bridge id STP enabled interfaces brq11ff868b-c3 8000.9abc9f508285 no tape7815e70-47 brq19b0727a-20 8000.06892f012ec9 no eth1.11 tap10011f4d-97 tapc8ef378e-62 brq70db0e5d-a3 8000.0e6477992fd2 no tap6606fa8e-ff brq86a3e679-48 8000.52540032261b no eth2 tapd429fba3-9f brqf10f49a2-ad 8000.12f120817482 no tapda04b27a-2f vxlan-1
-
创建主机测试
Routing
-
检查配置
[root@controller41 ~(keystone_admin)]# vim /etc/neutron/l3_agent.ini [DEFAULT] interface_driver = linuxbridge
-
创建路由器
-
检查
[root@controller41 ~(keystone_admin)]# openstack router list +--------------------------------------+------------------+--------+-------+----------------------------------+-------------+-------+ | ID | Name | Status | State | Project | Distributed | HA | +--------------------------------------+------------------+--------+-------+----------------------------------+-------------+-------+ | 90250668-0dde-423d-8b75-00c0e41277ad | net4_vlan_router | ACTIVE | UP | d6ebe861e11f4ce48e36452369b88edc | False | False | +--------------------------------------+------------------+--------+-------+----------------------------------+-------------+-------+ # 这里只有一个 qrouter [root@controller41 ~(keystone_admin)]# ip netns qrouter-90250668-0dde-423d-8b75-00c0e41277ad (id: 4) qdhcp-19b0727a-205f-4ccd-8cf7-22daf154d11a (id: 3) qdhcp-11ff868b-c3ea-46a0-ad40-658598df1041 (id: 2) qdhcp-70db0e5d-a3b1-414d-92c9-08119bb8bf23 (id: 1) qdhcp-f10f49a2-adce-44fe-bca0-b1420817100a (id: 0) # 查看 namespace 的 ip 配置 [root@controller41 ~(keystone_admin)]# ip netns exec qrouter-90250668-0dde-423d-8b75-00c0e41277ad ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 5: qr-f83d3c74-fa@if29: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether fa:16:3e:ee:f4:f0 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 10.1.4.1/24 brd 10.1.4.255 scope global qr-f83d3c74-fa valid_lft forever preferred_lft forever inet6 fe80::f816:3eff:feee:f4f0/64 scope link valid_lft forever preferred_lft forever
-
在主机中验证
由于 cirros 镜像比较小,方便测试,所以可以用 cirros 创建一个主机
$ ip route show default via 10.1.4.1 dev eth0 10.1.4.0/24 dev eth0 src 10.1.4.84 169.254.169.254 via 10.1.4.2 dev eth0 $ ping 10.1.4.1 PING 10.1.4.1 (10.1.4.1): 56 data bytes 64 bytes from 10.1.4.1: seq=0 ttl=64 time=4.499 ms ^C --- 10.1.4.1 ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 4.499/4.499/4.499 ms
external network(flat 类型)
-
配置 ml2
[root@controller41 ~(keystone_admin)]# vim /etc/neutron/plugins/ml2/ml2_conf.ini [ml2_type_flat] flat_networks = external # external 是标签,也可以是其他的命名 [root@controller41 ~(keystone_admin)]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini [linux_bridge] physical_interface_mappings = default:eth1,external:eth2 # 增加 external:eth2,eth2 作为连接外网的出口
-
新增子网
-
在之前添加的路由器中,指定网关
-
然后在主机内测试
$ ping 172.19.12.254 PING 172.19.12.254 (172.19.12.254): 56 data bytes 64 bytes from 172.19.12.254: seq=0 ttl=63 time=3.749 ms ^C --- 172.19.12.254 ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 3.749/3.749/3.749 ms