centos设置gre tunnel

环境:centos 7 * 2
[root@srv-1 ~]# uname -a
Linux srv-1 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

拓扑:
centos设置gre tunnel_第1张图片
1、Host A设置:

1.1 开启路由转发:

# vim /etc/sysctl.conf
net.ipv4.ip_forward=1
# sysctl -p

1.2 加载gre模块及gre配置

[root@srv-1 ~]# cat gre.conf.sh
#!/bin/bash
# 1. setup gre kernel module
modprobe ip_gre
#2. check gre kernel module
lsmod | grep gre
#3. create gre instance
ip tunnel add gre1 mode gre remote 192.168.1.16 local 192.168.1.6 ttl 255
ip link set gre1 up
ip address add 10.10.10.1 peer 10.10.10.2 dev gre1
#4. disable firewalld
systemctl stop firewalld
#5. test
echo "=================test==================="
ping 10.10.10.2 -c 1
echo "=================test==================="
#6. unset gre instance
#ip link set gre1 down
#ip tunnel del gre1

2、Host B设置:

2.1 开启路由转发:

# vim /etc/sysctl.conf
net.ipv4.ip_forward=1
# sysctl -p

2.2 加载gre模块及gre配置

[root@srv-1 ~]# cat gre.conf.sh
#!/bin/bash
# 1. setup gre kernel module
modprobe ip_gre
#2. check gre kernel module
lsmod | grep gre
#3. create gre instance
ip tunnel add gre1 mode gre remote 192.168.1.6 local 192.168.1.16 ttl 255
ip link set gre1 up
ip address add 10.10.10.2 peer 10.10.10.1 dev gre1
#4. disable firewalld
systemctl stop firewalld
#5. test
echo "=================test==================="
ping 10.10.10.1 -c 1
echo "=================test==================="
#6. unset gre instance
#ip link set gre1 down
#ip tunnel del gre1

3、test结果(在Host B上抓包如下):
centos设置gre tunnel_第2张图片
centos设置gre tunnel_第3张图片
参考:RFC1701 和 RFC 1702

你可能感兴趣的:(LINUX)