Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 2 servers from 2 different companies

The first server is a VPS where i host my websites (lets say it has IP The second server is a Minecraft server (lets say it has IP

On my VPS i have a domain and subdomain for the minecraft website (lets say its

If you would go to on your browser, you would end up on and on the website.

What I'm trying to do is, from Minecraft when you go to, you would end up on

So for example:       ->    ->

Now, my network interfaces are as follows I have two IPs on my VPS, the main one is venet0:0 (

This are the network interfaces

auto lo
iface lo inet loopback
        up ip route replace dev lo

# Auto generated venet0 interfaces
auto venet0
iface venet0 inet static
        up route add -net netmask dev venet0
        up route add default gw

auto venet0:0
iface venet0:0 inet static

auto venet0:1
iface venet0:1 inet static

Can someone please tell me what commands i would need to write in iptables in order to proxy that minecraft server from my VPS?

Thank you!

share|improve this question
up vote 1 down vote accepted

I would simply point to, otherwise you pay triple for all the minecraft traffic: incoming to, outgoing from and incoming to On I would set up a simple webserver that only sends redirects to something like, which would live on

And unless the network at both companies is set up in a fairly relaxed (broken) way, you will have to do SNAT to avoid asymettric routing. Thus any possible iptables solution also loses all accountability information: all traffic from comes from and know nothing about the real source of the traffic.

That said, this should do the trick:

iptables -t nat -A PREROUTING -d --dport 25565 -j DNAT --to
iptables -t nat -A POSTROUTING -d --dport 25565 -s '!' -j SNAT --to-source
share|improve this answer
thank you for the swift explanation! – Highstrike Apr 6 '13 at 12:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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