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

IPSec顾名思义,安全隧道,意味着下面三个方面:

  • 信息完整性——认证

  • 信息的私密性——加密

  • 信息不会被Replay

7b99e0f814e6e171501d695ee136f762.png

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

b61cbd6140927bc5c82fa8f8ae258399.png

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

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

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

db72663becfb77de62cce22b8a20bce3.png

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

3997125a7f45aaf8f01ae84f15ea393b.png

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

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

f955ed3a53b71f3372543991fac36bad.png

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

a899a7b41c8a01033c6ab1a894e28ec1.png

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

2fa1783b10aeceeaf240fb86a75f945e.png

一个是IPSec

ef0fce171c140d0b077816ec2af0c554.png

一个是Tunnel

ac8a4f54b5aa0721a285c26809ad48a5.png

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

855c905b88af468c2df4b150002602a3.png

又到了做实验的时候了。

1ae3f7b1c224f45c96a4a7d31359911e.png

创建网桥如下:

156e2114c289ef4b2097c120a7499f6e.png

在虚拟机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

31e9a384cebb2c1b5a49d5dd45a64090.png

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

3b01fb141e247b9543ba3b074572c65b.png

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

fa00365c51fcf9201ac112bfaf0aee23.png

最后说一下STP,全称Spanning Tree Protocol,即通过协议,将一个有环的二层网络变成一颗树。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

popsuper1982

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值