dd-wrt – speeding up internet browsing
Recently I have some time to play with my DD-WRT based router. I wanted to speed up internet browsing, so I decided to put on DD-WRT squid and DNSMasq. And here is what I’ve done.
My router config:
Firmware:
DD-WRT v24-sp2 (08/07/10) mega
Partition layout:
Filesystem Size Used Avail Use% Mounted on
rootfs 5.7M 5.7M 0 100% /
/dev/root 5.7M 5.7M 0 100% /
/dev/mtdblock/4 25M 900K 24M 4% /jffs
/dev/discs/disc0/part1
504M 314M 165M 66% /opt
/dev/sda3 6.8G 1.1G 5.4G 17% /mnt
As You can see I have added extra space by connecting to my router 8GB USB flash drive ( Patriot Xporter XT ), and installed OTRW.
I will not provide specific information how to install squid and DNSMasq (DNSMasq is installed by default), but my settings of those daemons.
So here are the main changes that I’ve done in squid configuration:
http_port 192.168.1.1:3128 transparent
cache_mem 8 MB
maximum_object_size_in_memory 32 KB
cache_dir ufs /mnt/squid/cache 1024 16 256
minimum_object_size 0 KB
maximum_object_size 4 MB
Then I’ve created file:
/opt/etc/rc.firewall
And put in it:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128
So all the traffic to http is redirect to squid cache.
Squid proxy is almost done, but You need to configure above firewall to start up automatically when router starts:
nvram set rc_firewall=/opt/etc/rc.firewall
nvram commit
chmod 755 /opt/etc/rc.firewall
From now on You router will automatically redirect all http traffic through You own squid cache server, what will cause speed improvement while browsing sites in internet.
Despite it was faster I wanted to do it much better, and I started to digging up what is taking too long to load the page, and I realized that DNS queries takes too long, so I decided to use DNSMasq to cach dns queries.
To turn on caching just put
cache-size=2000
In Services->Services->Additional DNSMasq Options box, click Save, and Apply Settings.
It will cache 2000 dns queries in routers memory.
Ok, but what I’ve achieved by those modifications:
- faster DNS queries responses (before modifications: +/- 40ms, after modifications: +/- 1ms)
- faster page loading (before modifications: +/- 8s, after modifications: +/- 3s – it all depends on site, for example – facebook.com from 34s to 12s)
I will try to do some more modifications to speed up internet browsing with dd-wrt, so stay tuned.
hello!
doesnt facebook, youtube, google,.. use httpS and so squid will not chache anything from that pages?
Yeah – this configuration will only apply to http traffic. But You can try to redirect https traffic to squid. You need to add this line to Your configuration of firewall:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128