I'm looking for some help getting a port forward setup to a VM running Ubuntu 12.04 on my LAN. I can forward the port to the VM successfully and connect to the service over the Internet. But when I connect the OpenVPN connection, the external access to the service no longer works. At that point my default gateway becomes my VPN's "tap0" adapter. I can see incoming traffic with tcpdump, but it appears the return traffic is never making it back. Local access to this port within my LAN works too even with the VPN connected, so its just when someone tries to access it over the Internet using the port forward.

I know I need either a static route or an iptables entry (or both) to ensure the return traffic goes out over my eth0/LAN/WAN connection and not the VPN route, but I'm not sure what to add. So I have:

WAN IP: x.x.x.x VPN IP: y.y.y.y LAN IP: z.z.z.z

I want to forward port p from WAN IP to LAN IP, and have the return traffic sent back to my routers gateway instead of the VPN gateway.

  • could you elaborate more? I don't quite get your exact setup. You have a server in your LAN with a VM inside. What virtualization? Is traffic to the VM routed or bridged? Your VM is the VPN client? I assume the VPN server creates a bridge, because of tap, not tun? Right? Do you have overlapping subnets (e.g. your LAN and the VPN server's net)? Do you want that all traffic goes through the VPN, if connected?
    – Thomas
    May 30 '14 at 7:28
  • Sure, yes the server is running Oracle Virtual Box, it has a local IP on 192.168.1.x. The VM has another IP using bridged networking on 192.168.1.x. When I connect to a third party VPN provider from the Linux VM's OpenVPN client the VPN IP is 10.x.x.x so they dont overlap. So what I want is for all traffic to go over the VPN while connected, EXCEPT for this return traffic over one certain port.
    – Josh
    May 30 '14 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.