Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a strange problem and i cannot find a solution. So first, here is my config; i have got an ESXI with public IP : 1.1.1.1, i host a virtual Ubuntu server with one NIC (configured in my esxi) eth0 with public IP 2.2.2.2, and i have plugged a virutal nic eth0:0 with public IP 3.3.3.3. Here is my /etc/network/interfaces:

auto eth0
allow-hotplug eth0
iface eth0 inet static
        address 2.2.2.2
        netmask 255.255.255.255
        broadcast 2.2.2.2
        post-up route add 1.1.1.1 dev eth0
        post-up route add default gw 1.1.1.1
        post-down route del 1.1.1.1 dev eth0
        post-down route del default gw 1.1.1.1

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
        address 3.3.3.3
        netmask 255.255.255.255
        broadcast 3.3.3.3

So far so good, its work. I can both ping 2.2.2.2 and 3.3.3.3 Now i want 3.3.3.3:443 to be redirect to 3.3.3.3:8777

So i have made a PAT with iptables like this:

iptables -t nat -A PREROUTING -i eth0:0 -p tcp --dport 443 -j DNAT --to-destination :8777

but when i do telnet 3.3.3.3:443 it failed. So i have tried

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 7778 -j DNAT --to-destination :22

And telnet 2.2.2.2:443 works fine. So my guess is that it come from the "add route" in my interfaces files but i am not sure.

Any ideas? thanks

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Solution had been found here: iptables: IP alias and port forwarding So i must not use DNAT like:

iptables -t nat -A PREROUTING -i eth0:0 -p tcp --dport 443 -j DNAT --to-destination :8777

But REDIRECT :

iptables -t nat -A PREROUTING -i eth0 -d 3.3.3.3 -p tcp --dport 443 -j REDIRECT --to 8777

That's it!

share|improve this answer

Your Answer

 
discard

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.