Skip to contentSkip to conversation

Port forwarding question

DISCUSSION David 2 participants 2 messages Apr 30, 2007 – May 2, 2007

lore
Share & tools
lore

David

author
#0 lore raw

Hi all - first post, should be a simple question but google and the docs are not helping

I want to forward port 10000 from internal hosts to the internet and it works with:

iptables -t nat -A PREROUTING -p tcp --dport 10000 -i ppp0 -j DNAT --to 192.168.0.2

for the host with ip 192.168.0.2, but how do I forward it for a range of hosts, ie 192.168.0.2-192.168.0.254

I try

iptables -t nat -A PREROUTING -p tcp --dport 10000 -i ppp0 -j DNAT --to 192.168.0.2-192.168.0.254

but it does not work for any other hosts

iptables -L -v -t nat
gives the range, but does not actually forward the port in any apps tcp dpt:10000 to:192.168.0.2-192.168.0.254

How do I forward the range of ports?
TIA,
David

==============================================
Running gentoo 2.16.18.4, iptables 1.3.5

#1 lore raw

Hi all,
maybe you can try this
iptables -t nat -A PREROUTING -p tcp --dport 10000 -i ppp0 -m iprange --dst-range 192.168.0.2-192.168.0.254 -j DNAT --to-destination 192.168.0.2-192.168..254

or check
http://iptables-tutorial.frozentux.net/iptables-tutorial.html#IPRANGEMATCH

Regards

Elvir Kuric

Quoted 29 lines · David

Hi all - first post, should be a simple question but google and the docs are not helping

I want to forward port 10000 from internal hosts to the internet and it works with:

iptables -t nat -A PREROUTING -p tcp --dport 10000 -i ppp0 -j DNAT --to 192.168.0.2

for the host with ip 192.168.0.2, but how do I forward it for a range of hosts, ie 192.168.0.2-192.168.0.254

I try

iptables -t nat -A PREROUTING -p tcp --dport 10000 -i ppp0 -j DNAT --to 192.168.0.2-192.168.0.254

but it does not work for any other hosts

iptables -L -v -t nat
gives the range, but does not actually forward the port in any apps tcp dpt:10000 to:192.168.0.2-192.168.0.254

How do I forward the range of ports?
TIA,
David

==============================================
Running gentoo 2.16.18.4, iptables 1.3.5