Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 am trying to redirect connections made inside a linux host to a guest VM, say, for a certain port range, say 8000:8500, i.e.:

telnet localhost 8000

should actually result in a connection to the VM. I can easily redirect connections from outside machines with:

iptables -t nat -I PREROUTING -p tcp --dport 8000:8500 -j DNAT --to

But from what I can gather traffic originating on the host machine does not go through the PREROUTING chain. I have tried to use the OUTPUT chain instead with:

iptables -t nat -I OUTPUT -p tcp --dport 8000:8500 -j DNAT --to

This does not seem to work. I ran a wireshark capture on all interfaces and when this rule is in place no traffic is generated for port 8000.

I was hoping to use iptables for this but I have not been able to make it work. I am considering using redir but I was hoping there is an iptables solution.

share|improve this question
Does that happen if you had any connection (ping would be enough) to immediately before, too? I tried to reproduce this here and had ARP problems. Does it work for telnet $eth_ip 8000? – Hauke Laging May 12 '13 at 22:11
telnet $eth_ip 8000 does work but not telnet localhost 8000 – samwise May 12 '13 at 22:34

Your Answer


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

Browse other questions tagged or ask your own question.