Skip to content

Instantly share code, notes, and snippets.

@suntong
Last active May 3, 2020 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suntong/521fbb38db65d77c9cac5f837be53870 to your computer and use it in GitHub Desktop.
Save suntong/521fbb38db65d77c9cac5f837be53870 to your computer and use it in GitHub Desktop.

Configure dbab

The dbab best works with a second static IP address. To configure dbab (and to work with a local web server):

  1. Stop dbab-svr service
  2. Change the IP address that dbab uses to the second IP address
  3. Start dbab-svr service
  4. Start your local web server again if you have any. You may need to limit its listening port from 0.0.0.0 to your first static IP as well if necessary.

In details, do the following as root, again assuming that the server's own IP address is 192.168.0.101, and its second IP is 192.168.0.100. The second IP will be used for the dbab pixelserv service, while server's own IP address will be used for WPAD.

# (run the following as root)

# stop dbab service
/etc/init.d/dbab stop

# use the second IP for dbab-svr to listens on
ip -f inet addr show eth0 | awk '/inet /{print $2}' | sed 's|/.*$||; 1d' | sudo tee /etc/dbab/dbab.addr
# verify its content before moving on
cat /etc/dbab/dbab.addr
# if it is not what you intent it to be, correct it with your text editor
  # or, set it manually (with a different IP address)
  echo 192.168.0.100 | sudo tee /etc/dbab/dbab.addr

# update ad blocking list with the second IP address 
/usr/sbin/dbab-get-list
/usr/sbin/dbab-add-list

# OPTIONAL! do the following only if you have squid caching server
# and you want to enable automatic WPAD service
hostname | tee /etc/dbab/dbab.proxy
  # NB, if your squid caching server is on a different server, do this instead
  echo my_squid_server_name | tee /etc/dbab/dbab.proxy
# then, 
/usr/sbin/dhcp-add-wpad
# Again verify everything here before moving on because script might not be
# 100% time correct. Manually tweaking is inevitable sometimes.

# restart DNS & DHCP
systemctl restart dnsmasq

# Verify dnsmasq ads blocking is working
$ dig +short actualdeals.com ad.abcnews.com
192.168.0.100
192.168.0.100

# re-start dbab service
/etc/init.d/dbab start

# Verify dbab pixelserv server is working
# do the following on command line or visit http://actualdeals.com/ from browswer
$ curl -s --dump-header - http://actualdeals.com/
HTTP/1.1 200 OK
Content-type: image/gif
Accept-ranges: bytes
Content-length: 43


# re-start your local web server again if you have any

# optional, only when dbab will not auto start on boot up
update-rc.d dbab defaults

That's it. We're done.

Static IP configuration

Here is a recap of what I did to configure my machine with the 192.168.2.102 static IP and a second one of 192.168.2.101, which might not apply to your distro any more. E.g., modern Ubuntu no longer use /etc/network/interfaces to config static IP, and I grew tired of tracking how it is done, throughout all its changes, which is convoluted to me at best. Please refer to other helps, if you're not doing it this way, as configuring the static and second IP is out of the scope of this document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment