Sign inSign up

edza78/dnsmasq

By edza78

•Updated about 7 years ago

dnsmasq container with blocked sites list.

Image
2

456

edza78/dnsmasq repository overview

⁠Changes in version 2.5:

  • Added support to use a local/private DNS, in cases where network admin blocked external DNS servers.
  • Added cache backup and import capabilities.

⁠Changes in version 2.0:

  • Added download of DNS Servers list from GitHub.
  • Added automatic dnsmasq service restart when user request it.
  • Added automatic update of Blocked sites list and DNS Server list before restart service.
  • Added support to create local list of sites.

⁠General description

Container with dnsmasq installed and configured to block tracker and ads sites.

The list of sites and DNS Server is retrieved from: github.com/edza978/blockedsites⁠

How to run it:

docker run --name=dnsmasq  -h dns.dev -v ${PWD}:/mnt --cap-add=NET_ADMIN -p 53:53 -p 53:53/udp --rm -itd edza78/dnsmasq

In ${PWD} you can find the log file ( dnsmasq.log ) That file contains all queries done to the container and can be used to debug and analysis of use.

How to use it:

Configure your network's DNS to: 127.0.0.1 and enjoy.

You can see a demo in: https://asciinema.org/a/WYNSjC6IUhxaC0GTVq5pjwbNH⁠

⁠Advanced use:

⁠1. Add desired records to the DNS config.

From version 2.0. The user can add it's own records to the lists used by dnsmasq to resolv hostnames. To do this, follow this steps:

  1. Define the host/domain you want to add (i.e: www.playboy.com⁠).
  2. Define the IP address to redirect to (To block sites use: 127.0.0.1)
  3. Create the file ( loca.conf ) in ${PWD} and add a line like this:
address=/www.playboy.com/127.0.0.1
  1. Save the file. Next time container's start or dnsmasq service be restarted, the new reocrd will be added. Tooltip: You can use the script: addLocal.bash from: github.com/edza978/blockedsites⁠
⁠2. Request service restart and domain' lists updates.

From version 2.0. The user can request an update of the lists and restart of the service from the HOST. To do this, follow this steps:

  1. Create a file in ${PWD} named: update.now.
touch update.now
  1. The container check for that file every 60 seconds, if it exists the DNS.conf, ads.conf files are downloaded from github.com⁠, the ${PWD}/local.conf file is updated in dnsmasq's config and dnsmasq service is restarted to add the new records.
⁠3. Local/Private DNS server use

From version 2.5. The user can define a private/local DNS server to be used as parent if the network administrators blocked external DNS servers. To do this, follow this steps:

  1. Create a file in ${PWD} named: localDns.conf.
touch update.now
  1. Add the next line to the file changing the 192.168.1.1 to your DNS Server's IP.
server=192.168.1.1      # Local DNS
  1. Next time the service start the local DNS server will be used as unique parent DNS. Hint: localDns.conf file can be created before docker run so at 1st start dnsmasq will use the private DNS.
⁠4. Create a backup of cache and import it to next executions.

From version 2.5. The user can request a dump of the dnsmasq's cache. This dump will be stored in the file: ${PWD}/cacheDump.txt, and the container's dnsmasq is configured to import that file at start. To request a dump, follow this steps:

  1. Create a file in ${PWD} named: dump.now.
touch dump.now
  1. The container check for that file every 60 seconds, if it exists the dnsmasq's cache will be dumped to dnsmasq.log and all the IPv4 and IPv6 will be dumped to cacheDump.txt in format similar to /etc/hosts file.
  2. Next time the service start the dnsmasq will import all cacheDump.txt records to it's config.

Tag summary

Content type

Image

Digest

Size

24.7 MB

Last updated

about 7 years ago

docker pull edza78/dnsmasq