Will_M
Posts: 2
Joined: Tue Feb 23, 2016 1:20 am

Conditional dns using dnsmasq with ad blocking

Tue Feb 23, 2016 1:34 am

I followed this guide some time ago to setup ad blocking dns using the raspberry pi: https://learn.adafruit.com/raspberry-pi ... ess-point/

I modified the dnsmasq.custom.conf file afterwards to allow for conditional dns redirecting. I basically wanted any requests coming from the kids computers to be directed through OpenDNS, and anything else going through Google's DNS servers. So now my dnsmasq configuration looks like this:

Code: Select all

#### DNS #####
domain-needed
bogus-priv
no-resolv
server=192.168.1.5
server=8.8.8.8
server=8.8.4.4
cache-size=4096

##### DHCP ######
local=/home/
expand-hosts
interface=eth0
dhcp-range=set:green,192.168.1.5,192.168.1.200,12h
dhcp-range=set:red,192.168.1.2,192.168.1.4,12h
dhcp-option=tag:green,option:dns-server,192.168.1.5
dhcp-option=tag:red,option:dns-server,208.67.222.222,208.67.220.220  #OpenDNS servers
dhcp-option=3,192.168.1.1
dhcp-authoritative
dhcp-option=252,"\n"
Now anything on the "green" network will use the Raspberry PI for dns which blocks ads and uses Google's dns servers, and anything on the "red" network uses OpenDNS. This works fine, however the problem I have is this doesn't allow for the ad blocking on any of the kids computers using OpenDNS as all dns queries are redirected straight to OpenDNS bypassing the Raspberry PI setup completely. Is there a way to use two different dns services but still use the ad blocking provided by the dnsmasq configuration?

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Conditional dns using dnsmasq with ad blocking

Fri Feb 26, 2016 7:48 pm

Did you try adding dnsmasq listen address as first dns server?

Code: Select all

dhcp-option=tag:red,option:dns-server,192.168.1.5,208.67.222.222,208.67.220.220  #OpenDNS servers
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Will_M
Posts: 2
Joined: Tue Feb 23, 2016 1:20 am

Re: Conditional dns using dnsmasq with ad blocking

Mon Feb 29, 2016 3:48 am

I did try that, but what that did is actually circumvent the OpenDNS settings. So dns queries ended up going through 8.8.8.8 instead of the OpenDNS servers.

I even tried this:

Code: Select all

dhcp-option=tag:green,option:dns-server,192.168.1.5,8.8.8.8,8.8.4.4
dhcp-option=tag:red,option:dns-server,192.168.1.5,208.67.222.222,208.67.220.220
And then commenting out the Google DNS servers in the config, but then ad blocking wasn't working very well.

Return to “Networking and servers”