确切的说这是fwaas,即防火墙即是服务。

防火墙与安全组区别
防火墙一般放在网关上,用来隔离子网之间的访问。因此,防火墙即服务也是在网络节点上(具体说来是在路由器命名空间中)来实现。

安全组的对象是虚拟网卡,由L2 Agent来实现,比如neutron_openvswitch_agent 和
neutron_linuxbridge_agent,会在计算节点上通过配置 iptables
规则来限制虚拟网卡的进出访问。防火墙可以在安全组之前隔离外部过来的恶意流量,但是对于同个子网内部不同虚拟网卡间的通讯不能过滤(除非它要跨子网)。

部署防火墙

我部署的是mitaka版本

在控制节点和网络节点:

yum install openstack-neutron-fwaas python-neutron-fwaas

  

控制节点:

修改配置文件 /etc/neutron/neutron.conf

service_plugins = router,neutron.services.firewall.fwaas_plugin.FirewallPlugin

  

配置数据库

neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini --service fwaas upgrade

  

配置dashboard

vim /usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py
'enable_firewall' = True

  

网络节点:

修改配置文件/etc/neutron/fwaas_driver.ini

[DEFAULT]
[fwaas]
driver = neutron.services.firewall.drivers.linux.iptables_fwaas.IptablesFwaasDriver
enabled = True
[service_providers]
service_provider= FIREWALL:Iptables:neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver:default

 # 修改系统脚本

修改系统脚本
[root@network system]# vim neutron-l3-agent.service
[root@network system]# cat neutron-l3-agent.service
[Unit]
Description=OpenStack Neutron Layer 3 Agent
After=syslog.target network.target [Service]
Type=simple
User=neutron
ExecStart=/usr/bin/neutron-l3-agent --config-file /usr/share/neutron/neutron-dist.conf --config-dir /usr/share/neutron/l3_agent --config-file /etc/neutron/neutron.conf --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-l3-agent --config-file /etc/neutron/fwaas_driver.ini --log-file /var/log/neutron/l3-agent.log
PrivateTmp=false
KillMode=process [Install]
WantedBy=multi-user.target
[root@network system]# pwd
/usr/lib/systemd/system 然后
[root@network system]# systemctl daemon-reload
[root@network system]# systemctl restart neutron-l3-agent

  

然后重启服务

systemctl restart neutron-server #控制节点
systemctl restart httpd.service memcached.service #控制节点
systemctl restart neutron-l3-agent.service # 网络节点

 

防火墙的使用示例

创建防火墙规则

创建防火墙策略

创建防火墙并应用的router路由器

防火墙分析流程

我事先在防火墙上下了2个规则,’icmp source 10.0.0.0/24 drop ‘, ‘tcp source 2.2.2.0/24 des 3.3.3.0/24 drop’,并应用到路由器。

INPUT

iptables –line-numbers -vnL INPUT

ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables  --line-numbers -vnL INPUT
Chain INPUT (policy ACCEPT 489 packets, 19560 bytes)
num pkts bytes target prot opt in out source destination
1 749 29960 neutron-l3-agent-INPUT all -- * * 0.0.0.0/0 0.0.0.0/0

  

