Skip to contentSkip to conversation

Multiple port-fwd on same port based on src IP

DISCUSSION Oliver Schulze L. 2 participants 3 messages Sep 20, 2006

lore
Share & tools
lore
#0 lore raw

Hi,
I wonder if I can use multiple port forwarding rules to the same IP/Port based on the src IP and forwarding to different internal IPs

It should be something like this:
iptables -t nat -A PREROUTING -p tcp -s CLIENT1_IP -d INET_IP --dport 1234 -j DNAT --to 192.168.1.1:1234 iptables -t nat -A PREROUTING -p tcp -s CLIENT2_IP -d INET_IP --dport 1234 -j DNAT --to 192.168.1.2:1234 iptables -t nat -A PREROUTING -p tcp -s CLIENT3_IP -d INET_IP --dport 1234 -j DNAT --to 192.168.1.3:1234
...

Will it work? Or should I configure some sort of tcp proxy.?

Thanks
Oliver

Signature · 2 lines
Oliver Schulze L.
Get my e-mail after a captcha test in: http://tinymailto.com/oliver
#1 lore raw
Quoted 14 lines

Hi,
I wonder if I can use multiple port forwarding rules to the same IP/Port based on the src IP and forwarding to different internal IPs

It should be something like this:
iptables -t nat -A PREROUTING -p tcp -s CLIENT1_IP -d INET_IP --dport 1234 -j DNAT --to 192.168.1.1:1234
iptables -t nat -A PREROUTING -p tcp -s CLIENT2_IP -d INET_IP --dport 1234 -j DNAT --to 192.168.1.2:1234
iptables -t nat -A PREROUTING -p tcp -s CLIENT3_IP -d INET_IP --dport 1234 -j DNAT --to 192.168.1.3:1234
...

Quoted 1 line

Will it work? Or should I configure some sort of tcp proxy.?

I'm not sure why you're using "-d INET_IP" (this box has multiple INET_IP's?), but IMO this would work (if your FORWARD chain is properly setup).

Gr,
Rob

#2 lore raw
Quoted 4 lines · Rob Sterenborg

I'm not sure why you're using "-d INET_IP" (this box has multiple INET_IP's?), but IMO this would work (if your FORWARD chain is properly setup).

Hi Rob,
the box has only 2 IPs, 1 Public, 1 Private.

Thanks for the comments, will try it.

Oliver

Signature · 2 lines
Oliver Schulze L.
Get my e-mail after a captcha test in: http://tinymailto.com/oliver