- FWaas(防火墙即服务)是基于neutron组件实现的L4-L7层的服务
- Firewall 以extension的方式与neutron-L3-agent 集成一起
- 社区 Firewall的driver都是基于 iptables
- newton 不支持 firewall_v2,(neutronclient还不支持firewall_v2的api)
部署Firewall
controller节点:
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节点:
# 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:
# 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。
网络情况如下:
Ext-Net 192.168.80.0/24, 192.168.80.2
Sub-Net 192.168.0.0/24, 192.168.0.1
Router 192.168.80.237 – 192.168.0.1
Router对应的namespace如下:
创建FW时会在Router的namespace上看到如下IPTables规则:
具体的就是在每个Router的interface设备qr{xxx}装上入向和出向两个IPTables规则链, 在每个链上都有相应的IPTables规则来实现防火墙的规则,neutron-l3-agent-iv4890abe79和neutron-l3-agent-ov4890abe79就是这两个规则链,neutron-l3-agent-fwaas-defau是默认规则链,可以看出默认情况他会Drop所有进出访问。
安全组与Firewall
-
安全组由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