Giter Site home page Giter Site logo

docker-dnsmasq's Introduction

docker-dnsmasq

dnsmasq in a docker container, configurable via a simple web UI

Docker Pulls Image Size

Usage

  1. Create a /opt/dnsmasq.conf file on the Docker host

    #dnsmasq config, for a complete example, see:
    #  http://oss.segetech.com/intra/srv/dnsmasq.conf
    #log all dns queries
    log-queries
    #dont use hosts nameservers
    no-resolv
    #use cloudflare as default nameservers, prefer 1^4
    server=1.0.0.1
    server=1.1.1.1
    strict-order
    #serve all .company queries using a specific nameserver
    server=/company/10.0.0.1
    #explicitly define host-ip mappings
    address=/myhost.company/10.0.0.2
  2. Run the container

    $ docker run \
    	--name dnsmasq \
    	-d \
    	-p 53:53/udp \
    	-p 5380:8080 \
    	-v /opt/dnsmasq.conf:/etc/dnsmasq.conf \
    	--log-opt "max-size=100m" \
    	-e "HTTP_USER=foo" \
    	-e "HTTP_PASS=bar" \
    	--restart always \
    	jpillora/dnsmasq
    
  3. Visit http://<docker-host>:5380, authenticate with foo/bar and you should see

    screen shot 2017-10-15 at 1 41 21 am
  4. Test it out with

    $ host myhost.company <docker-host>
    Using domain server:
    Name: <docker-host>
    Address: <docker-host>#53
    Aliases:
    
    myhost.company has address 10.0.0.2
    

MIT License

Copyright © 2018 Jaime Pillora <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

docker-dnsmasq's People

Contributors

bucha avatar jackygurui avatar jpillora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-dnsmasq's Issues

port 53 on TCP is also mandatory

Basic queries on port domain == 53 in example README does not contain TCP port. It is important requirement as a fallback to every response which is too long. Add not only port 53 udp forward, but also 53 tcp port.

No ability to import more config files

Hey,

Great project. I really enjoy the container, but I've been unable so far to add extra hostfiles. By simple redirecting the whole directory (instead of only the config file) breaks everything. And so does every other solution I've tried.

My goal is to have auto-updating DNS blocking lists which I update on the host and are linked in the Docker container. https://github.com/notracking/hosts-blocklists is a good example of such a list. It takes some of the performance hit away from my firewall.

Kind regards

bend directories / logs

How can I bend the log files for dns, dhcp, system to my folder outside the container (on host)?
Syslog is also missing.

Also I want to store multiple config-files in the hosts-folders.

I am not firm to create my own container.

Config must have 'user=root' enabled

Trying to create a dnsmasq config via curl, but it keeps on erroring with:

Config must have 'user=root' enabled

Here is the config file /tmp/files/dnsmasq.conf I am sending into curl:

#listen on container interface
listen-address=0.0.0.0
interface=eth0
user=root

#only use these namesservers
no-resolv
server=8.8.4.4
server=8.8.8.8

#static entries
address=/.brand.com/127.0.0.1

And the curl command:

$ curl --silent --show-error --location --request POST --data "@/tmp/files/dnsmasq.conf" http://127.0.0.1:8080/configure

Config must have 'user=root' enabled

DHCP serving

Can this container be modified to act as the host network's dhcp server?

/sync is very slowly.

$docker run
--name dnsmasq
-d
-p 53:53/udp
-p 5380:8080
-v /opt/dnsmasq.conf:/etc/dnsmasq.conf
--log-opt "max-size=100m"
-e "HTTP_USER=foo"
-e "HTTP_PASS=bar"
--restart always
jpillora/dnsmasq

After started and login, /sync used long time, one hour or more. please fix it. THX!!!

Reverse proxy is slow

image

my nginx configure:

docker run \
    --name nginx \
    -d \
    -p 80:80 \
    -v /opt/data/nginx/conf.d/:/etc/nginx/conf.d/ \
    --log-opt "max-size=10m" \
    nginx
server {
    listen       80;
    server_name  dns.com;
    location / {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://192.168.100.99:8080;
    }
}

dnsmasq configure:

log-queries
address=/dns.com/192.168.100.99

windows can't get domain name resolution record

Hi, Mr. Jpillora:

I set up a dns server refer to official articles " https://hub.docker.com/r/jpillora/dnsmasq"
dnsmasq-ip 10.2.1.137
CentOS-ip 10.2.1.138
Windows-ip 172.21.16.235

The contents of the document “dnsmasq.conf ” are as follows
log-queries
no-hosts
no-resolv
cache-size=1000
server=114.114.114.114
address=/harbor-zhc.zy.com/10.2.1.138

It run well for CentOS Server , but not for Windows. For example:

Running this command in CentOS:
$ nslookup harbor-zhc.zy.com 10.2.1.137
Server: 10.2.1.137
Address: 10.2.1.137#53

Name: harbor-zhc.zy.com
Address: 10.2.1.138

Running this command in Windws:
C:\Users\admin>nslookup harbor-zhc.zy.com 10.2.1.137
服务器: UnKnown
Address: 10.2.1.137

DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** 请求 UnKnown 超时

dnsmasq log when windows access:
⁣⁣dnsmasq: query[PTR] 137.1.2.10.in-addr.arpa from 172.21.16.235
⁣⁣dnsmasq: forwarded 137.1.2.10.in-addr.arpa to 114.114.114.114
⁣⁣dnsmasq: reply 10.2.1.137 is NXDOMAIN
⁣⁣dnsmasq: query[AAAA] harbor-zhc.zy.com from 172.21.16.235
⁣⁣dnsmasq: config harbor-zhc.zy.com is NODATA-IPv6
⁣⁣dnsmasq: query[AAAA] harbor-zhc.zy.com from 172.21.16.235
⁣⁣dnsmasq: config harbor-zhc.zy.com is NODATA-IPv6


This problem has been bothering me for two days. I have searched a lot of articles and still can't solve it
Look forward to your reply, thank you so much!

switch from no-daemon to keep-in-foreground

From dnsmasq docs:

-d, --no-daemon

Debug mode: don't fork to the background, don't write a pid file, don't change user id, generate a complete cache dump on receipt on SIGUSR1, log to stderr as well as syslog, don't fork new processes to handle TCP queries. Note that this option is for use in debugging only, to stop dnsmasq daemonising in production, use --keep-in-foreground.

I haven't worked that much with dnsmasq, so if --no-daemon is more correct for Docker usage, it would be nice to know why.

(Request) webproc listen port option.

Hello Dear

My name is tokohito.
Thanks your great job!

I also use docker-dnsmasq as DNS and DHCP Server.
So I have to set network settings as "host mode".

This is an example of a command that I actually use.

$ sudo docker run --name dnsmasq -d --restart always --network host --privileged -v /var/data/dnsmasq.conf:/etc/dnsmasq.conf --log-opt "max-size=100m" -e "HTTP_USER=admin" -e "HTTP_PASS=password" jpillora/dnsmasq

Unfortunately, the 8080 port that webproc uses by default conflicts with other products.
So I want to be change to webproc listen port to any user-specified setting.
e.g)
-e "HTTP_PORT=5380"

I'm glad if you change the docker image like that.

Best regards!

Using docker-dnsmasq on Ubuntu

Can someone please help how to use this image on Ubuntu. The problem is that Ubuntu has already a default dns server running on port 53.
I don't think it is a good idea to stop the local dns, as when the container is not running, there is not network.
It would be nice if both could run in parallel.

javascript memory leak?

First off, this works brilliantly for us as a local DNS solution, for forwarding, caching and local name resolution. Thank you for your efforts!

The only issue I've encountered is that if I keep a tab open in Firefox with the web interface running, it will begin to eat RAM like a monster, and I usually get a firefox prompt "a web page is slowing down your browser" and a choice of "stop script" or "wait", which works by (you guessed it) stopping the JS on that tab. Memory is released and all is well, and as expected the log pane of webproc stops updating.

Now maybe my issue is the sheer volume of data being updated, as it's the DNS logs for our entire LAN. If that's the case, then it's not really a big deal. I've only kept the tab pinned while configuring for a couple of weeks, I don't really need to see the constant flow of DNS logs.

If there was a way to stop it from consuming so much RAM, I would assume by refreshing the data displayed, or something like that, it would be a good thing. I can imagine there will come a time when I may need to consult the logs to diagnose issues on the network, fixing this would make that easier.

My machine is no slouch, I've got 16GB RAM, an i7 with 8 threads, running Ubuntu-MATE 16.04.

I am not JS savvy enough to debug, otherwise I'd try to fix it myself. :(

Show leases

How to see the leases?

docker exec -it /var/lib/misc/dnsmasq.leases

ends up with ...

OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "/var/lib/misc/dnsmasq.leases": permission denied: unknown

DNSSEC not working in docker

Hey!
If I want to enable DNSSEC it states that dnsmasq is compiled without DNSSEC:

dnsmasq: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect inotify dumpfile

⁣⁣dnsmasq: unsupported option (check that dnsmasq was compiled with DHCP/TFTP/DNSSEC/DBus support) at line 6 of /etc/dnsmasq.conf

dnsmasq: DNSSEC not available: set HAVE_DNSSEC in src/config.h

(line 6 is "trust-anchor=...")
I use jpillora/dnsmasq:latest

(Request) Send SIGHUP to load changes

This has probably more to do with webproc than with this container but I think it would be great to have the webinterface send a HUP signal after saving changes.

It's currently sending an INT signal, waiting, killing the process, waiting and then relaunching dnsmasq, which is fairly slow.

However sending a HUP signal reloads the configuration immediately, e.g.:

$ docker exec dnsmasq killall -HUP dnsmasq

Automate DNS registration on a service in a dockerfile.

Hello,
I am using dnsmasq with other services in a dockerfile. I would like to make a request from my service to automatically register the domain name related to the IP address of the service. But I do not know how to do it. Can someone help me ?
Thank you in advance for your help.
Best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.