auto tun0 iface tun0 inet tunnel address10.0.0.1 netmask30 mode gre endpoint2.2.2.2 ttl64
同样编辑B上的/etc/network/interfaces文件,加入以下内容
1 2 3 4 5 6 7
auto tun0 iface tun0 inet tunnel address10.0.0.2 netmask30 mode gre endpoint1.1.1.1 ttl64
在A、B上执行ifup tun0启动隧道
在A上ping B的内网IP,应该是已经通了
1 2 3 4 5 6 7 8 9 10 11 12 13
$ ping 10.0.0.2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=35.1 ms 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=33.4 ms 64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=32.9 ms 64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=34.2 ms 64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=33.8 ms 64 bytes from 10.0.0.2: icmp_seq=6 ttl=64 time=34.0 ms 64 bytes from 10.0.0.2: icmp_seq=7 ttl=64 time=33.4 ms 64 bytes from 10.0.0.2: icmp_seq=8 ttl=64 time=32.7 ms --- 10.0.0.2 ping statistics --- 8 packets transmitted, 8 received, 0% packet loss, time 17ms rtt min/avg/max/mdev = 32.691/33.682/35.081/0.734 ms