Skip to contentSkip to conversation

port mapping ANY:95 to originalIP:80

DISCUSSION Efraim 2 participants 3 messages Apr 30, 2005 – May 1, 2005

lore
Share & tools
lore

Efraim

author
#0 lore raw

Hi,
I'm using my linux box as a router and I have an application that is make all the request in port 95.
I need to make an iptables rule that will change the original port of any destination ip addres to 80.
I know how to do it for a specific destination ip but I could not find the way to do it for any destination ip.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 95 -j DNAT --to 66.249.87.99:80

66.249.87.99 is the Google ip, but I need the rule to work for any ip. Something like:

iptables -t nat -A PREROUTING -i eth0 -p tcp -d ANY --dport 95 -j DNAT --to ANY:80

I know that it is possible to do with checkpoint firewall but it is a little expensive...

author
#1 lore raw

Port mapping ANY:95 to originalIP:80

Hi,
I'm using my linux box as a router and I have an application that is make all the request in port 95.
I need to make an iptables rule that will change the original port of any destination ip addres to 80.
I know how to do it for a specific destination ip but I could not find the way to do it for any destination ip.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 95 -j DNAT --to 66.249.87.99:80

66.249.87.99 is the Google ip, but I need the rule to work for any ip. Something like:

iptables -t nat -A PREROUTING -i eth0 -p tcp -d ANY --dport 95 -j DNAT --to ANY:80

I know that it is possible to do with checkpoint firewall but it is a little expensive...

#2 lore raw
In reply to Efraim

Hm, a touch quick on the draw to repost. Sietse van Zanen posted a reply (https://lists.netfilter.org/pipermail/netfilter/2005-May/060125.html) to your earlier post with a solution that I just tested that did work for me.

Grant. . . .

Quoted 19 lines · Efraim

Hi,
I'm using my linux box as a router and I have an application that is make all the request in port 95.
I need to make an iptables rule that will change the original port of any destination ip addres to 80.
I know how to do it for a specific destination ip but I could not find the way to do it for any destination ip.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 95 -j DNAT --to 66.249.87.99:80

66.249.87.99 is the Google ip, but I need the rule to work for any ip. Something like:

iptables -t nat -A PREROUTING -i eth0 -p tcp -d ANY --dport 95 -j DNAT --to ANY:80

I know that it is possible to do with checkpoint firewall but it is a little expensive...