玩转Openvswitch第八站:Interface和Tunnel(下)

以下内容已屏蔽图片优化访问速度
IPSec顾名思义,安全隧道,意味着下面三个方面:
信息完整性——认证
信息的私密性——加密
信息不会被Replay


[IMG]
所以IPSec有一套协议来保证这三点。



[IMG]


IPSec隧道的连接也有两端,两端之间多通过对称加密来保证私密性。


所以两端都要建立Security Association,保存两边约定好的加密协议,对称秘钥,对方的IP地址等,对阵的秘钥要通过协议互换Exchange。


双方建立了连接之后,就可以对原始的包进行认证和加密了。



[IMG]


在原始的包之外,加入一个ESP的包头做加密。在外层的proto处的协议指定为ESP。


[IMG]


IPSec隧道常用于两个VPC之间的打通。


或者用于公有云和私有云之间的打通。如AWS里面:
[IMG]


配置这个VPN,需要配置下面三种东西。



[IMG]


一个是IKE,就是秘钥交换。


[IMG]


一个是IPSec


[IMG]


一个是Tunnel


[IMG]
GRE和IPSec一起使用,则包结构如下。

[IMG]


又到了做实验的时候了。



[IMG]


创建网桥如下:


[IMG]


在虚拟机Instance01上


ovs-vsctl add-br testbr
ifconfig testbr 10.0.0.1/24
ovs-vsctl add-port testbr gre0 -- set Interface gre0 type=gre options:local_ip=192.168.100.100 options:remote_ip=192.168.100.101
ovs-vsctl add-port testbr vxlan0 -- set Interface vxlan0 type=vxlan options:local_ip=192.168.100.100 options:remote_ip=192.168.100.102


在虚拟机Instance02上


ovs-vsctl add-br testbr
ifconfig testbr 10.0.0.2/24
ovs-vsctl add-port testbr gre0 -- set Interface gre0 type=gre options:local_ip=192.168.100.101 options:remote_ip=192.168.100.100
ovs-vsctl add-port testbr ipsec0 -- set Interface ipsec0 type=ipsec_gre options:local_ip=192.168.100.101 options:remote_ip=192.168.100.102 options:psk=password


在虚拟机Instance03上


ovs-vsctl add-br testbr
ifconfig testbr 10.0.0.3/24
ovs-vsctl add-port testbr vxlan0 -- set Interface vxlan0 type=vxlan options:local_ip=192.168.100.102 options:remote_ip=192.168.100.100
ovs-vsctl add-port testbr ipsec0 -- set Interface ipsec0 type=ipsec_gre options:local_ip=192.168.100.102 options:remote_ip=192.168.100.101 options:psk=password


不好,出现了环,没关系enable STP


ovs-vsctl set Bridge testbr stp_enable=true


监听Instance01的eth0: tcpdump -n -e -i eth0


[IMG]


监听Instance02的eth0: tcpdump -n -e -i eth0


[IMG]


监听Instance03的eth0: tcpdump -n -e -i eth0


[IMG]


最后说一下STP,全称Spanning Tree Protocol,即通过协议,将一个有环的二层网络变成一颗树。
别墅建到60层,可以在家里种菜、遛狗,这楼盘忒牛逼了! 孟晚舟获保释,但斗争才刚刚开始! DCOS的服务发现与负载均衡功能 人神话了阿胶,却欠下全世界的驴一句“对不起” 超逆天“胶水”,几乎可以修复世界上所有物品!汽车、手机、地板、鱼缸……
好看吗?
总执行时间0.0766139030456543,文章查询时间0.04945969581604004,分类查询时间0.010117053985595703,其他脚本0.00032138824462890625,模板渲染0.01671576499938965