深入理解NeutronOpenStack网络实现.pdf
- 文档编号:3430777
- 上传时间:2023-05-05
- 格式:PDF
- 页数:94
- 大小:7.28MB
深入理解NeutronOpenStack网络实现.pdf
《深入理解NeutronOpenStack网络实现.pdf》由会员分享,可在线阅读,更多相关《深入理解NeutronOpenStack网络实现.pdf(94页珍藏版)》请在冰点文库上搜索。
1.前言2.概述3.基本概念4.GRE模式i.计算节点ii.网络节点5.VLAN模式i.计算节点ii.网络节点6.VXLAN模式i.计算节点i.br-intii.br-tunii.网络节点i.br-tunii.br-intiii.br-ex7.网络命名空间i.DHCP服务ii.路由服务8.安全组i.INPUTii.OUTPUTiii.FORWARDiv.整体逻辑v.快速查找安全组规则vi.其它9.LBaaS(负载均衡即服务)i.典型场景ii.实现细节iii.其它问题10.FWaaS(防火墙即服务)i.典型场景ii.实现细节iii.其它问题11.DVR(分布式路由)i.典型场景ii.网络节点iii.计算节点iv.配置v.工作流程vi.实现细节目錄深入理解Neutron-OpenStack网络实现212.工具i.easyOVS13.参考14.附:
安装配置深入理解Neutron-OpenStack网络实现3Neutron是OpenStack项目中负责提供网络服务的组件,它基于软件定义网络的思想,实现了网络虚拟化下的资源管理。
本书将剖析Neutron组件的原理和实现。
最新版本在线阅读:
GitBook。
本书源码在Github上维护,欢迎参与:
https:
/fork到自己的仓库,如user/openstack_understand_Neutron,然后clone到本地,并设置用户信息。
深入理解Neutron-OpenStack网络实现更新历史:
参加步骤深入理解Neutron-OpenStack网络实现4前言$:
user/openstack_understand_Neutron.git$cdopenstack_understand_Neutron$gitconfiguser.nameUser$修改代码后提交,并推送到自己的仓库。
$#dosomechangeonthecontent$gitcommit-amFixissue#1:
changehelotohello$gitpush在GitHub网站上提交pullrequest。
定期使用项目仓库内容更新自己仓库内容。
$gitremoteaddupstreamhttps:
/安全网桥。
详见securitygroup部分的分析。
一个典型的br-int的端口如下所示:
#ovs-vsctlshowBridgebr-intPortqvo-XXXtag:
1Interfaceqvo-XXXPortpatch-tunInterfacepatch-tuntype:
patchoptions:
peer=patch-intPortbr-intInterfacebr-inttype:
internal其中,br-int为内部端口。
patch-tun(即端口E,端口号为1)连接到br-tun上,实现到外部网络的隧道。
qvo-XXX(即端口D,端口号为2)带有tag1,说明这个口是一个1号vlan的access端口。
虚拟机发出的从该端口到达br-int的网包将被自动带上vlantag1,而其他带有vlantag1的网包则可以在去掉vlantag后从该端口发出(即vlanaccess端口)。
这个vlantag是用来实现不同网络相互隔离的,比如租户创建一个网络(neutronnet-create),则会被分配一个唯一的vlantag。
br-int在GRE模式中作为一个NORMAL交换机使用,因此有效规则只有一条正常转发。
如果两个在同一计算节点qbrbr-int深入理解Neutron-OpenStack网络实现10计算节点主机上的vm属于同一个tenant的(同一个vlantag),则它们之间的通信只需要经过br-int即可。
#ovs-ofctldump-flowsbr-intNXST_FLOWreply(xid=0x4):
cookie=0x0,duration=10727.864s,table=0,n_packets=198,n_bytes=17288,idle_age=13,priority=一个典型的br-tun上的端口类似:
Bridgebr-tunPortpatch-intInterfacepatch-inttype:
patchoptions:
peer=patch-tunPortgre-1Interfacegre-1type:
greoptions:
in_key=flow,local_ip=10.0.0.101,out_key=flow,remote_ip=10.0.0.100Portbr-tunInterfacebr-tuntype:
internal其中,patch-int(即端口F,端口号为1)是连接到br-int上的vethpair的端口gre-1端口(即端口G,端口号为2)对应vm到外面的隧道。
gre-1端口是虚拟gre端口,当网包发送到这个端口的时候,会经过内核封包,然后从10.0.0.101发送到10.0.0.100,即从本地的物理网卡(10.0.0.101)发出。
br-tun将带有vlantag的vm跟外部通信的流量转换到对应的gre隧道,这上面要实现主要的转换逻辑,规则要复杂,一般通过多张表来实现。
典型的转发规则为:
#ovs-ofctldump-flowsbr-tunNXST_FLOWreply(xid=0x4):
cookie=0x0,duration=10970.064s,table=0,n_packets=189,n_bytes=16232,idle_age=16,priority=cookie=0x0,duration=10906.954s,table=0,n_packets=29,n_bytes=5736,idle_age=16,priority=cookie=0x0,duration=10969.922s,table=0,n_packets=3,n_bytes=230,idle_age=10962,priority=cookie=0x0,duration=10969.777s,table=1,n_packets=26,n_bytes=5266,idle_age=16,priority=cookie=0x0,duration=10969.631s,table=1,n_packets=163,n_bytes=10966,idle_age=21,priority=cookie=0x0,duration=688.456s,table=2,n_packets=29,n_bytes=5736,idle_age=16,priority=cookie=0x0,duration=10969.488s,table=2,n_packets=0,n_bytes=0,idle_age=10969,priority=cookie=0x0,duration=10969.343s,table=3,n_packets=0,n_bytes=0,idle_age=10969,priority=cookie=0x0,duration=10969.2s,table=10,n_packets=29,n_bytes=5736,idle_age=16,priority=cookie=0x0,duration=682.603s,table=20,n_packets=26,n_bytes=5266,hard_timeout=300,idle_age=cookie=0x0,duration=10969.057s,table=20,n_packets=0,n_bytes=0,idle_age=10969,priority=cookie=0x0,duration=688.6s,table=21,n_packets=161,n_bytes=10818,idle_age=21,priority=br-tun深入理解Neutron-OpenStack网络实现11计算节点cookie=0x0,duration=10968.912s,table=21,n_packets=2,n_bytes=148,idle_age=689,priority=其中,表0中有3条规则:
从内部端口1(即patch-int)来的,扔到表1,从外部端口2(即gre-1)来的,扔到表2。
cookie=0x0,duration=10970.064s,table=0,n_packets=189,n_bytes=16232,idle_age=16,priority=cookie=0x0,duration=10906.954s,table=0,n_packets=29,n_bytes=5736,idle_age=16,priority=cookie=0x0,duration=10969.922s,table=0,n_packets=3,n_bytes=230,idle_age=10962,priority=表1处理内部过来的网包,有2条规则:
如果是单播(00:
00:
00:
00:
00:
00/01:
00:
00:
00:
00:
00),则扔到表20;如果是多播等(01:
00:
00:
00:
00:
00/01:
00:
00:
00:
00:
00),则扔到表21。
cookie=0x0,duration=10969.777s,table=1,n_packets=26,n_bytes=5266,idle_age=16,priority=0,dl_dst=00:
00:
00:
00:
00:
00/01:
00:
00:
00:
00:
00actions=resubmit(,20)cookie=0x0,duration=10969.631s,table=1,n_packets=163,n_bytes=10966,idle_age=21,priority=0,dl_dst=01:
00:
00:
00:
00:
00/01:
00:
00:
00:
00:
00actions=resubmit(,21)表2处理外部过来的包。
有2条规则:
如果是tunnel1(合法的tunnelid)的网包,则修改其vlanid为1,并扔到表10学习记录来源;非tunnel1(非法的tunnelid)的网包,则丢弃。
cookie=0x0,duration=688.456s,table=2,n_packets=29,n_bytes=5736,idle_age=16,priority=cookie=0x0,duration=10969.488s,table=2,n_packets=0,n_bytes=0,idle_age=10969,priority=表3只有1条规则:
丢弃。
表10负责学习。
有一条规则,基于learn行动来创建反向(内部网包从gre端口发出去)的规则。
learn行动并非标准的openflow行动,是openvswitch自身的扩展行动,这个行动可以根据流内容动态来修改流表内容。
这条规则首先创建了一条新的流(该流对应vm从br-tun的gre端口发出的规则):
其中table=20表示规则添加在表20;NXM_OF_VLAN_TCI0.11表示匹配包自带的vlanid;NXM_OF_ETH_DST=NXM_OF_ETH_SRC表示L2目标地址需要匹配当前包的L2源地址;load:
0-NXM_OF_VLAN_TCI,去掉vlan,load:
NXM_NX_TUN_ID-NXM_NX_TUN_ID,添加tunnel号为原始tunnel号;output:
NXM_OF_IN_PORT,发出端口为原始包抵达的端口。
表0表1表2表3表10深入理解Neutron-OpenStack网络实现12计算节点向表20添加完规则后,最后将匹配的当前网包从端口1(即patch-int)发出。
cookie=0x0,duration=10969.2s,table=10,n_packets=29,n_bytes=5736,idle_age=16,priority=表20中有两条规则,其中第一条即表10中规则利用learn行动创建的内部向外部发包的流表项,第2条提交其他流到表21。
cookie=0x0,duration=682.603s,table=20,n_packets=26,n_bytes=5266,hard_timeout=300,idle_age=16,hard_age=16,priority=1,vlan_tci=0x0001/0x0fff,dl_dst=fa:
16:
3e:
32:
0d:
dbactions=load:
0-NXM_OF_VLAN_TCI,load:
0x1-NXM_NX_TUN_ID,output:
2cookie=0x0,duration=10969.057s,table=20,n_packets=0,n_bytes=0,idle_age=10969,priority=0actions=resubmit(,21)表21有2条规则,第一条是匹配所有目标vlan为1的网包,去掉vlan,然后从端口2(gre端口)发出。
第二条是丢弃。
cookie=0x0,duration=688.6s,table=21,n_packets=161,n_bytes=10818,idle_age=21,priority=1,dl_vlan=1actions=strip_vlan,set_tunnel:
0x1,output:
2cookie=0x0,duration=10968.912s,table=21,n_packets=2,n_bytes=148,idle_age=689,priority=0actions=drop这些规则所组成的整体转发逻辑如下图所示。
表20深入理解Neutron-OpenStack网络实现13计算节点深入理解Neutron-OpenStack网络实现14计算节点Bridgebr-tunPortbr-tunInterfacebr-tuntype:
internalPortpatch-intInterfacepatch-inttype:
patchoptions:
peer=patch-tunPortgre-2Interfacegre-2type:
greoptions:
in_key=flow,local_ip=10.0.0.100,out_key=flow,remote_ip=10.0.0.101Compute节点上发往GRE隧道的网包最终抵达Network节点上的br-tun,该网桥的规则包括:
#ovs-ofctldump-flowsbr-tunNXST_FLOWreply(xid=0x4):
cookie=0x0,duration=19596.862s,table=0,n_packets=344,n_bytes=66762,idle_age=4,priority=cookie=0x0,duration=19537.588s,table=0,n_packets=625,n_bytes=125972,idle_age=4,priority=cookie=0x0,duration=19596.602s,table=0,n_packets=2,n_bytes=140,idle_age=19590,priority=cookie=0x0,duration=19596.343s,table=1,n_packets=323,n_bytes=65252,idle_age=4,priority=cookie=0x0,duration=19596.082s,table=1,n_packets=21,n_bytes=1510,idle_age=5027,priority=cookie=0x0,duration=9356.289s,table=2,n_packets=625,n_bytes=125972,idle_age=4,priority=cookie=0x0,duration=19595.821s,table=2,n_packets=0,n_bytes=0,idle_age=19595,priority=cookie=0x0,duration=19595.554s,table=3,n_packets=0,n_bytes=0,idle_age=19595,priority=cookie=0x0,duration=19595.292s,table=10,n_packets=625,n_bytes=125972,idle_age=4,priority=cookie=0x0,duration=9314.338s,table=20,n_packets=323,n_bytes=65252,hard_timeout=300cookie=0x0,duration=19595.026s,table=20,n_packets=0,n_bytes=0,idle_age=19595,priority=cookie=0x0,duration=9356.592s,table=21,n_packets=9,n_bytes=586,idle_age=5027,priority=cookie=0x0,duration=19594.759s,table=21,n_packets=12,n_bytes=924,idle_age=5057,priority=这些规则跟Compute节点上br-tun的规则相似,完成tunnel跟vlan之间的转换。
Bridgebr-intPortqr-ff19a58b-3dtag:
1Interfaceqr-ff19a58b-3dtype:
internalPortbr-intInterfacebr-inttype:
internalPortpatch-tun网络节点br-tunbr-int深入理解Neutron-OpenStack网络实现15网络节点Interfacepatch-tuntype:
patchoptions:
peer=patch-intPorttap4385f950-8btag:
1Interfacetap4385f950-8btype:
internal该集成网桥上挂载了很多进程来提供网络服务,包括路由器、DHCP服务器等。
这些进程不同的租户可能都需要,彼此的地址空间可能冲突,也可能跟物理网络的地址空间冲突,因此都运行在独立的网络名字空间中。
规则跟computer节点的br-int规则一致,表现为一个正常交换机。
#ovs-ofctldump-flowsbr-intNXST_FLOWreply(xid=0x4):
cookie=0x0,duration=18198.244s,table=0,n_packets=849,n_bytes=164654,idle_age=43,priority=在Linux中,网络名字空间可以被认为是隔离的拥有单独网络栈(网卡、路由转发表、iptables)的环境。
网络名字空间经常用来隔离网络设备和服务,只有拥有同样网络名字空间的设备,才能看到彼此。
可以用ipnetnslist命令来查看已经存在的名字空间。
#ipnetnsqdhcp-88b1609c-68e0-49ca-a658-f1edff54a264qrouter-2d214fde-293c-4d64-8062-797f80ae2d8fqdhcp开头的名字空间是dhcp服务器使用的,qrouter开头的则是router服务使用的。
可以通过ipnetnsexecnamespaceidcommand来在指定的网络名字空间中执行网络命令,例如#ipnetnsexecqdhcp-88b1609c-68e0-49ca-a658-f1edff54a264ipaddr71:
ns-f14c598d-98:
mtu1500qdiscpfifo_faststateUPqlenlink/etherfa:
16:
3e:
10:
2f:
03brdff:
ff:
ff:
ff:
ff:
ffinet10.1.0.3/24brd10.1.0.255scopeglobalns-f14c598d-98inet6fe80:
f816:
3eff:
fe10:
2f03/64scopelinkvalid_lftforeverpreferred_lftforever可以看到,dhcp服务的网络名字空间中只有一个网络接口“ns-f14c598d-98”,它连接到br-int的tapf14c598d-98接口上。
dhcp服务是通过dnsmasq进程(轻量级服务器,可以提供dns、dhcp、tftp等服务)来实现的,该进程绑定到dhcp名字空间中的br-int的接口上。
可以查看相关的进程。
#ps-fe|grep88b1609c-68e0-49ca-a658-f1edff54a264网络名字空间dhcp服务深入理解Neutron-OpenStack网络实现16网络节点nobody2319510Oct26?
00:
00:
00dnsmasq-no-hosts-no-resolv-strict-order-bind-interfaces-interface=nsroot23196231950Oct26?
00:
00:
00dnsmasq-no-hosts-no-resolv-strict-order-bind-interfaces-interface=ns首先,要理解什么是router,router是提供跨subnet的互联功能的。
比如用户的内部网络中主机想要访问外部互联网的地址,就需要router来转发(因此,所有跟外部网络的流量都必须经过router)。
目前router的实现是通过iptables进行的。
同样的,router服务也运行在自己的名字空间中,可以通过如下命令查看:
#ipnetnsexecqrouter-2d214fde-293c-4d64-8062-797f80ae2d8fipaddr66:
qg-d48b49e0-aa:
mtu1500qdiscpfifo_faststateUPqlenlink/etherfa:
16:
3e:
5c:
a2:
acbrdff:
ff:
ff:
ff:
ff:
ffinet172.24.4.227/28brd172.24.4.239scopeglobalqg-d48b49e0-aainet172.24.4.228/32brd172.24.4.228scopeglobalqg-d48b49e0-aainet6fe80:
f816:
3eff:
fe5c:
a2ac/64scopelinkvalid_lftforeverpreferred_lftforever68:
qr-c2d7dd02-56:
mtu1500qdiscpfifo_faststateUPqlenlink/etherfa:
16:
3e:
ea:
64:
6ebrdff:
ff:
ff:
ff:
ff:
ffinet10.1.0.1/24brd10.1.0.255scopeglobalqr-c2d7dd02-56inet6fe80:
f816:
3eff:
feea:
646e/64scopelinkvalid_lftforeverpreferred_lftforever可以看出,该名字空间中包括两个网络接口。
第一个接口qg-d48b49e0-aa(即K)是外部接口(qg=qgateway),将路由器的网关指向默认网关(通过router-gateway-set命令指定),这个接口连接到br-ex上的tapd48b49e0-aa(即L)。
第二个接口qr-c2d7dd02-56(即N,qr=qbridge)跟br-int上的tapc2d7dd02-56口(即M)相连,将router进程连接到集成网桥上。
查看该名字空间中的路由表:
#ipnetnsexecqrouter-2d214fde-293c-4d64-8062-797f80ae2d8fiproute172.24.4.224/28devqg-d48b49e0-aaprotokernelscopelinksrc172.24.4.22710.1.0.0/24devqr-c2d7dd02-56protokernelscop
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 深入 理解 NeutronOpenStack 网络 实现