0

I have 2 servers from 2 different companies

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

On my VPS i have a domain and subdomain for the minecraft website (lets say its mc.example.com)

If you would go to mc.example.com on your browser, you would end up on 5.5.5.5 and on the website.

What I'm trying to do is, from Minecraft when you go to mc.example.com, you would end up on 6.6.6.6.

So for example:

mc.example.com:80       ->    5.5.5.5:80
mc.example.com:25565    ->    6.6.6.6:25565

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

This are the network interfaces

auto lo
iface lo inet loopback
        address 127.0.0.1
        netmask 255.0.0.0
        broadcast 127.255.255.255
        up ip route replace 127.0.0.0/8 dev lo


# Auto generated venet0 interfaces
auto venet0
iface venet0 inet static
        address 127.0.0.1
        netmask 255.255.255.255
        broadcast 0.0.0.0
        up route add -net 191.255.255.1 netmask 255.255.255.255 dev venet0
        up route add default gw 191.255.255.1

auto venet0:0
iface venet0:0 inet static
        address 5.5.5.5
        netmask 255.255.255.255

auto venet0:1
iface venet0:1 inet static
        address 4.4.4.4
        netmask 255.255.255.255

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!

1 Answer 1

1

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

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 6.6.6.6 comes from 5.5.5.5 and 6.6.6.6 know nothing about the real source of the traffic.

That said, this should do the trick:

iptables -t nat -A PREROUTING -d 5.5.5.5 --dport 25565 -j DNAT --to 6.6.6.6
iptables -t nat -A POSTROUTING -d 6.6.6.6 --dport 25565 -s '!' 5.5.5.5 -j SNAT --to-source 5.5.5.5
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .