At home, I am connected with an IPv6 address and additionally, my provider provides a NAT-like setup through which I receive a public IPv4 address that I share with other customers (the reason being obviously that we are running low on IPv4 addresses).

As a result, I cannot reach my devices at home (e.g. my VPN gateway) when I am on an IPv4 network. However, I do have a server that has both an IPv4 and an IPv6 address. Thus, it should be possible to reach my home devices if I go through my server.

Here is what I have in mind so far: Since on IPv6, each device gets their own IP, my server at home gets a static IPv6 IP. My remote server already has both static IPv4 and IPv6.

When I now want to reach my OpenVPN server at home, previously I would open port 1194 in my router and NAT would pass connections along to the server there. In my new scenario, I want to connect on port 1194 (or a different, doesn't matter) on my remote server and it should take that connection and tunnel it to my home server (seeing as they both have IPv6).

Graphically, this would mean:

Mobile Device (IPv4) --> Remote Server (IPv4+IPv6) --> Home Server (IPv6)

But this should only happen on select ports (or is there even a more clever way than to select by port?).

My question is, how do I achieve this setup?

At which level should this operate? If I want to do it by port, I obviously have to forward the packet at the TCP/UDP layer. My first idea would be iptables, but can iptables forward a packet to a remote IP? Or is there other software that can? Or should I create a tunnel between the two servers and then forward this locally? How would I go about that?

  • 1
    Have you considered using an IPv6 tunnel broker for your laptop? – Michael Hampton Feb 28 '14 at 2:58
  • @MichaelHampton thanks for the suggestion, but I much rather would like to have a way that does not need changes on the device as I also intend to make connection from my phone (android) and likely other devices. The setup should be as simple as before from the devices perspective. – javex Mar 2 '14 at 14:16

I finally found a solution with Forwarding IPv4 Ports to IPv6-only Hosts which basically uses socat:

socat TCP4-LISTEN:22,fork,su=nobody TCP6:[2a01:198:79d:1::8]:22

My solution is basically the same except I use a hostname except for a static IP there. Take care not to use square brackes with a hostname as it will then interpret it as an IP.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.