All of lore.kernel.org
 help / color / mirror / Atom feed
* Problems with NAT
@ 2003-05-29 15:15 Jose Luis Hime
  2003-05-29 15:55 ` Ray Leach
  0 siblings, 1 reply; 18+ messages in thread
From: Jose Luis Hime @ 2003-05-29 15:15 UTC (permalink / raw)
  To: netfilter

Dear all:

I have the following network:
              :
              :    /---------\
/-------\  Leased  | Router  |  Leased  /----------\
| LAN B |----------| without |----------| Internet |
\-------/  Line 1  | NAT     |  Line 2  \----------/
              :    \---------/
              :         |
              :         |
              :   /----------\
              :   | Firewall |      /-------\
              :   | Linux    |------| LAN A |
              :   | with NAT |      \-------/
              :   \----------/
              :
   CITY "B"   :     CITY "A"

1. The router, the firewall and LAN A are in city "A"
2. LAN B is in another city (city "B")
3. LAN A must access the internet, LAN B must not;
4. Unfortunately my router does not support NAT;
5. Both the router and the linux firewall have real internet IP addresses;
6. So:
   - The linux firewall must NAT packets from LAN A to the internet;
   - The linux firewall must not NAT packets from LAN A to LAN B;

I created rules in table "filter" allowing communication between LAN A and
LAN B:
   -t filter -A INPUT   -s LAN A -d LAN B -j ACCEPT
   -t filter -A INPUT   -s LAN B -d LAN A -j ACCEPT
   -t filter -A FORWARD -s LAN A -d LAN B -j ACCEPT
   -t filter -A FORWARD -s LAN B -d LAN A -j ACCEPT

After that, I created one rule in table "nat" in order to allow LAN A
accessing the internet:
   -t nat -A POSTROUTING -s LAN A -d 0/0 -j SNAT --to Firewall_IP_address

The problem is that LAN A is making NAT to LAN B.

Is there a way to prevent the firewall from NATing from LAN A to LAN B? The
problem is that both traffics (LAN A->internet and LAN A->LAN B) are going
through the same interface...

With ipchains, after reaching the INPUT and FORWARD rules the firewall
would stop and would not reach the NAT rules. This behavior changed in
iptables and it always check both tables (filter and nat).

Thanks in advance,
Jose Hime



^ permalink raw reply	[flat|nested] 18+ messages in thread
* Problems with NAT
@ 2003-09-27 16:44 Adam Mercer
  2003-09-28  3:30 ` Mark E. Donaldson
  0 siblings, 1 reply; 18+ messages in thread
From: Adam Mercer @ 2003-09-27 16:44 UTC (permalink / raw)
  To: netfilter

Hi

I'm trying to set up my firwall so that I can plug my laptop into eth1
of my desktop and use NAT to access the outside world on the laptop

I've followed the NAT Howto and my firewall contains the following rules

    # allow local-only connections
    ${IPTABLES} -A INPUT -i lo -j ACCEPT

    # free output on any interface to any ip for any service
    ${IPTABLES} -A OUTPUT -j ACCEPT

    # permit answers on already established connections
    # and permit new connections related to established ones
    ${IPTABLES} -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    ${IPTABLES} -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

    # allow incomg ssh connections
    ${IPTABLES} -A INPUT -p tcp  --dport ssh -j ACCEPT

    # NAT
    ${IPTABLES} -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    ${IPTABLES} -A FORWARD -s 10.0.0.0/24 -j ACCEPT

    # everything not accepted > /dev/null
    ${IPTABLES} -P INPUT DROP
    ${IPTABLES} -P FORWARD DROP
    ${IPTABLES} -P OUTPUT DROP

    # be verbose on dynamic ip-addresses
    echo 2 > /proc/sys/net/ipv4/ip_dynaddr

    # disable ExplicitCongestionNotification
    echo 0 > /proc/sys/net/ipv4/tcp_ecn

    # turn on IP forwarding
    echo 1 > /proc/sys/net/ipv4/ip_forward

The laptop (PowerBook G4) is assigned an ip address in the range 10.0.0.2-.10
by a DHCP server. eth1 has an ip address 10.0.0.1, and eth0 is the connection
to the outside world. After running ethereal it appears that no packets from
the local network are making it to eth0. However I can ssh into the server if I
use ip address, but not hostname.

Can anyone help me out with this?

Thanks in advance

Adam


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Problems with NAT
@ 2003-05-30  6:57 George Vieira
  0 siblings, 0 replies; 18+ messages in thread
From: George Vieira @ 2003-05-30  6:57 UTC (permalink / raw)
  To: Ray Leach, jhime; +Cc: Netfilter Mailing List

They are all visible by the 1 nic.. the linux box talks to them via the same router that goes to the internet, this is why he has a problem.. so "-o eth0" wouldn't make a difference..

