配置OVS的vxlan网络

配置OVS的vxlan网络
1、修改配置文件/etc/neutron/plugins/ml2/ml2_conf.ini(所有控制节点执行)
[ml2]
tenant_network_types  = vxlan
[ml2_type_flat]
flat_networks = physnet1
[ ml2_type_vxlan]
vni_ranges  1:1000
2、重启网络服务
systemctl restart neutron-server
3、创建网桥
ovs-vsctl add-br br-eth1
4、将网卡添加到网桥
ovs-vsctl add-port br-eth1 ens33
5、修改配置文件/etc/neutron/plugins/ml2/openvswitch_agent.ini
[agent]
tunnel_types = vxlan
l2_population = True
prevent_arp_spoofing = True
[ovs]
local_ip = 192.168.148.50 #各个节点的管理网IP
bridge_mappings = physnet1:br-eth1
13、重新启动服务
for service in dhcp-agent l3-agent metadata-agent openvswitch-agent; 
do
systemctl restart neutron-$service
done

14、修改计算节点配置文件
修改配置文件/etc/neutron/plugins/ml2/ml2_conf.ini
openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types  vxlan
openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks  physnet1
openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges  1:1000

修改配置文件/etc/neutron/plugins/ml2/openvswitch_agent.ini
openstack-config --set  /etc/neutron/plugins/ml2/openvswitch_agent.ini  agent tunnel_types vxlan
openstack-config --set  /etc/neutron/plugins/ml2/openvswitch_agent.ini  agent l2_population  True
openstack-config --set  /etc/neutron/plugins/ml2/openvswitch_agent.ini  prevent_arp_spoofing  True
openstack-config --set  /etc/neutron/plugins/ml2/openvswitch_agent.ini  ovs local_ip  192.168.148.36

15、重新启动服务
systemctl restart neutron-openvswitch-agent
16、配置DVR
控制节点
openstack-config --set /etc/neutron/neutron.conf DEFAULT router_distributed True
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini DEFAULT enable_distributed_routing True
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT agent_mode dvr_snat

17、计算节点修改配置文件/etc/neutron/l3_agent.ini
cp -a /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini_bak
[DEFAULT]
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT agent_mode dvr 
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini DEFAULT enable_distributed_routing True
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs bridge_mappings physnet1:br-eth1
18、创建网桥
ovs-vsctl add-br br-eth1 
ovs-vsctl add-port br-eth1 ens33(业务网)
19、计算节点上重启 neutron-l3-agent服务(默认没开启)
systemctl restart neutron-l3-agent.service
systemctl enable neutron-l3-agent.service
20、验证
创建路由
openstack router create router01
创建内部网络
openstack network create int_net --provider-network-type vxlan
创建子网
openstack subnet create subnet1 --network int_net \
--subnet-range 10.18.100.0/24 --gateway 10.18.100.1 \
--dns-nameserver 114.114.114.114
将子网添加到路由上
openstack router add subnet router01 subnet1
创建外部网络
openstack network create \
--provider-physical-network physnet1 \
--provider-network-type flat --external ext_net
创建外部网络子网
openstack subnet create subnet2 \
--network ext_net --subnet-range 192.168.148.0/24 \
--allocation-pool start=192.168.148.10,end=192.168.148.20 \
--gateway 192.168.148.1 --dns-nameserver 114.114.114.114
将网络添加到路由上
openstack router set router01 --external-gateway ext_net
创建flavor
openstack flavor create  --vcpus 1 --ram 512 --disk 1 test 
21、查看网络和image
Int_Net_ID=`openstack network list | grep int_net | awk '{ print $2 }'` 
openstack image list
创建keypair
ssh-keygen -q -N ""
添加公钥
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
创建虚拟机
openstack server create --flavor m1.small --image cirros--security-group default --nic net-id=$Int_Net_ID --key-name mykey cirros
openstack server list
分配浮动IP
openstack floating ip create ext_net
分配浮动IP给虚拟机
openstack server add floating ip cirros 192.168.148.11 
确认配置
openstack floating ip show 10.16.100.201
查看配置
openstack server list 
配置安全组icmp
openstack security group rule create --protocol icmp --ingress default 
配置安全组SSH
openstack security group rule create --protocol tcp --dst-port 22:22 default
查看安全组
openstack security group rule list
openstack server list
登录虚拟机
ssh [email protected]

你可能感兴趣的:(配置OVS的vxlan网络)