如何配置ip/ip或ip/gre tunnel构建VPN

Q:如何配置ip/ip或ip/gre tunnel构建VPN
A:通过ip/ip或ip/gre tunnel能够通过两个tunnel网关连接两个私有的网络
例如:
Public Network
------------------------------------
| 10.71.101.100/24 | 10.71.101.200/24
GRE Router A GRE Router B
| 192.168.0.1/24 | 192.168.10.1/24
| |
--------------------- --------------------
| Private Network A | | Private Network B |
| | | |
ClientA1 ClientAn ClientB1 ClientBm
192.168.0.10/24 192.168.10.10/24

假如没有配置tunnel,Private Network A是没有办法访问Private Network B中的机器的,配置
了tunnel之后,两个Private Network中的机器互相访问了。

所需的配置是主要是在两个GRE Router上配置的
GRE Router A的配置 (gre):
# modprobe ipgre
# ip tunnel add netb mode gre remote 10.71.101.200 local 10.71.101.100 ttl 255
# ip link set netb up
# ip addr add 192.168.0.1 dev netb
# ip route add 192.168.10.0/24 dev netb

GRE Router B的配置 (gre):
# modprobe ipgre
# ip tunnel add neta mode gre remote 10.71.101.100 local 10.71.101.200 ttl 255
# ip link set neta up
# ip addr add 192.168.10.1 dev neta
# ip route add 192.168.0.0/24 dev neta

在Private Network A上的主机配置:
# route add default gw 192.168.0.1

在Private Network B上的主机配置:
# route add default gw 192.168.10.1

对ip/ip tunnel的配置能够通过加载ipip模块,并将ip tunnel命令中的mode改为ipip加以实现。


文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!