Route public IP from openVPN Server through VPN

Need help configuring your VPN? Just post here and you'll get that help.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
nudeltabak
OpenVpn Newbie
Posts: 6
Joined: Tue Feb 16, 2016 4:56 pm

Route public IP from openVPN Server through VPN

Post by nudeltabak » Tue Feb 16, 2016 5:06 pm

Hi there,

I have a server which has an apache webserver and openVPN Server installed. So my openVPN connection works fine. All Traffic is tunneld through it. But if I want to access my Webserver via https and via the puplic IP form the server, my traffic will not go through the VPN connection. So i guess the problem occurs, because of the routing for the puplic IP from the server.

How to solve that?

My config files for a client and the server:

server.conf

Code: Select all

port 10434
proto udp
dev tun
sndbuf 0
rcvbuf 0
ca ca.crt
cert server.crt
key server.key
dh dh.pem
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 192.168.5.1"
keepalive 10 120
comp-lzo
persist-key
persist-tun
status openvpn-status.log
verb 3
crl-verify /etc/openvpn/easy-rsa/pki/crl.pem

user nobody
group nogroup

log-append /var/log/openvpn.log

tun-mtu 1460
mssfix 1420
client.ovpn

Code: Select all

client
dev tun
proto udp
pull
sndbuf 0
rcvbuf 0
remote dns.example.com 10434
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
comp-lzo
verb 3
<ca>
...

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: Route public IP from openVPN Server through VPN

Post by Traffic » Tue Feb 16, 2016 10:07 pm

nudeltabak wrote:But if I want to access my Webserver via https and via the puplic IP form the server, my traffic will not go through the VPN connection
Do you mean from the client ?

nudeltabak
OpenVpn Newbie
Posts: 6
Joined: Tue Feb 16, 2016 4:56 pm

Re: Route public IP from openVPN Server through VPN

Post by nudeltabak » Wed Feb 17, 2016 12:19 am

Traffic wrote:Do you mean from the client ?
No I don't. I mean I want to connect as a Client to the Servers puplic Ip / DNS. If I do that it will not go through the VPN tunnel.

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: Route public IP from openVPN Server through VPN

Post by Traffic » Wed Feb 17, 2016 12:32 am

No it will not ..

nudeltabak
OpenVpn Newbie
Posts: 6
Joined: Tue Feb 16, 2016 4:56 pm

Re: Route public IP from openVPN Server through VPN

Post by nudeltabak » Wed Feb 17, 2016 1:38 am

Traffic wrote:No it will not ..
So is there no way to route this through the vpn?

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: Route public IP from openVPN Server through VPN

Post by Traffic » Wed Feb 17, 2016 1:55 am

From your VPN server ~ To your VPN server ~ To your HTTP(s) server ... all on the same IP ?

Am I missing something ? :?

nudeltabak
OpenVpn Newbie
Posts: 6
Joined: Tue Feb 16, 2016 4:56 pm

Re: Route public IP from openVPN Server through VPN

Post by nudeltabak » Wed Feb 17, 2016 2:11 am

Traffic wrote:From your VPN server ~ To your VPN server ~ To your HTTP(s) server ... all on the same IP ?

Am I missing something ? :?
From my Client, which is connected to the VPN server. The HTTP server is on the same IP.

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: Route public IP from openVPN Server through VPN

Post by Traffic » Wed Feb 17, 2016 2:29 am

Traffic wrote:
nudeltabak wrote:But if I want to access my Webserver via https and via the puplic IP form the server, my traffic will not go through the VPN connection
Do you mean from the client ?
nudeltabak wrote:From my Client, which is connected to the VPN server
because of --redirect-gateway def1 you cannot make HTTP/s go over the tunnel to the same IP as the VPN server unless you use policy based routing .. which is beyond the scope of this Forum.

nudeltabak
OpenVpn Newbie
Posts: 6
Joined: Tue Feb 16, 2016 4:56 pm

Re: Route public IP from openVPN Server through VPN

Post by nudeltabak » Wed Feb 17, 2016 10:35 am

nudeltabak wrote:But if I want to access my Webserver via https and via the puplic IP form the server, my traffic will not go through the VPN connection.
I meant "puplic IP" <-- from the server

Even a traceroute to my servers puplic IP does not go through the VPN.

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: Route public IP from openVPN Server through VPN

Post by Traffic » Wed Feb 17, 2016 11:24 am

Traffic wrote:because of --redirect-gateway def1 you cannot make HTTP/s go over the tunnel to the same IP as the VPN server unless you use policy based routing .. which is beyond the scope of this Forum
If HTTP/s packets were sent to the server public IP over the VPN then the VPN data packets would also go over the VPN .. which breaks the VPN.

nudeltabak
OpenVpn Newbie
Posts: 6
Joined: Tue Feb 16, 2016 4:56 pm

Re: Route public IP from openVPN Server through VPN

Post by nudeltabak » Wed Feb 17, 2016 12:07 pm

Traffic wrote:If HTTP/s packets were sent to the server public IP over the VPN then the VPN data packets would also go over the VPN .. which breaks the VPN.
Could you explain this point a bit more?

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: Route public IP from openVPN Server through VPN

Post by Traffic » Wed Feb 17, 2016 12:31 pm

See --redirect-gateway step(1) in The Manual v23x

You cannot connect to the public IP of your VPN server with HTTP/s unless you use policy based routing .. which is probably not available to your windows client.

So just use the private IP 10.8.0.1

:roll:

Post Reply