Conserving RAM on a Fon+
Posted: Sun Mar 29, 2009 7:22 pm
I recently installed Gargoyle beta4 on a Fon+ 2201 as I am looking for a a decent QoS solution in a Fon-sized package. Since the Fon/Fon+ routers only have 13MB of RAM, the effectiveness of QoS depends very heavily on the available memory (I've noticed). So, here are steps I've taken to squeeze down Gargoyle's memory footprint and eek out more usefulness in the QoS...
Based on http://gargoyle-router.com/phpbb/viewtopic.php?f=5&t=58, add these lines to /etc/firewall.user to limite the # of new P2P connections per minute, where [start]:[end] is the port range of your P2P application.
Irrelevant to conserving RAM, but relevant to making the Fon+ more useful, add this line to /etc/firewall.user too so that the wired LAN port may connect with clients on the WLAN (from http://gargoyle-router.com/phpbb/viewto ... p=180#p188).
To apply these new firewall rules, append these lines to /etc/config/firewall
Now append/modify these lines in /etc/sysctl.conf:
You will note this limits the # of simultaneous connections to 1024, which is certainly on the low end for heavy P2P traffic, but in my experience the only option when you want both P2P 24/7 and some sort of passable QoS. Having your cake and eating is difficult with only 13MB of RAM. 
Finally, I disabled non-critical services like Dynamic DNS (not needed), the bandwidth monitor, and even the Web interface at the SSH console.
It's pretty trivial to remotely restart/stop the web admin console as needed:
... where [router IP] is the internal IP of the Gargoyle router, e.g. 192.168.1.1. Public key authentication (I believe dropbear supports this, right?) would help streamline the process for starting/restarting the web interface.
And that's it. I can now get almost near-realtime response on services requiring minimum latency (e.g. typing at a remote SSH console), along with P2P traffic backgrounded so as not to be too disruptive. Or to put it plainly, the QoS now works noticeably better than it did using Gargoyle firmware out of the box.
Could folks share their own RAM-conserving tips?
Based on http://gargoyle-router.com/phpbb/viewtopic.php?f=5&t=58, add these lines to /etc/firewall.user to limite the # of new P2P connections per minute, where [start]:[end] is the port range of your P2P application.
Code: Select all
iptables -N limitP2P
iptables -I FORWARD -j limitP2P
iptables -I INPUT -j limitP2P
iptables -A limitP2P -p tcp --dport [start]:[end] -m state --state NEW -m limit --limit 10/minute --limit-burst 10 -j RETURN
iptables -A limitP2P -p tcp --dport [start]:[end] -m state --state NEW -j DROP
Code: Select all
iptables -I zone_lan_forward -i br-lan -o br-lan -j ACCEPT
Code: Select all
config 'include'
option 'path' '/etc/firewall.user'
Code: Select all
net.ipv4.netfilter.ip_conntrack_max=1024
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=3600
net.ipv4.netfilter.ip_conntrack_udp_timeout=60
net.ipv4.netfilter.ip_conntrack_udp_timeout_stream=180

Finally, I disabled non-critical services like Dynamic DNS (not needed), the bandwidth monitor, and even the Web interface at the SSH console.
Code: Select all
/etc/init.d/ddns_gargoyle disable
/etc/init.d/ddns_gargoyle stop
/etc/init.d/httpd_gargoyle disable
/etc/init.d/httpd_gargoyle stop
/etc/init.d/bwmon_gargoyle stop
/etc/init.d/bwmon_gargoyle disable
Code: Select all
ssh root@[router IP] /etc/init.d/httpd_gargoyle start
ssh root@[router IP] /etc/init.d/httpd_gargoyle stop
And that's it. I can now get almost near-realtime response on services requiring minimum latency (e.g. typing at a remote SSH console), along with P2P traffic backgrounded so as not to be too disruptive. Or to put it plainly, the QoS now works noticeably better than it did using Gargoyle firmware out of the box.
Could folks share their own RAM-conserving tips?