controller节点:html
1 # Install package 2 yum install openstack-neutron-fwaas python-neutron-fwaas 3 4 # Edit /etc/neutron/neutron.conf 5 [DEFAULT] 6 service_plugins = router,firewall 7 8 # Create firewall database table 9 neutron-db-manage --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf \ 10 --config-file /etc/neutron/plugin.ini upgrade head 11 12 # Restart neutron-server 13 systemctl restart neutron-server
network节点:python
# Install package yum install openstack-neutron-fwaas python-neutron-fwaas # Edit /etc/neutron/l3_agent.ini [agent] extensions = fwaas # Edit /etc/neutron/fwaas_driver.ini [fwaas] driver = iptables enabled = true agent_version = v1 # Restart neutron-l3-agent (注 fwaas_driver.ini) systemctl restart neutron-l3-agent
firewall sample:linux
# Create firewall rule neutron firewall-rule-create --name allow-ssh --protocol tcp --destination-port 22 --ip-version 4 --action allow --enabled True # Create firewall policy neutron firewall-policy-create --firewall-rules allow-ssh --audited my_firewall_policy # Create firewall neutron firewall-create --name my_firewall --router $router_id my_firewall_policy
FWaas做用在三层的Router上的Iptables,因此若是要让防火墙生效,网络必须有网关,并且要有和网关链接的Router。api
网络状况以下:安全
Ext-Net 192.168.80.0/24, 192.168.80.2网络
Sub-Net 192.168.0.0/24, 192.168.0.1ssh
Router 192.168.80.237 – 192.168.0.1tcp
Router对应的namespace以下:ide
建立FW时会在Router的namespace上看到以下IPTables规则:ui
具体的就是在每一个Router的interface设备qr{xxx}装上入向和出向两个IPTables规则链, 在每一个链上都有相应的IPTables规则来实现防火墙的规则,neutron-l3-agent-iv4890abe79和neutron-l3-agent-ov4890abe79就是这两个规则链,neutron-l3-agent-fwaas-defau是默认规则链,能够看出默认状况他会Drop全部进出访问。
安全组由L2 Agent来实现,也就是说L2 Agent,好比neutron_openvswitch_agent和 neutron_linuxbridge_agent,会将安全组规则转换成IPTables规则,并且通常发生在全部计算节点上。
防火墙由L3 Agent来实现,它的规则会在租户的Router所在的L3 Agent节点上转化 成IPTables规则。
防火墙保护只能做用于跨网段的网络流量,而安全组则能够做用于任何进出虚拟机的流量。
防火墙做为高级网络服务,将被用于服务链中,而安全组则不能。在Neutron中同时部署防火墙和安全组能够达到双重防御。
外部恶意访问能够被防火墙过滤掉,避免了计算节点的安全组去处理恶意访问所形成的资源损失。
即便防火墙被突破,安全组做为下一到防线还能够保护虚拟机。最重要的是,安全组能够过滤掉来自内部的恶意访问。
参考文档:
http://niusmallnan.com/_build/html/_templates/openstack/fwaas_setup.html
https://docs.openstack.org/newton/networking-guide/misc.html