How to set the upstream servers of dnsmasq on ubuntu 15.10?
You can proceed as follows:
If your system runs a dhcp client then edit the dhclient.conf, you have to uncomment/modify the prepend domain-name-server
section as:
prepend domain-name-servers 8.8.8.8;
Create a file /etc/resolv.dnsmasq.conf
that contains:
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver <your ISP DNS>
copy the file /usr/share/doc/dnsmasq-base/examples/dnsmasq.conf.example
in /etc/NetworkManager/dnsmasq.d/dnsmasq.conf
and modify it to your needs. You have to add the line:
resolv-file=/etc/resolv.dnsmasq.conf
Then use networkmanager to launch dnsmasq. Edit the file /etc/NetworkManager/NetworkManager.conf
inserting in the [main] section dns=dnsmasq
try dig:
dig www.google.com
; <<>> DiG 9.9.5-9+deb8u2-Debian <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45033
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 299 IN A 74.125.232.147
www.google.com. 299 IN A 74.125.232.144
www.google.com. 299 IN A 74.125.232.145
www.google.com. 299 IN A 74.125.232.146
www.google.com. 299 IN A 74.125.232.148
;; Query time: 29 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Dec 17 01:43:19 CET 2015
;; MSG SIZE rcvd: 123
Then restart networking and NetworkManager and retry dig:
systemctl restart networking
systemctl restart NetworkManager
dig www.google.com
; <<>> DiG 9.9.5-9+deb8u2-Debian <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34735
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 299 IN A 74.125.232.144
www.google.com. 299 IN A 74.125.232.147
www.google.com. 299 IN A 74.125.232.145
www.google.com. 299 IN A 74.125.232.148
www.google.com. 299 IN A 74.125.232.146
;; Query time: 30 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Dec 17 01:46:38 CET 2015
;; MSG SIZE rcvd: 123
As you can see the resolver now is 127.0.0.1. If you dig again you will see that the query time will slow down to 0. This indicate that dnsmasq is running.
Related videos on Youtube
Comments
-
Sk4ry almost 2 years
I want to set the upstream servers of
dnsmasq
on ubuntu 15.10. I've read a lot of documentations or resources about dnsmasq, in which they referred to a configuration file called/etc/dnsmasq.conf
, but I couldn't find it. I tried to find out howdnsmasq
was started when system booted, but I couldn't finddnsmasq
under/etc/init.d
, either.So which file should I modify to set the upstream servers of
dnsmasq
? -
Sk4ry over 8 yearsThank you, it helps me a lot. But could you elaborate any further about how to set upstream servers? I tried to set
server=8.8.8.8
in/etc/dnsmasq.conf
, but it didn't work. Dnsmasq still uses127.0.1.1
as the upstream server.