Difference between revisions of "Talk:Dnsmasq"

From ArchWiki
Jump to: navigation, search
(Easier way to work with NetworkManager: Close finished.)
(need information for fixed IPs: close)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== need information for fixed IPs ==
+
== <s>need information for fixed IPs</s> ==
 
when this is set in rc.conf I think that require :
 
when this is set in rc.conf I think that require :
 
  { echo "nameserver 127.0.0.1"; grep -v "^#" /etc/resolv.conf | head -2; } > /tmp/resolv.conf
 
  { echo "nameserver 127.0.0.1"; grep -v "^#" /etc/resolv.conf | head -2; } > /tmp/resolv.conf
Line 5: Line 5:
 
  mv /tmp/resolv.conf /etc/resolv.conf
 
  mv /tmp/resolv.conf /etc/resolv.conf
 
--[[User:Sputnick|Sputnick]] 17:59, 1 August 2011 (EDT)
 
--[[User:Sputnick|Sputnick]] 17:59, 1 August 2011 (EDT)
 +
: Any error with direct change /etc/resolv.conf? Move around tmp is not very "Simple". -- [[User:Fengchao|Fengchao]] ([[User talk:Fengchao|talk]]) 01:27, 20 March 2013 (UTC)
 +
:: Closing. -- [[User:Alad|Alad]] ([[User talk:Alad|talk]]) 11:56, 14 September 2016 (UTC)
  
== <s> Easier way to work with NetworkManager </s> ==
+
== Force DNS cache persistence? ==
 +
I've noticed that the DNS cache expires very quickly (less than 60 seconds) for many domains thereby defeating the purpose of caching it in the first place. Is there a way to force entries to last longer? [[User:Neounk|Neounk]] ([[User talk:Neounk|talk]]) 01:30, 31 March 2013 (UTC)
  
If you add a line like
+
== Dnsmasq and Pidgin/Gtalk ==
  
      dns=dnsmasq
+
Using dnsmasq for dns caching seems to break gtalk on pidgin. Editing /etc/dhcpcd.conf and adding
 +
option 'domainneed' '1' solves the issue on my machine.
  
to /etc/NetworkManager/NetworkManager.conf then not only will NetworkManager do the right thing about resolv.conf, it will also start up dnsmasq for us, which seems way easier. I just did it in my machine and it works OK. It uses a temp conf file for dnsmasq at /var/run/nm-dns-dnsmasq.conf, and resolv.conf has only 127.0.0.1. This is not OK if dnsmasq is used for DHCP server, but is very good for caching. As it seems to me this will be the most common pattern for people using NetworkManager, i added this at the start of the NetworkManager section, instead of at the end.
+
if others verify the issue and fix, maybe consider for addition to the wiki?
  
Also, i feel that calling "DHCP config" the section about adding 127.0.0.1 to resolv.conf is very easy to confuse with configuring the DHCP functionality of dnsmasq itself. So i just changed the name to "resolv.conf".
+
[[User:LiamMcCalloway|LiamMcCalloway]] ([[User talk:LiamMcCalloway|talk]]) 01:10, 11 June 2013 (UTC) Liam
  
[[User:Mrpsbrk|Mrpsbrk]] ([[User talk:Mrpsbrk|talk]]) 03:35, 30 August 2012 (UTC)
+
== Usage with libvirt ==
  
: Nice edits, Mrpsbrk. I hadn't known about this so this is *nice*Cleanedup the page a bit so all is OK. Danke --[[User:Gen2ly|Gen2ly]] ([[User talk:Gen2ly|talk]]) 23:17, 30 August 2012 (UTC)
+
Network-manager think if there is one running libvirt that he run this before. To fix conflicts between other dnsmasq, eg: used in [[libvirt]], you must run it externally.
 +
 
 +
We do '''not''' want change our resolv.conf automaticly.
 +
 
 +
  {{hc|/etc/NetworkManager/NetworkManager.conf|<nowiki>
 +
[main]
 +
...
 +
dns=none
 +
</nowiki>}}
 +
 
 +
We put it manually here.
 +
 
 +
{{hc|/etc/resolv.conf.head|2=
 +
nameserver 127.0.0.1
 +
}}
 +
 
 +
