Networking Forums

Networking Forums > Computer Networking > Linux Networking > complex iptables port forwarding, is this possible?

Reply
Thread Tools Display Modes

complex iptables port forwarding, is this possible?

 
 
szr
Guest
Posts: n/a

 
      11-05-2008, 06:06 PM
I have a Linux box (which is not the default gw) with iptables running on
it, whose ip is 192.168.1.4

I want to forward packets coming to UDP 192.168.1.4:6130, which receives
logging data from several remote hosts on the Internet. The main router on
the network forwards from WAN:6130 to 192.168.1.4:6130.

If the original packet came from 5.4.3.1:10001,
forward (binding to 192.168.1.4:10001) to 192.168.1.8:6130


If the original packet came from 5.4.3.2:10002,
forward (binding to 192.168.1.4:10002) to 192.168.1.6:6130


Is this possible?

Thanks.

-szr


 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      11-05-2008, 07:05 PM
Hello,

szr a écrit :
> I have a Linux box (which is not the default gw) with iptables running on
> it, whose ip is 192.168.1.4
>
> I want to forward packets coming to UDP 192.168.1.4:6130, which receives
> logging data from several remote hosts on the Internet. The main router on
> the network forwards from WAN:6130 to 192.168.1.4:6130.
>
> If the original packet came from 5.4.3.1:10001,
> forward (binding to 192.168.1.4:10001) to 192.168.1.8:6130


iptables -t nat -A PREROUTING -s 5.4.3.1 -d 192.168.1.4 \
-p udp --sport 10001 --dport 6130 -j DNAT --to 192.168.1.8:6130
iptables -t nat -A POSTROUTING -s 5.4.3.1 -d 192.168.1.8 \
-p udp --sport 10001 --dport 6130 -j SNAT --to 192.168.1.4:10001

> If the original packet came from 5.4.3.2:10002,
> forward (binding to 192.168.1.4:10002) to 192.168.1.6:6130


iptables -t nat -A PREROUTING -s 5.4.3.2 -d 192.168.1.4 \
-p udp --sport 10002 --dport 6130 -j DNAT --to 192.168.1.6:6130
iptables -t nat -A POSTROUTING -s 5.4.3.2 -d 192.168.1.6 \
-p udp --sport 10002 --dport 6130 -j SNAT --to 192.168.1.4:10002

The SNAT rules are necessary because the box is not the default gateway.
 
Reply With Quote
 
Chris Davies
Guest
Posts: n/a

 
      11-06-2008, 09:49 AM
szr <(E-Mail Removed)> wrote:
> I have a Linux box (which is not the default gw) with iptables running on
> it, whose ip is 192.168.1.4


Answered elsewhere. Please don't multipost. If you want to post the same
question in several newsgroups please crosspost a single message, instead.

Chris
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IPTables port forwarding Miguel Sanders Linux Networking 1 10-11-2007 12:19 PM
Port forwarding with iptables ??? Joe Attardi Linux Networking 4 05-10-2004 11:45 PM
iptables port forwarding anonymous Linux Networking 1 01-22-2004 09:25 AM
iptables port forwarding Jason Lee Linux Networking 4 10-13-2003 12:53 AM
Port Forwarding with iptables Allan Bruce Linux Networking 0 08-27-2003 11:44 AM



1 2 3 4 5 6 7 8 9 10 11