I live in an area where reliable DSL is not available, therefore I access the Internet at home using 3G mobile broadband and short wave radio. However, my 3G mobile broadband contract is limited to 15GB of bandwidth per month, if I exceed that limit then I start incurring additional charges which can mount up very quickly.
nullserv is a minimal webserver. It's only purpose is to serve up null content.
nullserv was inspired by pixelserv
which serves a 1x1 pixel transparent
nullserv expands on this idea by
serving up null
Using some creative firewalling (netfilter/iptables) rules or local DNS you can
redirect some requests (for adverts for example) to
nullserv, thus saving
make sudo make install
- inetd (or similar).
Currently, I'm using
dnsmasq on a Gargoyle
router to redirect ad-server IP addresses to
nullserv running on an embedded Debian
Squeeze box. Gargoyle is based on OpenWRT, so this technique should also work with
git and the compiler toolchain.
sudo apt-get install build-essential git-core
Compile and install
git clone https://github.com/flexiondotorg/nullserv.git cd nullserv make sudo make install
Install OpenBSD inetd.
sudo apt-get install openbsd-inetd
Add the following to
www stream tcp nowait nobody /usr/sbin/tcpd /usr/bin/nullserv
sudo /etc/init.d/openbsd-inetd restart
Some ads are served via https, we can use
stunnel to forward https
sudo apt-get install stunnel
Create SSL certificate and a key.
sudo openssl req -new -nodes -x509 -out /etc/ssl/certs/stunnel.pem -keyout /etc/ssl/certs/stunnel.pem
[https] section in
/etc/stunnel.conf, I also disable the
[ssmtp] as I don't require them.
[https] accept = 443 connect = 80 TIMEOUTclose = 0
ENABLED and set it to
sudo /etc/init.d/stunnel4 start
Open a web browser and request anything you like from http://192.168.2.1 or
whatever the IP address is the host where
nullserv is installed. If you
request a file type that is not recognised by
nullserv it with send back a 0
byte response of
contrib/adaway.sh and then
scp the generated
on your Gargoyle/OpenWRT router.
cd contrib ./adaway.sh scp adaway.txt firstname.lastname@example.org:/etc/
Add the following to
/etc/config/dhcp under the
config dnsmasq section.
list addnhosts '/etc/adaway.txt'
You should now find that ads are blocked and replaced with null content. You can do lots more with dnasmasq on Gargoyle/OpenWRT, see the Wiki:
v0.3 2013, 29th May.
- Merged fixes and improvements contributed by Ben Shadwick.
- Updated documentation.
v0.2 2010, 16th September.
- Added optional logging.
v0.1 2010, 15th September.
- Initial release
- I am not a C programmer ;-)
in.dnsconfigurations to compliment
You can grab the source from Launchpad. Contributions are welcome :-)
A minimal webserver for serving up null content. Copyright (c) 2013 Flexion.Org, http://flexion.org/
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.