Slow Linux NAT
Hiya,
I got myself a new cable internet connection with a downstream of 50Mbps and 10Mbps upstream. I realized that my D-Link home router wouldn't be able to handle that traffic (WAN<->LAN), so I set up a computer with two NIC's and Slackware 12.2 (kernel 2.6.29.4) to use as a router instead. My problem is that I only get a throughput of about 20Mbps down and 10Mbps up (the upstream speed is fine though of course) with the linux router. Any computer connected directly to the cable modem get full speed (50/10)... any as in my usual desktop, as well as the linux router. I'm also able to send and recieve files in 100Mbps over the LAN between my router and desktop. But I just don't get full speed through the NAT routing to or from the internet. The two NIC's: eth0: 01:08.0 Ethernet controller: 3Com Corporation 3c905B 100BaseTX [Cyclone] (rev 30) eth1: 01:06.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10) eth0 is connected to cable modem and eth1 is for LAN. I've tried two different sets of iptables rules with same results: Code:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Code:
iptables -I INPUT 1 -i eth1 -j ACCEPT Any ideas what might be the cause of this..? |
iptables NAT is fast, so don't look too hard at that part of the configuration. I assure you, people use iptables NAT for gigabit networks with very little impact.
Quote:
|
Quote:
# wget ftp://ftp.port80.se/100M (4.80 MB/s) - `100M' saved [104857600] That was downloaded to the router itself. If I try to download the same file to my desktop or laptop in the LAN I get speeds of around 2MB/s. eth0: RX packets:228112 errors:0 dropped:0 overruns:699 frame:0 TX packets:127707 errors:0 dropped:0 overruns:0 carrier:0 eth1: RX packets:91983 errors:0 dropped:0 overruns:0 frame:0 TX packets:151671 errors:0 dropped:0 overruns:1 carrier:0 No errors and nothing dropped, don't know what overruns might be though? I recently rebooted it btw. With the router active my network looks like: cable modem <-> linux router <-> 100Mbps switch <-> client The router gets good speeds from the Internet, but the LAN clients doesn't. If I plug one of the LAN clients like this, it get goods speeds: cable modem <-> 100Mbps switch <-> client |
hm, weird indeed. overruns means generally that packets are being received too fast, but that shouldn't be happening on a 50Mb line. Do you get the same overruns count when downloading directly to the router, or only when forwarding/routing? What drivers are being used by the cards? (try 'ethtool -i eth0')
also 1GB sounds like plenty of RAM, but I'm curious, what does the output of 'free' show? |
# ethtool -i eth0
driver: 3c59x version: firmware-version: bus-info: 0000:01:08.0 # ethtool -i eth1 driver: 8139too version: 0.9.28 firmware-version: bus-info: 0000:01:06.0 # free -m total used free shared buffers cached Mem: 1002 45 957 0 0 30 -/+ buffers/cache: 14 988 Swap: 0 0 0 I used watch ifconfig, and the overruns only occured when downloading some big file on a lan client from the internet, not when downloading directly to the router. Just like it can't route it quick enough? |
ok, just checking to see that they're using the standard drivers, and that something unexpected wasn't consuming memory, but that looks good too.
hm, try just the masquerading w/out the filter rules, since the filter rules aren't quite correctly written. Code:
iptables -t filter -F as a separate test and just for kicks, try making eth1 your WAN and eth0 your LAN interface, to see if the behavior changes. |
Quote:
|
it should have, it does for me. here's the output from iptables-save on my system (running a similar setup as yours)
Code:
iptables-save |
Well, no traffic got through with only that rule for some reason.
Anyway I changed eth1 to be wan and eth0 to be lan. It actually gave my clients on the lan a boost of around 15Mbps. Weird. |
maybe you have a DROP policy in place, which would explain things. iptables-save would disclose that.
so swapping interfaces fixed you up? if so, then you probably have a hardware or driver issue there somewhere. |
And not only did it give a 15Mbps boost. I now have the speeds I'm supposed to be having, 50/10. Thanks for the help. :)
|
All times are GMT -5. The time now is 07:35 AM. |