Question about Masquerading

Question about Masquerading

Post by Martin Haberstro » Wed, 13 Jun 2001 23:40:42



Hello everybody.

We have a linux box with kernel 2.2.xx (SuSE 6.4)
three networks attached:
- one with 4 public static ip addresses
- one with a private ip address
- one with another private ip address in a diffrent subnet
masquerading done with ipchains

Is it possible to do an masquerading for computers in private network 1 with
public ip adress 1 and for computers in private network 2 with public ip
adress 2?

If it is not possible with kernel 2.2.xx, is it possible with kernel 2.4.X?

Martin

 
 
 

Question about Masquerading

Post by Julian Tibbl » Thu, 14 Jun 2001 08:04:37


Quote:> Is it possible to do an masquerading for computers in private network 1
> with public ip adress 1 and for computers in private network 2 with public
> ip adress 2?

> If it is not possible with kernel 2.2.xx, is it possible with kernel
> 2.4.X?

As far as I can see it is not possible with 2.2 and ipchains (at least not
easily), but it is possible with 2.4 and iptables.

To achieve what you want you would need to make the linux machine accept
packets to the two public IP addresses on one interface - the most obvious
way I can think of to achieve this would be IP aliasing (you'd end up with
eth0:0 and eth0:1 or something)

Having accomplished this you would do the following commands, assuming that

public interface on eth0:0 = 1.1.1.1
public interface on eth0:1 = 1.1.1.2
private net 1 = 192.168.0.0/24
private net 2 = 192.168.1.0/24

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d ! 192.168.0.0/16 \
-j SNAT --to-source 1.1.1.1

AND

iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d ! 192.168.0.0/16 \
-j SNAT --to-source 1.1.1.2

these rules basically match everything that is from a private network that
isn't going to the other private network, and changes the source ip to the
appropriate one (de-masquerading is handled automatically)

N.B. these rules could probably be "hardened" for security - but the basic
idea is there

Good luck,
Julian

 
 
 

Question about Masquerading

Post by Julian Tibbl » Thu, 14 Jun 2001 08:27:49


Quote:> To achieve what you want you would need to make the linux machine accept
> packets to the two public IP addresses on one interface - the most obvious
> way I can think of to achieve this would be IP aliasing (you'd end up with
> eth0:0 and eth0:1 or something)

Hmmm, just thought - this could also be done by using "arp" to tell the
linux machine (and those on the same public subnet) that it accepts packets
for the second public address.
 
 
 

1. a question about masquerade source ports

Hi,

I'm trying to do some rate limiting on the apps I'm running and have come
across a problem. One of the apps uses random source ports >1024 for TCP
connections. He's the one I want to limit but I don't want to limit my ip
masqueraded connections. I remember that linux ip masquerade used to use
ports 60000-65535 as source but that no longer seems to be the case in the
2.4 kernel. Is there a way to specifify a source port range for ip
masquerade under iptables?

2. Apache - How to limit large downloads by users?

3. Newbie question on Masquerading

4. KSH - alias and .kshrc question

5. Newbie Question concerning MASQUERADING and FIREWALLING

6. x86 Installation Problems.

7. NAT question (NOT masquerading)

8. SMIT - looking behind the curtain

9. New User Question (IP-masquerade)

10. Questions about masquerading - firewalling

11. IP Masquerading works, but does not masquerade from within the local network

12. Flame my Firewall - Masquerade Masquerade !

13. IP for masqueraded net other than masquerading host IP