Networking Forums

Networking Forums > Computer Networking > Linux Networking > iptables - problem with forwarding traffic

Reply
Thread Tools Display Modes

iptables - problem with forwarding traffic

 
 
Sanal Kisi
Guest
Posts: n/a

 
      03-04-2005, 07:59 PM
Hello,

I am new to iptables but comfortable with Linux.
I setup a RHAS3 with 2 NICs, one connected to internet with real IP
and the other connected to my local LAN. I have modified the
ip_forwarding file content and issued the iptables line below

iptables -t nat -A -POSTROUTING -s internal.ip/internal.mask -o ethx
-j SNAT --to-source external.ip

which allowed my to allow my local users use this box as a gateway to
internet.

My next topic is how to set up web/mail/ftp etc servers locally, and
by assigning other real IP's and making proper forwarding so that
these servers would server both local and non-local internet users.

In summary here is what I neet to do but have no clue ;

1 - assigning several secondary IP's onto the public NIC
2 - issuing apropriate iptables command so that the traffic of each of
these secondary real IP's would be forwarded directly to seperate
local IP's, regardless of the port etc. details of the traffic.

Regards thanks for all kind of help.
 
Reply With Quote
 
 
 
 
=?ISO-8859-2?Q?Pawe=B3?= Staszewski
Guest
Posts: n/a

 
      03-04-2005, 08:06 PM
Sanal Kisi wrote:

> Hello,
>
> I am new to iptables but comfortable with Linux.
> I setup a RHAS3 with 2 NICs, one connected to internet with real IP
> and the other connected to my local LAN. I have modified the
> ip_forwarding file content and issued the iptables line below
>
> iptables -t nat -A -POSTROUTING -s internal.ip/internal.mask -o ethx
> -j SNAT --to-source external.ip
>
> which allowed my to allow my local users use this box as a gateway to
> internet.
>
> My next topic is how to set up web/mail/ftp etc servers locally, and
> by assigning other real IP's and making proper forwarding so that
> these servers would server both local and non-local internet users.
>
> In summary here is what I neet to do but have no clue ;
>
> 1 - assigning several secondary IP's onto the public NIC
> 2 - issuing apropriate iptables command so that the traffic of each of
> these secondary real IP's would be forwarded directly to seperate
> local IP's, regardless of the port etc. details of the traffic.
>
> Regards thanks for all kind of help.



Hello

So you must do:

iptables -t nat -A PREROUTING -d realip(1) -p (tcp or udp or all) --dport
(service you want to forwart inside) -j DNAT --to (your local ip in
network)

If you want to forward all traffic (for some ip in lan) from internet to lan

iptables -t nat -A PREROUTING -d (real ip) -j DNAT --to (local lan ip)

You must remember that you must snat local lan ip to the same address used
for forward:


iptables -t nat -A PREROUTING -d 80.55.98.98 -j DNAT --to 192.168.0.2
iptables -t nat -A POSTROUTING -s 192.168.0.2 -j SNAT --to 80.55.98.98



 
Reply With Quote
 
Sanal Kisi
Guest
Posts: n/a

 
      03-07-2005, 07:44 AM


Thanks a lot.

It worked like a charm.

I've done the urgent part of my job, now its time for me to start
learning the depths of IPTABLES, if I can :-)

Best regards.

 
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: forwarding traffic among all LAN networks H.S. Linux Networking 5 11-20-2007 02:30 PM
Problem with port forwarding config (iptables) Daryl Linux Networking 1 02-15-2007 07:54 PM
unusual iptables port forwarding problem azensun@gmail.com Linux Networking 2 11-19-2006 12:58 AM
Iptables, DNAT, Forwarding? problem... Mitch Linux Networking 1 04-19-2004 04:23 PM
Nocat - iptables problem (port forwarding) pablo rossi Linux Networking 0 03-04-2004 09:51 AM



1 2 3 4 5 6 7 8 9 10 11