CentOS下GRE隧道配置

一、拓扑图:

L2中gre.sh配置内容如下:
insmod /lib/modules/2.6.32-71.el6.x86_64/kernel/net/ipv4/ip_gre.ko(开机加载内核模块)
ip tunnel add tunnel0 mode gre remote192.168.77.137 local 192.168.31.9 ttl 245
ip link set tunnel0 up mtu 1400
ip addr add 172.16.1.2/30  dev tunnel0
ip addr del 172.16.1.2/30 peer 172.16.1.1/30 dev tunnel0
ip addr add 172.16.1.2/30 peer 172.16.1.1/30 dev tunnel0
ip route add 20.0.1.1/32dev tunnel0
chmod +x /etc/init.d/gre.sh
echo "/etc/init.d/gre.sh">> /etc/rc.d/rc.local(将该文件加载到开机启动的系统文件中)

四、验证隧道配置:
L1系统下 ip addr show 结果如下(L2中类似):

L2上面的Ifconfig查看:

猜你喜欢

转载自www.linuxidc.com/Linux/2017-05/144351.htm