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

There are two IPs associated with one physical network interface eth0 and eth0:0.

The following works fine for the first interface:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Howerver the same doesn't work for the second interface:

iptables -A PREROUTING -t nat -i eth0:0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Also tried:

iptables -A PREROUTING -t nat -p tcp --dport 80 -d $THE_IP -j REDIRECT --to-port 8080

So the question is how to do redirecting on a virtual interface.

share|improve this question
up vote 4 down vote accepted

You don't. Alias interfaces are a notational convention that don't actually exist at the deep layers of the kernel where iptables roams. Use an IP address (your third example command is broken and will have produced an error message which should have clued you in) and all will be well.

share|improve this answer
edited the 3rd command to the one I've used and there is no error and redirection still doesn't work. Could you also elaborate on why nating based on the incoming interface is dangerous? – f3r3nc Jul 5 '12 at 18:04
If that third command doesn't work, something else is wrong, because I use the exact same command and it works for me. Time to break out the TRACE target and see what you can see. – womble Jul 5 '12 at 18:12
Well, TRACE target? could you be more specific? – f3r3nc Jul 5 '12 at 18:37
I could. Can you read a manpage? – womble Jul 5 '12 at 18:44
omg, this is rtfm all over the place.. :( – f3r3nc Jul 6 '12 at 9:21

You should use TUN/TAP interface for doing this work. Refer to this tutorial for further details.

share|improve this answer

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.