以下内容已屏蔽图片优化访问速度 |
---|
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,即通过协议,将一个有环的二层网络变成一颗树。 |