简单GRE隧道搭建
1.网络拓扑
2.创建GRE隧道
2.1.Linux虚拟机(ubuntu18.04系统)
2.1.1.配置ip
R1:
#ip link set eth0 up
#ip addr add 169.254.1.108/24 dev eth0
#ip link set eth1 up
#ip addr add 169.254.2.108/24 dev eth1
R2:
#ip link set eth0 up
#ip addr add 169.254.1.109/24 dev eth0
#ip link set eth1 up
#ip addr add 169.254.3.109/24 dev eth1
2.1.2.创建gre接口
R1:
#ip tunnel add gre1 mode gre local 169.254.1.108 remote 169.254.1.109 dev eth0 key 1 csum (隧道接口地址local、remote)
#ip link set gre8 up
#ip addr add 10.10.10.1 peer 10.10.10.2/24 dev gre1 (隧道内地址)
R2:
#ip tunnel add gre1 mode gre local 169.254.1.109 remote 169.254.1.108 dev eth0 key 1 csum (隧道接口地址local、remote)
#ip link set gre9 up
#ip addr add 10.10.10.2 peer 10.10.10.1/24 dev gre1 (隧道内地址)
2.1.3.创建静态路由
R1:
#ip route 169.254.3.0/24 via 10.10.10.1
R2:
#ip route 169.254.2.0/24 via 10.10.10.2
2.2.路由器配置
2.2.1.创建gre接口及配置
R1:(只需配置红框内即可,R2同理)
2.2.2.创建静态路由(若使用动态路由协议则不需要手动创建)
R1:
3.验证
(1)在GRE接口开启(up)的情况下,在L2机器ping R1 机器的eth0、eth1有回应;
(2)在GRE接口关闭(down)的情况下,在L2机器ping R1 机器的eth0、eth1无回应。
抓包分析: