동일한 시스템에 있는 OpenVPN 서버와 OpenVPN 클라이언트

동일한 시스템에 있는 OpenVPN 서버와 OpenVPN 클라이언트

저는 Debian 기반 가상 머신에서 여러 클라이언트를 위해 OpenVPN 서버를 실행하고 있으며 여러 가지 복잡한 이유로 해당 시스템을 다른 (외부) OpenVPN 서버에 연결하여 클라이언트 트래픽이 가상 시스템과 외부 VPN을 통과하도록 하려고 합니다. 월드 와이드 웹. 외부 VPN 서버도 OpenVPN을 실행하고 있기 때문에 내 가상 시스템이 외부 VPN 공급자의 OpenVPN 클라이언트 및 내 클라이언트의 OpenVPN 서버 역할을 하는 중개자 역할을 할 수 있다고 생각했습니다. 그런데 설정하려고 하면 OpenVPN 인스턴스의 장치가 서로 간섭하는 것 같습니다.

기본적으로 제가 원하는 설정은 다음과 같습니다: Client --> [openvpn 서버가 있는 내 VM#1] --> [VPN 서비스 공급자 클라이언트가 있는 내 VM#2] --> internet . 나보다 지식이 풍부한 누군가가 설정 방법에 대해 조언을 제공할 수 있기를 바랍니다.


VM#1 [openvpn 서버]

root@buster:~#cat /etc/openvpn/server/server.conf
port 1199
proto tcp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-crypt tc.key
topology subnet
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1 bypass-dhcp"
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 1.1.1.1"
push "dhcp-option DNS 1.0.0.1"
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
verb 3
crl-verify crl.pem


ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.33.10  netmask 255.255.255.0  broadcast 192.168.33.255

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.8.0.1  netmask 255.255.255.0  destination 10.8.0.1


route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.8.0.0        0.0.0.0         255.255.255.0   U     0      0        0 tun0
192.168.33.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1

openvpn 서버 포트 1199가 호스트로 전달되었습니다.

======================

VM#2 [외부 서비스 VPN 클라이언트 연결됨]

root@buster:~#cat external-client.ovpn
client
dev tun
proto tcp
remote *.*.*.* 1188
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
ignore-unknown-option block-outside-dns
block-outside-dns
verb 3
<ca>
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
</ca>
<cert>
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
</key>
<tls-crypt>
-----BEGIN OpenVPN Static key V1-----
-----END OpenVPN Static key V1-----
</tls-crypt>


ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.33.11  netmask 255.255.255.0  broadcast 192.168.33.255

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.8.0.2  netmask 255.255.255.0  destination 10.8.0.2


route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.8.0.1        128.0.0.0       UG    0      0        0 tun0
0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.8.0.0        0.0.0.0         255.255.255.0   U     0      0        0 tun0
128.0.0.0       10.8.0.1        128.0.0.0       UG    0      0        0 tun0
*external-client-ip* 10.0.2.2        255.255.255.255 UGH   0      0        0 eth0
192.168.33.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1

답변1

두 서버 구성이 표시되지 않으면 두 VPN 서버에 서로 다른 IPv4 서브넷을 제공하는 것을 잊어버린 것 같습니다.

구성에서 다음 줄을 볼 수 있습니다.

server 10.8.0.0 255.255.255.0

따라서 다른 하나에는 다른 서브넷이 필요합니다. 예를 들어:

server 10.9.0.0 255.255.255.0

관련 정보