The interface to bind and bind it even if there is second dnsmasq runned on computer.
 +
 
 +
{{hc|/etc/NetworkManager/dnsmasq.d/bind-interface.conf|2=
 +
interface=lo
 +
bind-interface
 +
}}
 +
 
 +
This start service if interface is up. This service can start only once before stop which will be initiate by systemd on restart/shutdown.
 +
 
 +
{{hc|/etc/NetworkManager/dispatcher.d/10_dnsmasq|2=
 +
#!/bin/sh
 +
if [ -n "$2" ] && [ "$2" = "up" ]; then # $INTERFACE is up
 +
systemctl start NetworkManager-dnsmasq.service
 +
fi
 +
}}
 +
 
 +
Systemd service.
 +
 
 +
{{hc|/etc/systemd/system/NetworkManager-dnsmasq.service|2=
 +
[Unit]
 +
Description=A lightweight DHCP and caching DNS server
 +
After=network.target
 +
Documentation=man:dnsmasq(8)
 +
 
 +
[Service]
 +
Type=dbus
 +
BusName=uk.org.thekelleys.dnsmasq
 +
ExecStartPre=/usr/bin/dnsmasq --test
 +
ExecStart=/usr/bin/dnsmasq -k --enable-dbus --user=dnsmasq --pid-file --conf-dir=/etc/NetworkManager/dnsmasq.d/
 +
ExecReload=/bin/kill -HUP $MAINPID
 +
}}
 +
 
 +
00:03, 25 March 2016‎ 3ED

Latest revision as of 11:56, 14 September 2016

need information for fixed IPs

when this is set in rc.conf I think that require :

{ echo "nameserver 127.0.0.1"; grep -v "^#" /etc/resolv.conf | head -2; } > /tmp/resolv.conf

then backup /etc/resolv.conf and last :

mv /tmp/resolv.conf /etc/resolv.conf

--Sputnick 17:59, 1 August 2011 (EDT)

Any error with direct change /etc/resolv.conf? Move around tmp is not very "Simple". -- Fengchao (talk) 01:27, 20 March 2013 (UTC)
Closing. -- Alad (talk) 11:56, 14 September 2016 (UTC)

Force DNS cache persistence?

I've noticed that the DNS cache expires very quickly (less than 60 seconds) for many domains thereby defeating the purpose of caching it in the first place. Is there a way to force entries to last longer? Neounk (talk) 01:30, 31 March 2013 (UTC)

Dnsmasq and Pidgin/Gtalk

Using dnsmasq for dns caching seems to break gtalk on pidgin. Editing /etc/dhcpcd.conf and adding option 'domainneed' '1' solves the issue on my machine.

if others verify the issue and fix, maybe consider for addition to the wiki?

LiamMcCalloway (talk) 01:10, 11 June 2013 (UTC) Liam

Usage with libvirt

Network-manager think if there is one running libvirt that he run this before. To fix conflicts between other dnsmasq, eg: used in libvirt, you must run it externally.

We do not want change our resolv.conf automaticly.

/etc/NetworkManager/NetworkManager.conf
[main]
...
dns=none

We put it manually here.

/etc/resolv.conf.head
nameserver 127.0.0.1

The interface to bind and bind it even if there is second dnsmasq runned on computer.

/etc/NetworkManager/dnsmasq.d/bind-interface.conf
interface=lo
bind-interface

This start service if interface is up. This service can start only once before stop which will be initiate by systemd on restart/shutdown.

/etc/NetworkManager/dispatcher.d/10_dnsmasq
#!/bin/sh
if [ -n "$2" ] && [ "$2" = "up" ]; then # $INTERFACE is up
	systemctl start NetworkManager-dnsmasq.service
fi

Systemd service.

/etc/systemd/system/NetworkManager-dnsmasq.service
[Unit]
Description=A lightweight DHCP and caching DNS server
After=network.target
Documentation=man:dnsmasq(8)

[Service]
Type=dbus
BusName=uk.org.thekelleys.dnsmasq
ExecStartPre=/usr/bin/dnsmasq --test
ExecStart=/usr/bin/dnsmasq -k --enable-dbus --user=dnsmasq --pid-file --conf-dir=/etc/NetworkManager/dnsmasq.d/
ExecReload=/bin/kill -HUP $MAINPID

00:03, 25 March 2016‎ 3ED