iptables –line-numbers -vnL neutron-l3-agent-INPUT

ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-INPUT
Chain neutron-l3-agent-INPUT (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x1/0xffff
2 0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:9697

  

可见在INPUT接受所有的数据包

OUTPUT

iptables –line-numbers -vnL OUTPUT

ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL OUTPUT
Chain OUTPUT (policy ACCEPT 3 packets, 120 bytes)
num pkts bytes target prot opt in out source destination
1 14 560 neutron-filter-top all -- * * 0.0.0.0/0 0.0.0.0/0
2 14 560 neutron-l3-agent-OUTPUT all -- * * 0.0.0.0/0 0.0.0.0/0
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-filter-top
Chain neutron-filter-top (2 references)
num pkts bytes target prot opt in out source destination
1 14 560 neutron-l3-agent-local all -- * * 0.0.0.0/0 0.0.0.0/0
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-local
Chain neutron-l3-agent-local (1 references)
num pkts bytes target prot opt in out source destination
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-OUTPUT
Chain neutron-l3-agent-OUTPUT (1 references)
num pkts bytes target prot opt in out source destination

  

可见在OUTPUT链没有什么规则

FORWARD

ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL FORWARD
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 neutron-filter-top all -- * * 0.0.0.0/0 0.0.0.0/0
2 0 0 neutron-l3-agent-FORWARD all -- * * 0.0.0.0/0 0.0.0.0/0
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-filter-top
Chain neutron-filter-top (2 references)
num pkts bytes target prot opt in out source destination
1 14 560 neutron-l3-agent-local all -- * * 0.0.0.0/0 0.0.0.0/0
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-local
Chain neutron-l3-agent-local (1 references)
num pkts bytes target prot opt in out source destination
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-FORWARD
Chain neutron-l3-agent-FORWARD (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 neutron-l3-agent-scope all -- * * 0.0.0.0/0 0.0.0.0/0
2 0 0 neutron-l3-agent-iv45e26bf33 all -- * qr-+ 0.0.0.0/0 0.0.0.0/0
3 0 0 neutron-l3-agent-ov45e26bf33 all -- qr-+ * 0.0.0.0/0 0.0.0.0/0
4 0 0 neutron-l3-agent-fwaas-defau all -- * qr-+ 0.0.0.0/0 0.0.0.0/0
5 0 0 neutron-l3-agent-fwaas-defau all -- qr-+ * 0.0.0.0/0 0.0.0.0/0

  neutron-l3-agent-FORWARD很重要,在没有防火墙应用到路由之前,只有条目1,应用防火墙之后,生成了2,3,4,5 我们分别看一下它们具体的内容。

 

ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-iv45e26bf33
Chain neutron-l3-agent-iv45e26bf33 (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
2 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 0 0 DROP tcp -- * * 2.2.2.0/24 3.3.3.0/24 tcp spt:30 dpt:30
4 0 0 DROP icmp -- * * 10.0.0.0/24 0.0.0.0/0
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-ov45e26bf33
Chain neutron-l3-agent-ov45e26bf33 (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
2 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 0 0 DROP tcp -- * * 2.2.2.0/24 3.3.3.0/24 tcp spt:30 dpt:30
4 0 0 DROP icmp -- * * 10.0.0.0/24 0.0.0.0/0
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-fwaas-defau
Chain neutron-l3-agent-fwaas-defau (2 references)
num pkts bytes target prot opt in out source destination
1 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0

  

这正是我在前面提到的规则,我们发现一条规则下发后分别存在进出两条规则在router中,即neutron-l3-agent-iv45e26bf33 ,neutron-l3-agent-ov45e26bf33 ,用于进数据网络的包的默认处理和出数据网络的包的默认处理。 neutron-l3-agent-fwaas-defau用于默认丢弃没有被以上规则处理的所有包。

我们在此基础上又添加一条规则’‘udp source 7.7.0.0/16 des 8.8.8.0/24 REJECT’’,默认新加的规则在前两者之前,当然我们可以控制这条规则的位置,加入我们把它放在前面两个规则之间,查看如下:

ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-ov45e26bf33
Chain neutron-l3-agent-ov45e26bf33 (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
2 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 0 0 DROP tcp -- * * 2.2.2.0/24 3.3.3.0/24 tcp spt:30 dpt:30
4 0 0 REJECT udp -- * * 7.7.0.0/16 8.8.8.0/24 udp spt:89 dpt:900 reject-with icmp-port-unreachable
5 0 0 DROP icmp -- * * 10.0.0.0/24 0.0.0.0/0
ip netns exec qrouter-6d975099-f0d9-49a8-bae8-8bf936c95e1c iptables --line-numbers -vnL neutron-l3-agent-iv45e26bf33
Chain neutron-l3-agent-iv45e26bf33 (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
2 0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 0 0 DROP tcp -- * * 2.2.2.0/24 3.3.3.0/24 tcp spt:30 dpt:30
4 0 0 REJECT udp -- * * 7.7.0.0/16 8.8.8.0/24 udp spt:89 dpt:900 reject-with icmp-port-unreachable
5 0 0 DROP icmp -- * * 10.0.0.0/24 0.0.0.0/0

  

防火墙有一定顺序,一条一条匹配的,所以规则的顺序也是值得关注的。

Neutron的防火墙原理的更多相关文章

  1. 基于IMD的包过滤防火墙原理与实现

    一.前言二.IMD中间层技术介绍三.passthru例程分析四.部分演示代码五.驱动编译与安装六. 总结 一.前言 前段时间,在安全焦点上看到了TOo2y朋友写的<基于SPI的数据报过滤原理与实 ...

  2. iptable防火墙原理

    iptable防火墙原理 简介 Linux 2.0 ipfs/firewalld Linux 2.2 ipchain/firewall Linux 2.4 iptables/netfilter (ip ...

  3. iptables防火墙原理详解

    1. netfilter与iptables Netfilter是由Rusty Russell提出的Linux 2.4内核防火墙框架,该框架既简洁又灵活,可实现安全策略应用中的许多功能,如数据包过滤.数 ...

  4. Linux网卡驱动安装、防火墙原理

    安装网卡驱动程序: 需要检查是否安装kernel依赖包: rpm –q kernel-devel #检查kernel依赖包是否安装 yum –y install kernel-devel 检查gcc和 ...

  5. Neutron Vlan Network 原理- 每天5分钟玩转 OpenStack(92)

    前面我们陆续学习了 Neutron local network,flat network 和 DHCP 服务,从本节将开始讨论 vlan network. vlan network 是带 tag 的网 ...

  6. Neutron Router 工作原理 - 每天5分钟玩转 OpenStack(142)

    上一节我们创建了 router 连通了 vlan100 和 vlan101, 今天分析router是如何工作的.首先查看控制节点的网络结构发生了什么变化: br-int 上多了两个 port: 1. ...

  7. iptables防火墙原理详解+mysql pt工具

    http://seanlook.com/2014/02/23/iptables-understand/

  8. [转]Openstack neutron 防火墙

    全文阅读传送门:http://www.ustack.com/wp-content/uploads/2013/11/Neutron%E9%98%B2%E7%81%AB%E5%A2%99.pdf 原作者: ...

  9. 使用Devstack部署neutron网络节点

    本文为minxihou的翻译文章,转载请注明出处Bob Hou: http://blog.csdn.net/minxihou JmilkFan:minxihou的技术博文方向是 算法&Open ...

随机推荐

  1. js中的整除运算

      Math.ceil(count / pagesize); //向上整除 4/3=2;   Math.floor(count / pagesize); //向下整除 4/3=1; Math.roun ...

  2. 我的Android进阶之旅------>Android Activity的singleTask加载模式和onActivityResult方法之间的冲突

    今天调试一个bug的时候,情景如下: 一个Activity A,需要用startActivityForResult方法开启Activity B.Activity B的launch mode被设置为si ...

  3. django 单元测试小结

    测试的场景 框架Django1.8 测试工具 unittest, 要记得给test设置一个独特的settings. 测试请求 也就是测试整个view部分 官方案例 其中可能会遇到登录,或者时sessi ...

  4. EJB远程客户端和本地客户端

    在客户端中使用企业bean 企业bean的客户端通过依赖注入或JNDI查询的方式获得对企业bean实例的引用. 依赖注入是获得对企业bean实例的引用的最简便的方法. (紧耦合的bean之间相互依赖, ...

  5. 什么是EJB

    学习EJB可以加深对J2EE平台的认识. 百科定义EJB: 被称为java企业bean,服务器端组件,核心应用是部署分布式应用程序.用它部署的系统不限定平台.实际上ejb是一种产品,描述了应用组件要解 ...

  6. vue项目如何打包扔向服务器

    vue项目如何打包扔向服务器   当我们将 vue 项目完成后,面临的就是如何将项目进行打包上线,放到服务器中.我使用的是 vue-cli(simple) 脚手架,所以就讲一下如何将项目进行打包,并放 ...

  7. 将php数组存取到本地文件

    存数组: <?php $data = array( "a" => "aaaaaa", "b" => "bbbbb ...

  8. HDOJ 1501 Zipper 【简单DP】

    HDOJ 1501 Zipper [简单DP] Problem Description Given three strings, you are to determine whether the th ...

  9. html 基础--一般标签

    <html>    --开始标签 <head> 网页上的控制信息 <title>页面标题</title> </head> <body& ...

  10. 如何使用sql函数平均值、总数、最小值、最大值

    使用sql函数,您可以在一个select语句的查询当中,直接计算数据库资料的平均值.总数.最小值.最大值.总和.标准差.变异数等统计.使用recordset对象时,也可使用这些sql函数. sql函数 ...