Tunnel to local services on OpenVPN server - iptables

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

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

Post Reply
a_kemper
OpenVpn Newbie
Posts: 1
Joined: Thu Jan 08, 2015 7:10 am

Tunnel to local services on OpenVPN server - iptables

Post by a_kemper » Thu Jan 08, 2015 7:46 am

I have a pretty normal routed OpenVPN installation, i.e. with the client using tun interfaces and the server doing IP masquerading. The only exception from a standard setup is using encrypted TCP instead of UDP packets. So far everything is nice and easy.
Now I would like to configure the client for tunneling also requests to other local (IMAP) services running on the VPN-gateway. These are accessible by either the gateway public IP or alternatively the OpenVPN internal IP (10.8.0.1).
From client perspective (Thunderbird) I'd always like to use the gateway public IP, which in case of the VPN tunnel being established needs some kind of translation to the internal IP (10.8.0.1). Initially I thought I'd be able to do this by configuring the server with "redirect-gateway block-local", but this only prevents the (Ubuntu) client from bypassing any traffic outside the tunnel.

Instead I most likely need DNAT on the client. With respect to http://l7-filter.sourceforge.net/PacketFlow.png I assume this should be something like

Code: Select all

iptables -t nat -A OUTPUT -p tcp ! --dport 1194 -j DNAT --to 10.8.0.1
But this doesn't work. Can anyone give me a hint what is missing there or where I have a misunderstanding?

Thx,
Andreas

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Tunnel to local services on OpenVPN server - iptables

Post by maikcat » Thu Jan 08, 2015 8:52 am

From client perspective (Thunderbird) I'd always like to use the gateway public IP,
so you want when your vpn connected client connects to your openvpn servers PUBLIC ip on imap service
you want the openvpn to respond via its vpn interface?

Michael.

Post Reply