Skip to contentSkip to conversation

iptables questions

DISCUSSION Antti Korpela 5 participants 5 messages Nov 15, 2003 – Nov 19, 2003

lore
Share & tools
lore
#0 lore raw

Hi,

I have here some questions and i hope you have some time to answer

1. What difference and which is better between: iptables -t nat -j MASQUERADE or SNAT --to IP if im using it for internet gateway NAT-machine in big LAN-parties, over 300 IP:s.
2. I have get this error often "too much work on eth0, dropping packet..." what this mean? do i have to put this on kernel:
echo "65000" > /proc/sys/net/ipv4/ip_conntrack_max ? is there any other solutions for this ?
3. Do you have some other tips for MASQ ? :)

Thanks for your time and support!

#1 lore raw
Quoted 5 lines · Antti Korpela

Hi,

I have here some questions and i hope you have some time to answer

1. What difference and which is better between: iptables -t nat -j MASQUERADE or SNAT --to IP if im using it for internet gateway NAT-machine in big LAN-parties, over 300 IP:s.

According to Oskar's tutorial SNAT is preferable for static IPs:

Quoted 5 lines

It is still possible to use the *MASQUERADE* target instead of *SNAT* even though you do have an static IP, however, it is not favorable since it will add extra overhead, and there may be inconsistencies in the future which will thwart your existing scripts and render them "unusable".

2. I have get this error often "too much work on eth0, dropping packet..." what this mean? do i have to put this on kernel:
echo "65000" > /proc/sys/net/ipv4/ip_conntrack_max ? is there any other solutions for this ?

Can't help with this.

Quoted 1 line

3. Do you have some other tips for MASQ ? :)

SNAT is pretty straightforward and there aren't a lot of configuration choices. It's a good idea to read all of Oskar's tutorial, but you should at least read and understand this section:

http://iptables-tutorial.frozentux.net/chunkyhtml/targets.html#SNATTARGET

Jeff

#2 lore raw
Quoted 7 lines · Jeffrey Laramie
Quoted 4 lines · Antti Korpela

1. What difference and which is better between: iptables -t nat -j MASQUERADE or SNAT --to IP if im using it for internet gateway NAT-machine in big LAN-parties, over 300 IP:s.

According to Oskar's tutorial SNAT is preferable for static IPs:

My understanding is that SNAT is marginally more efficient than MASQUERADE because the address to be susbstituted is fixed in the SNAT rule, whereas with MASQUERADE the rule needs to look up the address of the interface before it knows what to replace into the packet.

Whether you could measure the difference in efficiency between the two rules
is another matter entirely, however. My recommendation would be to go for
maximum readability of your rules.

Regards,

Antony.

Signature · 6 lines
90% of network problems are routing problems.
9 of the remaining 10% are routing problems in the other direction.
The remaining 1% might be something else, but check the routing anyway.

                                                     Please reply to the list;
                                                           please don't CC me.
#3 lore raw
Quoted 4 lines · Antony Stone

My understanding is that SNAT is marginally more efficient than MASQUERADE because the address to be susbstituted is fixed in the SNAT rule, whereas with MASQUERADE the rule needs to look up the address of the interface before it knows what to replace into the packet.

There's another advantage in using SNAT instead of MASQUERADE. When you use MASQUERADE, nated connections are bound to output interface. If it gets down, all theses connections will get flushed. With SNAT, there's no interface dependency of this kind.

At home, I have a PPPoE DSL access. When I had a dynamic IP, I was setting SNAT rule using pppd ip-up script. So when the PPP link get up and down, I don't loose my current connections. I used to lose them using MASQUERADE.

Signature · 2 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines

Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!

#4 lore raw
In reply to Antti Korpela

Good evening, Antti,

Quoted 5 lines · Antti Korpela

I have here some questions and i hope you have some time to answer

1. What difference and which is better between: iptables -t nat -j MASQUERADE or SNAT --to IP if im using it for internet gateway NAT-machine in big LAN-parties, over 300 IP:s.

MASQUERADE is for situations where your outside IP address
changes; most commonly used for modem connections. If your outside address is static, use SNAT.
http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO-6.html

Quoted 1 line

2. I have get this error often "too much work on eth0, dropping

I _think_ this is a better question for the linux-net mailing
list. I have a sense this is an internal problem with the network card driver and not with netfilter.
You might see if a newer kernel is available, or even consider
using the 2.6.x test kernels; they're probably able to scale better.

Quoted 3 lines

packet..." what this mean? do i have to put this on kernel: echo "65000"

Quoted 1 line

/proc/sys/net/ipv4/ip_conntrack_max ? is there any other solutions for

this ?

I don't think this is related.

Quoted 1 line

3. Do you have some other tips for MASQ ? :)

I tend to include this line in /etc/modules.conf to increase the
connection table size (not sure if it's truly required anymore):
options ip_conntrack hashsize=16384
Cheers,
- Bill

---------------------------------------------------------------------------

	"Scattered showers my ass!"
	-- Noah

(Courtesy of "Michael B. Trausch" <[email protected]>)
--------------------------------------------------------------------------
William Stearns ([email protected]). Mason, Buildkernel, freedups, p0f,
rsync-backup, ssh-keyinstall, dns-check, more at: http://www.stearns.org
Linux articles at: http://www.opensourcedigest.com
--------------------------------------------------------------------------