jpillora / docker-dnsmasq

dnsmasq in a docker container, configurable via a simple web UI
MIT License
734 stars 226 forks source link

Config must have 'user=root' enabled #1

Closed nodesocket closed 7 years ago

nodesocket commented 8 years ago

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
jpillora commented 8 years ago

Thats strange, here's mine:

#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

#================
#redirect .service requests into the cluster
server=/service/1.2.2.2

#================
#static entries
address=/foo.bar/1.2.3.4
address=/foo.bar/1.2.3.4
address=/foo.bar/1.2.3.4
address=/foo.bar/1.2.3.4
address=/foo.bar/1.2.3.4
address=/foo.bar/1.2.3.4
address=/foo.bar/1.2.3.4

Any difference saving via the web ui?

nodesocket commented 8 years ago

I updated the curl request to:

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

And now that just returns, without any body. Is that right?

Also, by the way, I am calling the POST without any /etc/dnsmasq.conf file already created.

jpillora commented 8 years ago

ah data-binary, that probably did it, yep should just return just a 200 OK

nodesocket commented 8 years ago

Very strange though, it appears to be working, yet the domain I am "spoofing" is still resolving to the real ip:

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

$ ping -c 1 brand.com
PING brand.com (72.52.4.91): 56 data bytes

Is there any output, or way to view logs what is happening?

nodesocket commented 8 years ago

@jpillora sorry to bother, but still can't quite get this working. Any insight based on my above comment?

Here is the contents of /tmp/files/dnsmasq.conf:

#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
jpillora commented 8 years ago

Try dropping the leading . in .brand.com

nodesocket commented 8 years ago

Isn't that required for wildcard? I guess, I wish when calling the RESTful endpoint:

POST /configure

It would output that the dnsmasq service was restarted successfully or not... The output.

jpillora commented 8 years ago

Ah yes, you're right, never used wildcard before. When it returns 200, it means service dnsmasq restart exited with 0. Just tested it. It works fine.

$ host foo.brand.com 10.9.3.2
Using domain server:
Name: 10.9.3.2
Address: 10.9.3.2#53
Aliases:

foo.brand.com has address 127.0.0.1

Docker ports mapped?

jpillora commented 7 years ago

I've migrated to alpine linux, so I think this is fixed, re-open if it's still an issue