Route all traffic through the 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
izghitu
OpenVpn Newbie
Posts: 5
Joined: Mon Aug 29, 2011 6:51 pm

Route all traffic through the VPN

Post by izghitu » Thu Apr 27, 2017 3:11 pm

Hi,

I have following working setup:

Code: Select all

port 1234
proto udp
dev tun

ca      /etc/openvpn/keys/ca.crt    # generated keys
cert    /etc/openvpn/keys/server.crt
key     /etc/openvpn/keys/server.key  # keep secret
dh      /etc/openvpn/keys/dh2048.pem

server 10.9.7.0 255.255.255.0  # internal tun0 connection IP
ifconfig-pool-persist ipp.txt

keepalive 10 120

comp-lzo         # Compression - must be turned on at both end
persist-key
persist-tun

status log/openvpn-status.log

verb 3  # verbose mode
client-to-client
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "redirect-gateway"

Code: Select all

client
dev tun
proto udp
remote HOST 1234
resolv-retry infinite
nobind
persist-key
persist-tun

comp-lzo
redirect-gateway
dhcp-option DNS 8.8.8.8


# Set log file verbosity.
verb 3
#client-to-client

...
certificate/keys data
---
All works fine, traffic to the outside is routed via the VPN server and I get the external IP as the VPN server when going to http://www.whatismyip.com.

The problem that I have is that when I access a website that is hosted on the same server as the VPN server then the webserver on that site sees my real IP and not the VPN IP.

Is there any way to make the webserver see the VPN server IP instead of my PC IP?
Please let me know.
Thanks

heinzelrumpel
OpenVpn Newbie
Posts: 19
Joined: Fri Jan 11, 2013 10:59 am

Re: Route all traffic through the VPN

Post by heinzelrumpel » Fri Apr 28, 2017 8:06 pm

I think source Nat in your internal IP should do it

kevin.richards
OpenVpn Newbie
Posts: 7
Joined: Fri May 19, 2017 11:29 am

Re: Route all traffic through the VPN

Post by kevin.richards » Sat May 20, 2017 8:04 am

one solution could be VPN over VPN layer.

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Route all traffic through the VPN

Post by TinCanTech » Sat May 20, 2017 12:05 pm

izghitu wrote:The problem that I have is that when I access a website that is hosted on the same server as the VPN server then the webserver on that site sees my real IP
That is because of the way --redirect-gateway works.

The only solution I am aware of is to use the server's VPN IP (eg. 10.8.0.1)

Post Reply