I found this out when he told me this in Portugese.. ;) he he funny that....

Thanks,
____________________________________________
George Vieira
Systems Manager
georgev@citadelcomputer.com.au

Citadel Computer Systems Pty Ltd
http://www.citadelcomputer.com.au

 

-----Original Message-----
From: Ray Leach [mailto:raymondl@knowledgefactory.co.za]
Sent: Friday, May 30, 2003 4:04 PM
To: jhime@synchro.com.br
Cc: 'Netfilter Mailing List'
Subject: RE: Problems with NAT


On Thu, 2003-05-29 at 19:15, Jose Luis Hime wrote:
> The problem is that there are LAN C, LAN D and LAN E in other 3 cities,
> also! So, the rule:
> 
> -t nat -A POSTROUTING -s LAN A -d ! LAN B -j SNAT --to Firewall_IP_address
> 
> would work for LAN B, but not for the other LANs.
> 
> All LANs are connected to the same router.
> 

What about adding '-o INET_IFACE', or do LAN C,D,E also connect via the
internet interface?

> Thanks again,
> Jose Hime
> 
> 
> -----Original Message-----
> From: netfilter-admin@lists.netfilter.org
> [mailto:netfilter-admin@lists.netfilter.org]On Behalf Of Ray Leach
> Sent: Thursday, May 29, 2003 12:55 PM
> To: Netfilter Mailing List
> Subject: Re: Problems with NAT
> 
> 
> On Thu, 2003-05-29 at 17:15, Jose Luis Hime wrote:
> > Dear all:
> > 
> > I have the following network:
> >               :
> >               :    /---------\
> > /-------\  Leased  | Router  |  Leased  /----------\
> > | LAN B |----------| without |----------| Internet |
> > \-------/  Line 1  | NAT     |  Line 2  \----------/
> >               :    \---------/
> >               :         |
> >               :         |
> >               :   /----------\
> >               :   | Firewall |      /-------\
> >               :   | Linux    |------| LAN A |
> >               :   | with NAT |      \-------/
> >               :   \----------/
> >               :
> >    CITY "B"   :     CITY "A"
> > 
> > 1. The router, the firewall and LAN A are in city "A"
> > 2. LAN B is in another city (city "B")
> > 3. LAN A must access the internet, LAN B must not;
> > 4. Unfortunately my router does not support NAT;
> > 5. Both the router and the linux firewall have real internet IP addresses;
> > 6. So:
> >    - The linux firewall must NAT packets from LAN A to the internet;
> >    - The linux firewall must not NAT packets from LAN A to LAN B;
> > 
> > I created rules in table "filter" allowing communication between LAN A and
> > LAN B:
> >    -t filter -A INPUT   -s LAN A -d LAN B -j ACCEPT
> >    -t filter -A INPUT   -s LAN B -d LAN A -j ACCEPT
> >    -t filter -A FORWARD -s LAN A -d LAN B -j ACCEPT
> >    -t filter -A FORWARD -s LAN B -d LAN A -j ACCEPT
> > 
> > After that, I created one rule in table "nat" in order to allow LAN A
> > accessing the internet:
> >    -t nat -A POSTROUTING -s LAN A -d 0/0 -j SNAT --to Firewall_IP_address
> > 
> > The problem is that LAN A is making NAT to LAN B.
> > 
> > Is there a way to prevent the firewall from NATing from LAN A to LAN B? The
> > problem is that both traffics (LAN A->internet and LAN A->LAN B) are going
> > through the same interface...
> > 
> Sure, change your nat rule:
>   -t nat -A POSTROUTING -s LAN A -d ! LAN B -j SNAT --to
> Firewall_IP_address
> 
> > With ipchains, after reaching the INPUT and FORWARD rules the firewall
> > would stop and would not reach the NAT rules. This behavior changed in
> > iptables and it always check both tables (filter and nat).
> > 
> > Thanks in advance,
> > Jose Hime
-- 
--
Raymond Leach <raymondl@knowledgefactory.co.za>
Network Support Specialist
http://www.knowledgefactory.co.za
"lynx -source http://www.rchq.co.za/raymondl.asc | gpg --import"
Key fingerprint = 7209 A695 9EE0 E971 A9AD  00EE 8757 EE47 F06F FB28
--


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Problems with NAT
@ 2003-05-30  2:30 George Vieira
  0 siblings, 0 replies; 18+ messages in thread
From: George Vieira @ 2003-05-30  2:30 UTC (permalink / raw)
  To: Matt Hellman, jhime, Ray Leach, Netfilter Mailing List

SNAT should not be used for MASQUERADING.. it's not advised anyway but still works but who knows what possible problems it may cause.

Thanks,
____________________________________________
George Vieira
Systems Manager
georgev@citadelcomputer.com.au

