Linux创建gre隧道
ubuntu
写入网卡/etc/network/interfaces
ubuntu通用
auto tun0
iface tun0 inet static
address <local tunnel IP>
netmask <tunnel subnet mask>
pre-up iptunnel add tun1 mode gre local <local IP> remote <remote IP> ttl 255
up ifconfig tun1 multicast
pointopoint <remote tunnel IP>
post-down iptunnel del tun1
Centos类方法
约定:
hostA IP:公网 100.xx.xx.101 内网10.0.0.1
hostB IP:公网192.xx.xx.101 内网10.0.0.2
HOST A配置
cat /etc/sysconfig/network-scripts/ifcfg-tun0
DEVICE=tun0
BOOTPROTO=none
ONBOOT=yes
TYPE=GRE
PEER_OUTER_IPADDR=192.xx.xx.102 #hostB IPv4
PEER_INNER_IPADDR=10.0.0.2
MY_INNER_IPADDR=10.0.0.1
host B配置
cat /etc/sysconfig/network-scripts/ifcfg-tun0
DEVICE=tun0
BOOTPROTO=none
ONBOOT=yes
TYPE=GRE
PEER_OUTER_IPADDR=100.xx.xx.101 #hostA IPv4
PEER_INNER_IPADDR=10.0.0.1
MY_INNER_IPADDR=10.0.0.2
设定好配置文件用ifup上线隧道做测试,ifdown下线隧道。
ifup tun0
最后用ping和tcpdump抓包分析
tcpdump -n -i eth1 proto 47
上述内容采摘整理自:
https://www.linickx.com/gre-example-for-centosrhel
https://onvox.net/articles/2009-01-19-how-to-create-ipv4-gre-tunnels-in-ubuntu
none
6666666666666