Ad blocking implementation

General discussion about Gargoyle, OpenWrt or anything else even remotely related to the project

Moderator: Moderators

Post Reply
Posts: 20
Joined: Mon Aug 24, 2009 2:17 pm

Ad blocking implementation

Post by foreverstorm »

Hi, I have tried to make a universal adblock on my gargoyle WR1043ND router running the latest 1.5.10-ar71xx firmware, but I haven't got it working quite right yet and need some help.

I got a block list from and added it to the etc/hosts file using WinSCP. That works fine - but I find the messages saying url cannot be found in place of the ads still annoying.

I wanted to implement a pixelserv from, but I can't get it to run. In /etc/init.d/pixelserv I have the (set to be executable) code

Code: Select all

#!/bin/sh /etc/rc.common



start() {
       service_start /sbin/
and in usr/sbin/ I have the (1.0 daemon) code

Code: Select all

#! /usr/bin/perl -Tw

use IO::Socket::INET;

$pixel=pack("C*",qw(71 73 70 56 57 97 1 0 1 0 128 0 0 255 255 255 0 0 0 33 249 4 1 0 0 0 0 44 0 0 0 0 1 0 1 0 0 2 2 68 1 0 59));

$sock = new IO::Socket::INET (  LocalHost => '',
                                LocalPort => '80',
                                Proto => 'tcp',
                                Listen => 30,
                                Reuse => 1);

if (!defined($sock)) {
        print "error : cannot bind : $! exit\n";

while ($new_sock = $sock->accept()) {
       while (<$new_sock>) {
#             print "$_\n";
              if ($_ eq '') { last; }
        print $new_sock "HTTP/1.1 200 OK$crlf";
        print $new_sock "Content-type: image/gif$crlf";
        print $new_sock "Accept-ranges: bytes$crlf";
        print $new_sock "Content-length: 43$crlf$crlf";
       print $new_sock $pixel;

It doesn't make a difference, however.

If it's too difficult to setup on the router - I also have a synology nas that might be able to host it, but I'm not sure how that would be done.

Any ideas?

User avatar
Posts: 66
Joined: Wed Aug 22, 2012 12:04 pm
Location: Turkey

Re: Ad blocking implementation

Post by powerlogy »

Done that with a second ip interface on router,firewall rule and a web server.

There was a openwrt topic about that on openwrt forums.
Here is the link : ... 51#p197151

Posts: 20
Joined: Mon Aug 24, 2009 2:17 pm

Re: Ad blocking implementation

Post by foreverstorm »

Thanks, that looks like what I'm after. But I'm stuck at the second block of commands; as soon as I enter uci add uhttpd uhttpd I get the message uci: Entry not found. Is there something else I need to do first?

Posts: 5
Joined: Sat Jun 01, 2013 6:15 pm

Re: Ad blocking implementation

Post by lakyljuk »

I would like to have this solution working as well, because I have the same router and would like to get rid of adblock chrome extension in every computer behind router. If some one experienced could advice, how to make it work, it would be appreciated, thanks.


Post Reply