Citadel Computer Systems Pty Ltd
http://www.citadelcomputer.com.au

Phone   : +61 2 9955 2644
HelpDesk: +61 2 9955 2698
 

-----Original Message-----
From: Matt Hellman [mailto:netfilter@taxandfinance.com]
Sent: Friday, May 30, 2003 11:59 AM
To: jhime@synchro.com.br; George Vieira; 'Ray Leach'; 'Netfilter Mailing
List'
Subject: RE: Problems with NAT


never tried it, but why couldn't you just add ACCEPT rules in PREROUTING
[before the NAT rule] for each LAN not_to_be_natted?

-t nat -A POSTROUTING -s LAN A -d LAN B -j ACCEPT
-t nat -A POSTROUTING -s LAN A -d LAN C -j ACCEPT
-t nat -A POSTROUTING -s LAN A -d 0/0 -j SNAT --to Firewall_IP_address


^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Problems with NAT
@ 2003-05-29 22:09 George Vieira
  2003-05-29 23:02 ` Jose Luis Hime
  0 siblings, 1 reply; 18+ messages in thread
From: George Vieira @ 2003-05-29 22:09 UTC (permalink / raw)
  To: jhime, Ray Leach, Netfilter Mailing List

What is the IP ranges for the other networks? Are they the same subnet or different ones?
Ned more info so we can determine the needs..

PS: Nice drawing ;P

Thanks,
____________________________________________
George Vieira
Systems Manager
georgev@citadelcomputer.com.au

Citadel Computer Systems Pty Ltd
http://www.citadelcomputer.com.au

Phone   : +61 2 9955 2644
HelpDesk: +61 2 9955 2698
 

-----Original Message-----
From: Jose Luis Hime [mailto:jhime@synchro.com.br]
Sent: Friday, May 30, 2003 3:15 AM
To: 'Ray Leach'; 'Netfilter Mailing List'
Subject: RE: Problems with NAT


The problem is that there are LAN C, LAN D and LAN E in other 3 cities,
also! So, the rule:

-t nat -A POSTROUTING -s LAN A -d ! LAN B -j SNAT --to Firewall_IP_address

would work for LAN B, but not for the other LANs.

All LANs are connected to the same router.

Thanks again,
Jose Hime


-----Original Message-----
From: netfilter-admin@lists.netfilter.org
[mailto:netfilter-admin@lists.netfilter.org]On Behalf Of Ray Leach
Sent: Thursday, May 29, 2003 12:55 PM
To: Netfilter Mailing List
Subject: Re: Problems with NAT



^ permalink raw reply	[flat|nested] 18+ messages in thread
* problems with nat
@ 2002-11-13 18:13 Rahul Jadhav
  2002-11-13 19:20 ` Ben Russo
  2002-11-16 18:58 ` Joel Newkirk
  0 siblings, 2 replies; 18+ messages in thread
From: Rahul Jadhav @ 2002-11-13 18:13 UTC (permalink / raw)
  To: netfilter

[-- Attachment #1: Type: text/plain, Size: 46 bytes --]

please check the attachment...

Thanks
Rahul


[-- Attachment #2: query --]
[-- Type: application/x-java-vm, Size: 10758 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Problems with NAT
@ 2000-12-13 16:23 Marian Jancar
  0 siblings, 0 replies; 18+ messages in thread
From: Marian Jancar @ 2000-12-13 16:23 UTC (permalink / raw)
  To: linux-kernel

There is a problem with nat in at least 2.2.16 and 2.2.18. If you
specify routing first and nat second,

ip route add nat x.x.x.x via y.y.y.y
ip rule add from y.y.y.y nat x.x.x.x

the rule doesnt have an effect, ping to x.x.x.x says it got response
from y.y.y.y. With turned order of commands,

ip rule ...
ip route ...

it works.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2003-09-28  7:36 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-29 15:15 Problems with NAT Jose Luis Hime
2003-05-29 15:55 ` Ray Leach
2003-05-29 17:15   ` Jose Luis Hime
2003-05-30  6:04     ` Ray Leach
  -- strict thread matches above, loose matches on Subject: below --
2003-09-27 16:44 Adam Mercer
2003-09-28  3:30 ` Mark E. Donaldson
2003-09-28  7:36   ` Adam Mercer
2003-05-30  6:57 George Vieira
2003-05-30  2:30 George Vieira
2003-05-29 22:09 George Vieira
2003-05-29 23:02 ` Jose Luis Hime
2003-05-30  1:59   ` Matt Hellman
2003-05-30  2:01   ` Matt Hellman
2002-11-13 18:13 problems with nat Rahul Jadhav
2002-11-13 19:20 ` Ben Russo
2002-11-13 20:01   ` Rahul Jadhav
2002-11-16 18:58 ` Joel Newkirk
2000-12-13 16:23 Problems with NAT Marian Jancar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.