Tuesday, April 23, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  23] [ 0]  / answers: 1 / hits: 54771  / 3 Years ago, thu, may 27, 2021, 9:13:07

I have installed DNSMASQ but it was not starting as 53 port was busy.



I found out that ubuntu already had dnsmasq package and it's working.



Now the problem is...I just want to be able to resolve my hosts in /etc/hosts through it



i.e: nslookup somehostonlan localhost
to be resolved to certain IP taken from /etc/hosts file.



but this is not happening.



Why? BTW, as the caching DNS server it's working fine. I just want it to resolve hosts from /etc/hosts file that's all


More From » dnsmasq

 Answers
1

To speed up internet, ubuntu 12.04 has added a plugin to NetworkManager to start dnsmasq, a local dns server that caches dns entries. The problem is the plugin has hardcoded the --no-hosts string.



So one solution is to comment out the line that load the plugin in the NetworkManager config file and restart NetworkManager :



sudo mv /etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/NetworkManager.conf.bak
sudo bash -c 'cat /etc/NetworkManager/NetworkManager.conf.bak | sed -e "s/^(dns=dnsmasq)$/#1/" > /etc/NetworkManager/NetworkManager.conf'
sudo restart network-manager


Another solution is to wrap dnsmasq to filter out the undesired arguments:



sudo mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.bin
sudo bash -c 'cat > /usr/sbin/dnsmasq' << EOF
#!/bin/sh
dnsmasq=/usr/sbin/dnsmasq.bin

exec $dnsmasq `echo $@ | sed -e s/--no-hosts//`
EOF

sudo chmod 755 /usr/sbin/dnsmasq


Please mark the bug as affecting you.



Another solution without patching system files



cat /etc/NetworkManager/dnsmasq.d/hosts.conf 

addn-hosts=/etc/hosts

[#39543] Saturday, May 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ticrew

Total Points: 190
Total Questions: 111
Total Answers: 99

Location: Fiji
Member since Wed, Jul 14, 2021
3 Years ago
;