1、向ketstone注册服务
(1)创建neutron网络服务目录:
# openstack service create --name neutron \
--description "OpenStack Networking" network
# openstack endpoint create --region RegionOne \
network public http://controller:9696
# openstack endpoint create --region RegionOne \
network internal http://controller:9696
# openstack endpoint create --region RegionOne \
network admin http://controller:9696
2、修改neutron配置文件
(1)编辑/etc/neutron/neutron.conf
connection = mysql+pymysql://neutron:neutron@controller/neutron
transport_url = rabbit://openstack:openstack@controller
#开启nova访问,通过nova访问虚拟机
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_url = http://controller:5000
# 设置neutron运行文件位置:
lock_path = /var/lib/neutron/tmp
(2)编辑 /etc/neutron/plugins/ml2/ml2_conf.ini
mechanism_drivers = linuxbridge
extension_drivers = port_security
(3)编辑 /etc/neutron/plugins/ml2/linuxbridge_agent.ini
physical_interface_mappings = public:ens33
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
(4)配置sysctl.conf,将数据链路层的策略上升到网络层
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
(5)配置/etc/neutron/dhcp_agent.ini
#DHCP功能管理
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
#配置网络服务元数据管理模块/etc/neutron/metadata_agent.ini
nova_metadata_host = controller
metadata_proxy_shared_secret = directsoft
(6)配置/etc/nova/nova.conf连接neutron
url = http://controller:9696
auth_url = http://controller:5000
metadata_proxy_shared_secret = directsoft
# ml2的配置文件需要放到neutron的主配置文件目录下
# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
3、同步数据库数据
# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
# systemctl restart openstack-nova-api.service
4、启动并设置开机自启
# systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
# systemctl start neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
# openstack network agent list
发现有不是3个带笑脸服务,到/var/log/neutron下查看相应日志。
5、创建网络 network
# openstack network create --share \
--provider-physical-network public \
--provider-network-type flat pub
--share #指定网络为共享网络
--provider-physical-network 网络名称 #指定配置文件中设置网络名称
--provider-network-type flat #网络类型为flat
对应以下配置项
ml2_conf.ini
physical_interface_mappings = public:ens33
# 创建子网
# openstack subnet create --network pub \
--allocation-pool start=192.168.44.100,end=192.168.44.150 \
--dns-nameserver 192.168.44.2 --gateway 192.168.44.2 \
--subnet-range 192.168.44.0/24 pub-subnet
6、验证添加安全组策略
(1)开启ICMP协议访问
# openstack security group rule create --proto icmp default
# openstack security group rule create --proto tcp --dst-port 22 default