To start with, uninstall isc-dhcp-server and install dnsmasq. We'll be using dnsmasq as your dhcp server instead of isc-dhcp-server. You may want to do a sudo apt-get update first, and then execute the following:
sudo apt-get autoremove isc-dhcp-server sudo apt-get install -y dnsmasq dnsutils
sudo service dnsmasq status
sudo nano /etc/dnsmasq.d/dnsmasq.custom.conf
interface=wlan0 dhcp-range=wlan0,192.168.42.10,192.168.42.50,2h # Gateway dhcp-option=3,192.168.42.1 # DNS dhcp-option=6,192.168.42.1 dhcp-authoritative
These are the minimum settings required to get the dhcp server setup properly. There are a lot more settings available as examples in /etc/dnsmasq.conf if you want to configure it further.
Any files added to the directory /etc/dnsmasq.d are automatically loaded by dnsmasq after a restart. This is a convenient way to override or add new configuration files in Debian.
Open the file with sudo nano /etc/resolv.conf and replace the contents with the following:
nameserver 192.168.42.1 nameserver 8.8.8.8 nameserver 8.8.4.4
sudo service dnsmasq restart
dig adafruit.com
Open nano and create a file with the following command:
sudo nano /usr/local/bin/dnsmasq_ad_list.sh
#!/bin/bash ad_list_url="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext" pixelserv_ip="192.168.42.49" ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf" temp_ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf.tmp" curl $ad_list_url | sed "s/127\.0\.0\.1/$pixelserv_ip/" > $temp_ad_file if [ -f "$temp_ad_file" ] then #sed -i -e '/www\.favoritesite\.com/d' $temp_ad_file mv $temp_ad_file $ad_file else echo "Error building the ad list, please try again." exit fi service dnsmasq restart
sed -i -e '/ads\.stackoverflow\.com/d' $temp_ad_file
Next allow the file to be executed:
sudo chmod +x /usr/local/bin/dnsmasq_ad_list.sh
sudo /usr/local/bin/dnsmasq_ad_list.sh
You could manually do this every once in a while, but it's easier if we setup a weekly cron job with the root user.
Open crontab with the following command:
sudo crontab -e
@weekly /usr/local/bin/dnsmasq_ad_list.sh
dig doubleclick.com