blob: cbb6e82c0bf3cf5cccc3c45e5281bf54c0b8cfaf [file] [log] [blame]
Simon Kelley3d8df262005-08-29 12:19:27 +01001DBus support must be enabled at compile-time and run-time. Ensure
2that src/config.h contains the line
3
4#define HAVE_DBUS.
5
6and that /etc/dnsmasq.conf contains the line
7
8enable-dbus
9
10Because dnsmasq can operate stand-alone from the DBus, and may need to provide
11service before the dbus daemon is available, it will continue to run
12if the DBus connection is not available at startup. The DBus will be polled
13every 250ms until a connection is established. Start of polling and final
14connection establishment are both logged. When dnsmasq establishes a
15connection to the dbus, it sends the signal "Up". Anything controlling
16the server settings in dnsmasq should re-invoke the SetServers method
17(q.v.) when it sees this signal. This allows dnsmasq to be restarted
18and avoids startup races with the provider of nameserver information.
19
20
21Dnsmasq provides one service on the DBus: uk.org.thekelleys.dnsmasq
Simon Kelleyad094272012-08-10 17:10:54 +010022and a single object: /uk/org/thekelleys/dnsmasq
23The name of the service may be changed by giving an argument to --enable-dbus.
Simon Kelley3d8df262005-08-29 12:19:27 +010024
Simon Kelley9009d742008-11-14 20:04:27 +0000251. METHODS
26----------
27
Simon Kelley3d8df262005-08-29 12:19:27 +010028Methods are of the form
29
30uk.org.thekelleys.<method>
31
32Available methods are:
33
34GetVersion
35----------
36Returns a string containing the version of dnsmasq running.
37
38ClearCache
39----------
40Returns nothing. Clears the domain name cache and re-reads
41/etc/hosts. The same as sending dnsmasq a HUP signal.
42
43SetServers
44----------
45Returns nothing. Takes a set of arguments representing the new
46upstream DNS servers to be used by dnsmasq. IPv4 addresses are
47represented as a UINT32 (in network byte order) and IPv6 addresses
48are represented as sixteen BYTEs (since there is no UINT128 type).
49Each server address may be followed by one or more STRINGS, which are
50the domains for which the preceding server should be used.
51
52Examples.
53
54UINT32: <address1>
55UNIT32: <address2>
56
57is equivalent to
58
59--server=<address1> --server=<address2>
60
61
62UINT32 <address1>
63UINT32 <address2>
64STRING "somedomain.com"
65
66is equivalent to
67
68--server=<address1> --server=/somedomain.com/<address2>
69
70UINT32 <address1>
71UINT32 <address2>
72STRING "somedomain.com"
73UINT32 <address3>
74STRING "anotherdomain.com"
75STRING "thirddomain.com"
76
77is equivalent to
78
79--server=<address1>
80--server=/somedomain.com/<address2>
81--server=/anotherdomain.com/thirddomain.com/<address3>
82
83Am IPv4 address of 0.0.0.0 is interpreted as "no address, local only",
84so
85
86UINT32: <0.0.0.0>
87STRING "local.domain"
88
89is equivalent to
90
91--local=/local.domain/
92
93
94Each call to SetServers completely replaces the set of servers
95specified by via the DBus, but it leaves any servers specified via the
96command line or /etc/dnsmasq.conf or /etc/resolv.conf alone.
97
Simon Kelleyfaafb3f2012-09-20 14:17:39 +010098SetServersEx
99------------
100
101This function is more flexible and the SetServers function, in that it can
102handle address scoping, port numbers, and is easier for clients to use.
103
104Returns nothing. Takes a set of arguments representing the new
105upstream DNS servers to be used by dnsmasq. All addresses (both IPv4 and IPv6)
106are represented as STRINGS. Each server address may be followed by one or more
107STRINGS, which are the domains for which the preceding server should be used.
108
109This function takes an array of STRING arrays, where each inner array represents
110a set of DNS servers and domains for which those servers may be used. Each
111string represents a list of upstream DNS servers first, and domains second.
112Mixing of domains and servers within a the string array is not allowed.
113
114Examples.
115
116[
117 ["1.2.3.4", "foobar.com"],
118 ["1003:1234:abcd::1%eth0", "eng.mycorp.com", "lab.mycorp.com"]
119]
120
121is equivalent to
122
123--server=/foobar.com/1.2.3.4 \
124 --server=/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0
125
126An IPv4 address of 0.0.0.0 is interpreted as "no address, local only",
127so
128
129[ ["0.0.0.0", "local.domain"] ]
130
131is equivalent to
132
133--local=/local.domain/
134
135
136Each call to SetServersEx completely replaces the set of servers
137specified by via the DBus, but it leaves any servers specified via the
138command line or /etc/dnsmasq.conf or /etc/resolv.conf alone.
139
Simon Kelley295a54e2012-12-01 21:02:15 +0000140
141SetDomainServers
142----------------
143
144Yes another variation for setting DNS servers, with the capability of
145SetServersEx, but without using arrays of arrays, which are not
146sendable with dbus-send. The arguments are an array of strings which
147are identical to the equivalent arguments --server, so the example
148for SetServersEx is represented as
149
150[
151 "/foobar.com/1.2.3.4"
152 "/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0"
153]
154
155
156
Simon Kelley9009d742008-11-14 20:04:27 +00001572. SIGNALS
158----------
Simon Kelley3d8df262005-08-29 12:19:27 +0100159
Simon Kelley9009d742008-11-14 20:04:27 +0000160If dnsmasq's DHCP server is active, it will send signals over DBUS whenever
161the DHCP lease database changes. Think of these signals as transactions on
162a database with the IP address acting as the primary key.
163
164Signals are of the form:
165
166uk.org.thekelleys.<signal>
167
168and their parameters are:
169
170STRING "192.168.1.115"
171STRING "01:23:45:67:89:ab"
172STRING "hostname.or.fqdn"
173
174
175Available signals are:
176
177DhcpLeaseAdded
178---------------
179
180This signal is emitted when a DHCP lease for a given IP address is created.
181
182DhcpLeaseDeleted
183----------------
184
185This signal is emitted when a DHCP lease for a given IP address is deleted.
186
187DhcpLeaseUpdated
188----------------
189
190This signal is emitted when a DHCP lease for a given IP address is updated.
191