Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-11-2005, 10:05 AM
|
#1
|
Member
Registered: May 2005
Location: Brazil
Distribution: Fedore Core 3
Posts: 138
Rep:
|
MASQUERADE vs. DNAT/SNAT
Hey there!!
Iīd like some help regarding this issue. I have a book that doesnt cover anything related to MASQUERADE. It only covers DNAT and SNAT. At the office the system admin uses MASQUERADE and Iīd like to know what is the difference. In wich cases should I use MASQUERADE, and in wich cases should I use DNAT/SNAT.
Thanks!!!
|
|
|
08-11-2005, 10:24 AM
|
#2
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep: 
|
MASQUERADE is usually used for dynamic IPs, while SNAT is used for static ips (with SNAT you specify the IP you're natting FROM). DNAT is more used for port forwarding. Check out this page: http://www.baraka.ca/barbwire_tables.asp
|
|
|
08-11-2005, 11:41 AM
|
#3
|
Member
Registered: May 2005
Location: Brazil
Distribution: Fedore Core 3
Posts: 138
Original Poster
Rep:
|
Thanks a lot.
Nice link. But I already have another question...
Letīs suppose I have a LAN with 99 computers (192.168.100.1-192.168.100.100).
Quote:
(with SNAT you specify the IP you're natting FROM)
|
In this case I would have to specify a line for each one of the computers of my LAN? That seems like a lot of work to me...
|
|
|
08-11-2005, 05:03 PM
|
#4
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep: 
|
no, sorry. You only need one, it just has your static ip in it. I *THINK* (though I've never done SNAT) it would be:
Code:
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -j SNAT --from 99.99.99.99
Where 99.99.99.99 is your STATIC IP for the outside.
|
|
|
08-11-2005, 05:34 PM
|
#5
|
Member
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303
Rep:
|
Quote:
Originally posted by Matir
You only need one, it just has your static ip in it. I *THINK* (though I've never done SNAT)
|
Yup, that's correct. The syntax, however, is -j SNAT --to-source 99.99.99.99
|
|
|
08-11-2005, 06:37 PM
|
#6
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep: 
|
Oops, sorry.  Like I said, never used it before. My ISP gives me DHCP, so I'm forced to use MASQUERADE. Though I honestly wonder if SNAT has many advantages, if any?
|
|
|
08-11-2005, 06:59 PM
|
#7
|
Member
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303
Rep:
|
The main difference I can think of is that when the link goes down the nat table is deleted when using MASQUERADE since chances are that the IP will change once the link comes back up. This is not true for SNAT. Here the NAT table stays even when the link goes down so that when it comes back up the connection can continues without a new handshake (provided it didn't time out on either side). Also SNAT performs a little better since it doesn't need to figure out the IP that belongs to the interface the NATing is done for. (This, however, doesn't really have any noticable effect now that most routers have an abundance of cpu cycles to burn.)
|
|
|
08-11-2005, 07:04 PM
|
#8
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep: 
|
Yeah, my router is a PII/333. It's load averages are in the .05 range
The conntrack table being flushed, however, is an excellent point that I had not thought of.
|
|
|
08-12-2005, 07:01 AM
|
#9
|
Member
Registered: May 2005
Location: Brazil
Distribution: Fedore Core 3
Posts: 138
Original Poster
Rep:
|
Ahhhhhhhhhhh!!!
Thanks! I can now see the light.
Letīs create two scenarios:
Network 1: 192.168.100.0/24 - eth0 IP provided by DHCP
Netowrk 2: 192.168.100.0/24 - eth0 IP is static - 200.119.78.110 (tottaly random number)
Network 1 nat rule: iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -j MASQUERADE
Network 2 nat rule: iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -j SNAT --to-source 200.119.78.110
Are these rules Ok? And second: Would the security of my network be compromised in any way? (Thinking right, security has nothing to do with nat. Security is about the filter table isnīt it? But Iīd like to read that it doesnīt from someone more experienced.)
I use DHCP too but knowing a bit more wouldnīt hurt anyone. Plus! On a big network, that uses a static valid IP, probably that line using the SNAT rule would bring, if not much, probably a little more productivity to that network wouldnīt it?
|
|
|
08-12-2005, 10:23 AM
|
#10
|
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507
Rep: 
|
With realistically modern routing equipment (read: old p2 pcs) you can pretty much NAT most connections with no problem.
NAT is generally considered GOOD for security because it makes it impossible for the outside world to connect to the NATted computers without your permission. For example, to run a server behind NAT, you need to enable portforwarding and forward the proper port in.
Of course, the filter table is also important in locking it down more.
|
|
|
All times are GMT -5. The time now is 11:15 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|