Skip to contentSkip to conversation

Problems with NAT

DISCUSSION Jose Luis Hime 2 participants 4 messages May 29, 2003 – May 30, 2003

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 37 lines · Jose Luis Hime

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:

Quoted 8 lines
   -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

Quoted 6 lines

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

Signature · 7 lines
--
Raymond Leach <[email protected]>
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
--
#2 lore raw

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: [email protected] [mailto:[email protected]]On Behalf Of Ray Leach
Sent: Thursday, May 29, 2003 12:55 PM
To: Netfilter Mailing List
Subject: Re: Problems with NAT

Quoted 37 lines · Jose Luis Hime

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:

Quoted 8 lines
   -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

Quoted 6 lines

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

Signature · 7 lines
--
Raymond Leach <[email protected]>
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
--
#3 lore raw
Quoted 9 lines · Jose Luis Hime

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?

Quoted 68 lines

Thanks again,
Jose Hime

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Ray Leach
Sent: Thursday, May 29, 2003 12:55 PM
To: Netfilter Mailing List
Subject: Re: Problems with NAT

Quoted 37 lines · Jose Luis Hime

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:

Quoted 8 lines
   -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

Quoted 6 lines

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

Signature · 7 lines
--
Raymond Leach <[email protected]>
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
--