Skip to contentSkip to conversation

Can iptables REDIRECT traffic to a range of ports in one command?

DISCUSSION Grace Li 3 participants 3 messages Apr 19, 2004 – Apr 20, 2004 netfilter

lore
Share & tools
lore

Grace Li

author
#0 lore raw

Hi Guys,

I would like to intercept traffic to a range of ports, say port 2000-3000 to one port locally, say port 3333. I am wondering if there is a simple way to do it, like specify a range in iptables instead of writing a script to speficy for each port?

Thanks,

Grace

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN Premium http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines

#1 lore raw
Quoted 7 lines · Grace Li

I would like to intercept traffic to a range of ports, say port 2000-3000 to one port locally, say port 3333. I am wondering if there is a simple way to do it, like specify a range in iptables instead of writing a script to speficy for each port?

From the manual:

--destination-port [!] port[:port]
Destination port or port range specification. The flag --dport is a convenient alias for this option.

Regards
Henrik

#2 lore raw
In reply to Grace Li

this is what you look for;

10.0.0.1 is the ip of destination machine

iptables -t nat -A PREROUTING -p tcp -d 10.0.0.1 --dport 2000:3000 -j DNAT --to 10.0.0.1:3333

Signature · 1 line
Ozgur Akan