多机房OPENVPN互联的解决方法

    Read

一、基础环境

$ uname -a
Linux openvpn-server.t4x.org 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ uname -r
3.10.0-693.el7.x86_64
$ uname -m
x86_64

二、IP信息

杭州机房 : (Centos 7.4)
VPN-SERVER:10.4.0.4(公网IP)、192.168.101.1(内网IP)
机房主机IP:192.168.101.2(无公网IP)


北京机房 : (Centos 6.8)
VPN-SERVER:10.4.0.8(公网IP)、192.168.103.1(内网IP)
机房主机IP:192.168.103.2(无公网IP)
SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

广东机房:(Centos 7.4)
VPN-SERVER:10.4.0.6(公网IP)、192.168.102.1(内网IP)
机房主机IP:192.168.102.2(无公网IP)

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/


1:由于用vm模拟,需要首先将宿主机上面的网关删除,以免影响实验效果!!!
2:调试前,将firewalld关闭,以免影响实验效果!!!

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

三、OPENVPN服务端安装

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

四、OPENVPN服务端证书生成

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

五、OPENVPN客户端证书生成

方式1:ca证书在pki目录下

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

方式2:ca证书不在pki目录下

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

六、OPENVPN所有证书

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

七、OPENVPN服务端配置

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

八、OPENVPN客户端配置

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

九、服务端拨号

服务端:


客户端(广东):

VPN段IP拨号验证:
广东IP:10.8.0.10

从vpn客户端机房(广东机房)到VPN服务端机房(杭州机房)互通验证:SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

到VPN-SERVER(192.168.101.1):


到杭州机房主机(192.168.101.2):

解决方法1:(在192.168.101.2服务器配置到10.8.0.0/24网段的路由)

解决方法2:(在192.168.101.1做IP伪装)
SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

从VPN服务端机房(杭州机房)到vpn客户端机房(广东机房)互通验证:SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

十、多网互通完整配置:

服务端配置(杭州机房[192.168.101.x/24]):


客户端配置(广东机房[192.168.102.x/24]):

客户端配置(北京机房[192.168.103.x/24]):
SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

互访验证:SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

vpn server服务器到其他服务器:


北京内网服务器(192.168.103.1)到其他服务器:
SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

备注信息:SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

Each pair of ifconfig-push addresses represent the virtual client and server IP endpoints. They must be taken from successive /30 subnets in order to be compatible with Windows clients and the TAP-Windows driver. Specifically, the last octet in the IP address of each endpoint pair must be taken from this set:SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

[ 1, 2] [ 5, 6] [ 9, 10] [ 13, 14] [ 17, 18]
[ 21, 22] [ 25, 26] [ 29, 30] [ 33, 34] [ 37, 38]
[ 41, 42] [ 45, 46] [ 49, 50] [ 53, 54] [ 57, 58]
[ 61, 62] [ 65, 66] [ 69, 70] [ 73, 74] [ 77, 78]
[ 81, 82] [ 85, 86] [ 89, 90] [ 93, 94] [ 97, 98]
[101,102] [105,106] [109,110] [113,114] [117,118]
[121,122] [125,126] [129,130] [133,134] [137,138]
[141,142] [145,146] [149,150] [153,154] [157,158]
[161,162] [165,166] [169,170] [173,174] [177,178]
[181,182] [185,186] [189,190] [193,194] [197,198]
[201,202] [205,206] [209,210] [213,214] [217,218]
[221,222] [225,226] [229,230] [233,234] [237,238]
[241,242] [245,246] [249,250] [253,254]SourceByrd's Weblog-https://note.t4x.org/project/use-openvpn-computer-room-interconnect/

因为子网内有效的主机数为2^n-2,所以依上面的条件2^2-2=2,即每个子网中实际的主机数为4,子网掩码=256-4=252,使用的又是c类地址,所以该业务所使用的子网掩码的形式为255.255.255.252,可以产生256/4-2=64-2=62个子网,每个子网可用的最大的主机数为2,具体的IP地址如下:
网络 子网掩码 IP地址范围 子网地址 子网广播地址
局域1 255.255.255.252 10.8.0.5~6 10.8.0.4 10.8.0.7
局域2 255.255.255.252 10.8.0.9~10 10.8.0.8 10.8.0.11
局域3 255.255.255.252 10.8.0.13~14 10.8.0.12 10.8.0.15
……
局域62 255.255.255.252 10.8.0.249~250 10.8.0.248 10.8.0.251

十一、证书吊销:

证书吊销:

参考文档:
1:https://openvpn.net/index.php/open-source/documentation/howto.html

申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Byrd
  • by Published on July 5, 2020
  • 原文链接:https://note.t4x.org/project/use-openvpn-computer-room-interconnect/
匿名

Comment

Anonymous

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: