mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28866e9567 | ||
|
|
c52e189734 | ||
|
|
8ef5ada238 | ||
|
|
316e2730ac |
No files matched your search
@@ -1,3 +1,412 @@
|
|||||||
|
version 2.56
|
||||||
|
Add a patch to allow dnsmasq to get interface names right in a
|
||||||
|
Solaris zone. Thanks to Dj Padzensky for this.
|
||||||
|
|
||||||
|
Improve data-type parsing heuristics so that
|
||||||
|
--dhcp-option=option:domain-search,.
|
||||||
|
treats the value as a string and not an IP address.
|
||||||
|
Thanks to Clemens Fischer for spotting that.
|
||||||
|
|
||||||
|
Add IPv6 support to the TFTP server. Many thanks to Jan
|
||||||
|
'RedBully' Seiffert for the patches.
|
||||||
|
|
||||||
|
Log DNS queries at level LOG_INFO, rather then
|
||||||
|
LOG_DEBUG. This makes things consistent with DHCP
|
||||||
|
logging. Thanks to Adam Pribyl for spotting the problem.
|
||||||
|
|
||||||
|
Ensure that dnsmasq terminates cleanly when using
|
||||||
|
--syslog-async even if it cannot make a connection to the
|
||||||
|
syslogd.
|
||||||
|
|
||||||
|
Add --add-mac option. This is to support currently
|
||||||
|
experimental DNS filtering facilities. Thanks to Benjamin
|
||||||
|
Petrin for the orignal patch.
|
||||||
|
|
||||||
|
Fix bug which meant that tags were ignored in dhcp-range
|
||||||
|
configuration specifying PXE-proxy service. Thanks to
|
||||||
|
Cristiano Cumer for spotting this.
|
||||||
|
|
||||||
|
Raise an error if there is extra junk, not part of an
|
||||||
|
option, on the command line.
|
||||||
|
|
||||||
|
Flag a couple of log messages in cache.c as coming from
|
||||||
|
the DHCP subsystem. Thanks to Olaf Westrik for the patch.
|
||||||
|
|
||||||
|
Omit timestamps from logs when a) logging to stderr and
|
||||||
|
b) --keep-in-forground is set. The logging facility on the
|
||||||
|
other end of stderr can be assumned to supply them. Thanks
|
||||||
|
to John Hallam for the patch.
|
||||||
|
|
||||||
|
Don't complain about strings longer than 255 characters in
|
||||||
|
--txt-record, just split the long strings into 255
|
||||||
|
character chunks instead.
|
||||||
|
|
||||||
|
Fix crash on double-free. This bug can only happen when
|
||||||
|
dhcp-script is in use and then only in rare circumstances
|
||||||
|
triggered by high DHCP transaction rate and a slow
|
||||||
|
script. Thanks to Ferenc Wagner for finding the problem.
|
||||||
|
|
||||||
|
Only log that a file has been sent by TFTP after the
|
||||||
|
transfer has completed succesfully.
|
||||||
|
|
||||||
|
A good suggestion from Ferenc Wagner: extend
|
||||||
|
the --domain option to allow this sort of thing:
|
||||||
|
--domain=thekelleys.org.uk,192.168.0.0/24,local
|
||||||
|
which automatically creates
|
||||||
|
--local=/thekelleys.org.uk/
|
||||||
|
--local=/0.168.192.in-addr.arpa/
|
||||||
|
|
||||||
|
Tighten up syntax checking of hex contants in the config
|
||||||
|
file. Thanks to Fred Damen for spotting this.
|
||||||
|
|
||||||
|
Add dnsmasq logo/icon, contributed by Justin Swift. Many
|
||||||
|
thanks for that.
|
||||||
|
|
||||||
|
Never cache DNS replies which have the 'cd' bit set, or
|
||||||
|
which result from queries forwarded with the 'cd' bit
|
||||||
|
set. The 'cd' bit instructs a DNSSEC validating server
|
||||||
|
upstream to ignore signature failures and return replies
|
||||||
|
anyway. Without this change it's possible to pollute the
|
||||||
|
dnsmasq cache with bad data by making a query with the
|
||||||
|
'cd' bit set and subsequent queries would return this data
|
||||||
|
without its being marked as suspect. Thanks to Anders
|
||||||
|
Kaseorg for pointing out this problem.
|
||||||
|
|
||||||
|
Add --proxy-dnssec flag, for compliance with RFC
|
||||||
|
4035. Dnsmasq will now clear the 'ad' bit in answers returned
|
||||||
|
from upstream validating nameservers unless this option is
|
||||||
|
set.
|
||||||
|
|
||||||
|
Allow a filename of "-" for --conf-file to read
|
||||||
|
stdin. Suggestion from Timothy Redaelli.
|
||||||
|
|
||||||
|
Rotate the order of SRV records in replies, to provide
|
||||||
|
round-robin load balancing when all the priorities are
|
||||||
|
equal. Thanks to Peter McKinney for the suggestion.
|
||||||
|
|
||||||
|
Edit
|
||||||
|
contrib/MacOSX-launchd/uk.org.thekelleys.dnsmasq.plist
|
||||||
|
so that it doesn't log all queries to a file by
|
||||||
|
default. Thanks again to Peter McKinney.
|
||||||
|
|
||||||
|
By default, setting an IPv4 address for a domain but not
|
||||||
|
an IPv6 address causes dnsmasq to return
|
||||||
|
an NODATA reply for IPv6 (or vice-versa). So
|
||||||
|
--address=/google.com/1.2.3.4 stops IPv6 queries for
|
||||||
|
*google.com from being forwarded. Make it possible to
|
||||||
|
override this behaviour by defining the sematics if the
|
||||||
|
same domain appears in both --server and --address.
|
||||||
|
In that case, the --address has priority for the address
|
||||||
|
family in which is appears, but the --server has priority
|
||||||
|
of the address family which doesn't appear in --adddress
|
||||||
|
So:
|
||||||
|
--address=/google.com/1.2.3.4
|
||||||
|
--server=/google.com/#
|
||||||
|
will return 1.2.3.4 for IPv4 queries for *.google.com but
|
||||||
|
forward IPv6 queries to the normal upstream nameserver.
|
||||||
|
Similarly when setting an IPv6 address
|
||||||
|
only this will allow forwarding of IPv4 queries. Thanks to
|
||||||
|
William for pointing out the need for this.
|
||||||
|
|
||||||
|
Allow more than one --dhcp-optsfile and --dhcp-hostsfile
|
||||||
|
and make them understand directories as arguments in the
|
||||||
|
same way as --addn-hosts. Suggestion from John Hanks.
|
||||||
|
|
||||||
|
Ignore rebinding requests for leases we don't know
|
||||||
|
about. Rebind is broadcast, so we might get to overhear a
|
||||||
|
request meant for another DHCP server. NAKing this is
|
||||||
|
wrong. Thanks to Brad D'Hondt for assistance with this.
|
||||||
|
|
||||||
|
Fix cosmetic bug which produced strange output when
|
||||||
|
dumping cache statistics with some configurations. Thanks
|
||||||
|
to Fedor Kozhevnikov for spotting this.
|
||||||
|
|
||||||
|
|
||||||
|
version 2.55
|
||||||
|
Fix crash when /etc/ethers is in use. Thanks to
|
||||||
|
Gianluigi Tiesi for finding this.
|
||||||
|
|
||||||
|
Fix crash in netlink_multicast(). Thanks to Arno Wald for
|
||||||
|
finding this one.
|
||||||
|
|
||||||
|
Allow the empty domain "." in dhcp domain-search (119)
|
||||||
|
options.
|
||||||
|
|
||||||
|
|
||||||
|
version 2.54
|
||||||
|
There is no version 2.54 to avoid confusion with 2.53,
|
||||||
|
which incorrectly identifies itself as 2.54.
|
||||||
|
|
||||||
|
|
||||||
|
version 2.53
|
||||||
|
Fix failure to compile on Debian/kFreeBSD. Thanks to
|
||||||
|
Axel Beckert and Petr Salinger.
|
||||||
|
|
||||||
|
Fix code to avoid scary strict-aliasing warnings
|
||||||
|
generated by gcc 4.4.
|
||||||
|
|
||||||
|
Added FAQ entry warning about DHCP failures with Vista
|
||||||
|
when firewalls block 255.255.255.255.
|
||||||
|
|
||||||
|
Fixed bug which caused bad things to happen if a
|
||||||
|
resolv.conf file which exists is subsequently removed.
|
||||||
|
Thanks to Nikolai Saoukh for the patch.
|
||||||
|
|
||||||
|
Rationalised the DHCP tag system. Every configuration item
|
||||||
|
which can set a tag does so by adding "set:<tag>" and
|
||||||
|
every configuration item which is conditional on a tag is
|
||||||
|
made so by "tag:<tag>". The NOT operator changes to '!',
|
||||||
|
which is a bit more intuitive too. Dhcp-host directives
|
||||||
|
can set more than one tag now. The old '#' NOT,
|
||||||
|
"net:" prefix and no-prefixes are still honoured, so
|
||||||
|
no existing config file needs to be changed, but
|
||||||
|
the documentation and new-style config files should be
|
||||||
|
much less confusing.
|
||||||
|
|
||||||
|
Added --tag-if to allow boolean operations on tags.
|
||||||
|
This allows complicated logic to be clearer and more
|
||||||
|
general. A great suggestion from Richard Voigt.
|
||||||
|
|
||||||
|
Add broadcast/unicast information to DHCP logging.
|
||||||
|
|
||||||
|
Allow --dhcp-broadcast to be unconditional.
|
||||||
|
|
||||||
|
Fixed incorrect behaviour with NOT <tag> conditionals in
|
||||||
|
dhcp-options. Thanks to Max Turkewitz for assistance
|
||||||
|
finding this.
|
||||||
|
|
||||||
|
If we send vendor-class encapsulated options based on the
|
||||||
|
vendor-class supplied by the client, and no explicit
|
||||||
|
vendor-class option is given, echo back the vendor-class
|
||||||
|
from the client.
|
||||||
|
|
||||||
|
Fix bug which stopped dnsmasq from matching both a
|
||||||
|
circuitid and a remoteid. Thanks to Ignacio Bravo for
|
||||||
|
finding this.
|
||||||
|
|
||||||
|
Add --dhcp-proxy, which makes it possible to configure
|
||||||
|
dnsmasq to use a DHCP relay agent as a full proxy, with
|
||||||
|
all DHCP messages passing through the proxy. This is
|
||||||
|
useful if the relay adds extra information to the packets
|
||||||
|
it forwards, but cannot be configured with the RFC 5107
|
||||||
|
server-override option.
|
||||||
|
|
||||||
|
Added interface:<iface name> part to dhcp-range. The
|
||||||
|
semantics of this are very odd at first sight, but it
|
||||||
|
allows a single line of the form
|
||||||
|
dhcp-range=interface:virt0,192.168.0.4,192.168.0.200
|
||||||
|
to be added to dnsmasq configuration which then supplies
|
||||||
|
DHCP and DNS services to that interface, without affecting
|
||||||
|
what services are supplied to other interfaces and
|
||||||
|
irrespective of the existance or lack of
|
||||||
|
interface=<interface>
|
||||||
|
lines elsewhere in the dnsmasq configuration. The idea is
|
||||||
|
that such a line can be added automatically by libvirt
|
||||||
|
or equivalent systems, without disturbing any manual
|
||||||
|
configuration.
|
||||||
|
|
||||||
|
Similarly to the above, allow --enable-tftp=<interface>
|
||||||
|
|
||||||
|
Allow a TFTP root to be set separately for requests via
|
||||||
|
different interfaces, --tftp-root=<path>,<interface>
|
||||||
|
|
||||||
|
Correctly handle and log clashes between CNAMES and
|
||||||
|
DNS names being given to DHCP leases. This fixes a bug
|
||||||
|
which caused nonsense IP addresses to be logged. Thanks to
|
||||||
|
Sergei Zhirikov for finding and analysing the problem.
|
||||||
|
|
||||||
|
Tweak flush_log so as to avoid leaving the log
|
||||||
|
file in non-blocking mode. O_NONBLOCK is a property of the
|
||||||
|
file, not the process/descriptor.
|
||||||
|
|
||||||
|
Fix contrib/Solaris10/create_package
|
||||||
|
(/usr/man -> /usr/share/man) Thanks to Vita Batrla.
|
||||||
|
|
||||||
|
Fix a problem where, if a client got a lease, then went
|
||||||
|
to another subnet and got another lease, then moved back,
|
||||||
|
it couldn't resume the old lease, but would instead get
|
||||||
|
a new address. Thanks to Leonardo Rodrigues for spotting
|
||||||
|
this and testing the fix.
|
||||||
|
|
||||||
|
Fix weird bug which sometimes omitted certain characters
|
||||||
|
from the start of quoted strings in dhcp-options. Thanks
|
||||||
|
to Dayton Turner for spotting the problem.
|
||||||
|
|
||||||
|
Add facility to redirect some domains to the standard
|
||||||
|
upstream servers: this allows something like
|
||||||
|
--server=/google.com/1.2.3.4 --server=/www.google.com/#
|
||||||
|
which will send queries for *.google.com to 1.2.3.4,
|
||||||
|
except *www.google.com which will be forwarded as usual.
|
||||||
|
Thanks to AJ Weber for prompting this addition.
|
||||||
|
|
||||||
|
Improve the hash-algorithm used to generate IP addresses
|
||||||
|
from MAC addresses during initial DHCP address
|
||||||
|
allocation. This improves performance when large numbers
|
||||||
|
of hosts with similar MAC addresses all try and get an IP
|
||||||
|
address at the same time. Thanks to Paul Smith for his
|
||||||
|
work on this.
|
||||||
|
|
||||||
|
Tweak DHCP code so that --bridge-interface can be used to
|
||||||
|
select which IP alias of an interface should be used for
|
||||||
|
DHCP purposes on Linux. If eth0 has an alias eth0:dhcp
|
||||||
|
then adding --bridge-interface=eth0:dhcp,eth0 will use
|
||||||
|
the address of eth0:dhcp to determine the correct subnet
|
||||||
|
for DHCP address allocation. Thanks to Pawel Golaszewski
|
||||||
|
for prompting this and Eric Cooper for further testing.
|
||||||
|
|
||||||
|
Add --dhcp-generate-names. Suggestion by Ferenc Wagner.
|
||||||
|
|
||||||
|
Tweak DNS server selection algorithm when there is more
|
||||||
|
than one server available for a domain, eg.
|
||||||
|
--server=/mydomain/1.1.1.1
|
||||||
|
--server=/mydomain/2.2.2.2
|
||||||
|
Thanks to Alberto Cuesta-Canada for spotting a weakness
|
||||||
|
here.
|
||||||
|
|
||||||
|
Add --max-ttl. Thanks to Fredrik Ringertz for the patch.
|
||||||
|
|
||||||
|
Allow --log-facility=- to force all logging to
|
||||||
|
stderr. Suggestion from Clemens Fischer.
|
||||||
|
|
||||||
|
Fix regression which caused configuration like
|
||||||
|
--address=/.domain.com/1.2.3.4 to be rejected. The dot to the
|
||||||
|
left of the domain has been implied and not required for a
|
||||||
|
long time, but it should be accepted for backward
|
||||||
|
compatibility. Thanks to Andrew Burcin for spotting this.
|
||||||
|
|
||||||
|
Add --rebind-domain-ok and --rebind-localhost-ok.
|
||||||
|
Suggestion from Clemens Fischer.
|
||||||
|
|
||||||
|
Log replies to queries of type TXT, when --log-queries
|
||||||
|
is set.
|
||||||
|
|
||||||
|
Fix compiler warnings when compiled with -DNO_DHCP. Thanks
|
||||||
|
to Shantanu Gadgil for the patch.
|
||||||
|
|
||||||
|
Updated French translation. Thanks to Gildas Le Nadan.
|
||||||
|
|
||||||
|
Updated Polish translation. Thanks to Jan Psota.
|
||||||
|
|
||||||
|
Updated German translation. Thanks to Matthias Andree.
|
||||||
|
|
||||||
|
Added contrib/static-arp, thanks to Darren Hoo.
|
||||||
|
|
||||||
|
Fix corruption of the domain when a name from /etc/hosts
|
||||||
|
overrides one supplied by a DHCP client. Thanks to Fedor
|
||||||
|
Kozhevnikov for spotting the problem.
|
||||||
|
|
||||||
|
Updated Spanish translation. Thanks to Chris Chatham.
|
||||||
|
|
||||||
|
|
||||||
|
version 2.52
|
||||||
|
Work around a Linux kernel bug which insists that the
|
||||||
|
length of the option passed to setsockopt must be at least
|
||||||
|
sizeof(int) bytes, even if we're calling SO_BINDTODEVICE
|
||||||
|
and the device name is "lo". Note that this is fixed
|
||||||
|
in kernel 2.6.31, but the workaround is harmless and
|
||||||
|
allows earlier kernels to be used. Also fix dnsmasq
|
||||||
|
bug which reported the wrong address when this failed.
|
||||||
|
Thanks to Fedor for finding this.
|
||||||
|
|
||||||
|
The API for IPv6 PKTINFO changed around Linux kernel
|
||||||
|
2.6.14. Workaround the case where dnsmasq is compiled
|
||||||
|
against newer headers, but then run on an old kernel:
|
||||||
|
necessary for some *WRT distros.
|
||||||
|
|
||||||
|
Re-read the set of network interfaces when re-loading
|
||||||
|
/etc/resolv.conf if --bind-interfaces is not set. This
|
||||||
|
handles the case that loopback interfaces do not exist
|
||||||
|
when dnsmasq is first started.
|
||||||
|
|
||||||
|
Tweak the PXE code to support port 4011. This should
|
||||||
|
reduce broadcasts and make things more reliable when other
|
||||||
|
servers are around. It also improves inter-operability
|
||||||
|
with certain clients.
|
||||||
|
|
||||||
|
Make a pxe-service configuration with no filename or boot
|
||||||
|
service type legal: this does a local boot. eg.
|
||||||
|
pxe-service=x86PC, "Local boot"
|
||||||
|
|
||||||
|
Be more conservative in detecting "A for A"
|
||||||
|
queries. Dnsmasq checks if the name in a type=A query looks
|
||||||
|
like a dotted-quad IP address and answers the query itself
|
||||||
|
if so, rather than forwarding it. Previously dnsmasq
|
||||||
|
relied in the library function inet_addr() to convert
|
||||||
|
addresses, and that will accept some things which are
|
||||||
|
confusing in this context, like 1.2.3 or even just
|
||||||
|
1234. Now we only do A for A processing for four decimal
|
||||||
|
numbers delimited by dots.
|
||||||
|
|
||||||
|
A couple of tweaks to fix compilation on Solaris. Thanks
|
||||||
|
to Joel Macklow for help with this.
|
||||||
|
|
||||||
|
Another Solaris compilation tweak, needed for Solaris
|
||||||
|
2009.06. Thanks to Lee Essen for that.
|
||||||
|
|
||||||
|
Added extract packaging stuff from Lee Essen to
|
||||||
|
contrib/Solaris10.
|
||||||
|
|
||||||
|
Increased the default limit on number of leases to 1000
|
||||||
|
(from 150). This is mainly a defence against DoS attacks,
|
||||||
|
and for the average "one for two class C networks"
|
||||||
|
installation, IP address exhaustion does that just as
|
||||||
|
well. Making the limit greater than the number of IP
|
||||||
|
addresses available in such an installation removes a
|
||||||
|
surprise which otherwise can catch people out.
|
||||||
|
|
||||||
|
Removed extraneous trailing space in the value of the
|
||||||
|
DNSMASQ_TIME_REMAINING DNSMASQ_LEASE_LENGTH and
|
||||||
|
DNSMASQ_LEASE_EXPIRES environment variables. Thanks to
|
||||||
|
Gildas Le Nadan for spotting this.
|
||||||
|
|
||||||
|
Provide the network-id tags for a DHCP transaction to
|
||||||
|
the lease-change script in the environment variable
|
||||||
|
DNSMASQ_TAGS. A good suggestion from Gildas Le Nadan.
|
||||||
|
|
||||||
|
Add support for RFC3925 "Vendor-Identifying Vendor
|
||||||
|
Options". The syntax looks like this:
|
||||||
|
--dhcp-option=vi-encap:<enterprise number>, .........
|
||||||
|
|
||||||
|
Add support to --dhcp-match to allow matching against
|
||||||
|
RFC3925 "Vendor-Identifying Vendor Classes". The syntax
|
||||||
|
looks like this:
|
||||||
|
--dhcp-match=tag,vi-encap<enterprise number>, <value>
|
||||||
|
|
||||||
|
Add some application specific code to assist in
|
||||||
|
implementing the Broadband forum TR069 CPE-WAN
|
||||||
|
specification. The details are in contrib/CPE-WAN/README
|
||||||
|
|
||||||
|
Increase the default DNS packet size limit to 4096, as
|
||||||
|
recommended by RFC5625 section 4.4.3. This can be
|
||||||
|
reconfigured using --edns-packet-max if needed. Thanks to
|
||||||
|
Francis Dupont for pointing this out.
|
||||||
|
|
||||||
|
Rewrite query-ids even for TSIG signed packets, since
|
||||||
|
this is allowed by RFC5625 section 4.5.
|
||||||
|
|
||||||
|
Use getopt_long by default on OS X. It has been supported
|
||||||
|
since version 10.3.0. Thanks to Arek Dreyer for spotting
|
||||||
|
this.
|
||||||
|
|
||||||
|
Added up-to-date startup configuration for MacOSX/launchd
|
||||||
|
in contrib/MacOSX-launchd. Thanks to Arek Dreyer for
|
||||||
|
providing this.
|
||||||
|
|
||||||
|
Fix link error when including Dbus but excluding DHCP.
|
||||||
|
Thanks to Oschtan for the bug report.
|
||||||
|
|
||||||
|
Updated French translation. Thanks to Gildas Le Nadan.
|
||||||
|
|
||||||
|
Updated Polish translation. Thanks to Jan Psota.
|
||||||
|
|
||||||
|
Updated Spanish translation. Thanks to Chris Chatham.
|
||||||
|
|
||||||
|
Fixed confusion about domains, when looking up DHCP hosts
|
||||||
|
in /etc/hosts. This could cause spurious "Ignoring
|
||||||
|
domain..." messages. Thanks to Fedor Kozhevnikov for
|
||||||
|
finding and analysing the problem.
|
||||||
|
|
||||||
|
|
||||||
version 2.51
|
version 2.51
|
||||||
Add support for internationalised DNS. Non-ASCII characters
|
Add support for internationalised DNS. Non-ASCII characters
|
||||||
in domain names found in /etc/hosts, /etc/ethers and
|
in domain names found in /etc/hosts, /etc/ethers and
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ A: Yes, from version-2.21. The support is only available running under
|
|||||||
If a physical interface has more than one IP address or aliases
|
If a physical interface has more than one IP address or aliases
|
||||||
with extra IP addresses, then any dhcp-ranges corresponding to
|
with extra IP addresses, then any dhcp-ranges corresponding to
|
||||||
these addresses can be used for address allocation. So if an
|
these addresses can be used for address allocation. So if an
|
||||||
interface has addresses 192.168.1.0/24 and 192.68.2.0/24 and there
|
interface has addresses 192.168.1.0/24 and 192.168.2.0/24 and there
|
||||||
are DHCP ranges 192.168.1.100-192.168.1.200 and
|
are DHCP ranges 192.168.1.100-192.168.1.200 and
|
||||||
192.168.2.100-192.168.2.200 then both ranges would be used for host
|
192.168.2.100-192.168.2.200 then both ranges would be used for host
|
||||||
connected to the physical interface. A more typical use might be to
|
connected to the physical interface. A more typical use might be to
|
||||||
@@ -413,10 +413,11 @@ A: Change your kernel configuration: either deselect CONFIG_SECURITY
|
|||||||
_or_ select CONFIG_SECURITY_CAPABILITIES. Alternatively, you can
|
_or_ select CONFIG_SECURITY_CAPABILITIES. Alternatively, you can
|
||||||
remove the need to set capabilities by running dnsmasq as root.
|
remove the need to set capabilities by running dnsmasq as root.
|
||||||
|
|
||||||
Q: Where can I get .rpms Suitable for Suse?
|
|
||||||
|
|
||||||
A: Dnsmasq is in Suse itself, and the latest releases are also
|
Q: Where can I get .rpms Suitable for openSUSE/SLES?
|
||||||
available at ftp://ftp.suse.com/pub/people/ug/
|
|
||||||
|
A: Dnsmasq is in openSUSE itself, and the latest releases are also
|
||||||
|
available at http://download.opensuse.org/repositories/network/
|
||||||
|
|
||||||
|
|
||||||
Q: Can I run dnsmasq in a Linux vserver?
|
Q: Can I run dnsmasq in a Linux vserver?
|
||||||
@@ -456,6 +457,16 @@ A: In almost all cases: none. If you have the normal arrangement with
|
|||||||
and turn on syslog-ng's dns-cache function.
|
and turn on syslog-ng's dns-cache function.
|
||||||
|
|
||||||
|
|
||||||
|
Q: DHCP doesn't work with windows Vista, but everything else is fine.
|
||||||
|
|
||||||
|
A: The DHCP client on windows Vista (and possibly later versions)
|
||||||
|
demands that the DHCP server send replies as broadcasts. Most other
|
||||||
|
clients don't do this. The broadcasts are send to
|
||||||
|
255.255.255.255. A badly configured firewall which blocks such
|
||||||
|
packets will show exactly these symptoms (Vista fails, others
|
||||||
|
work).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
# dnsmasq is Copyright (c) 2000-2010 Simon Kelley
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,29 +18,33 @@ BINDIR = ${PREFIX}/sbin
|
|||||||
MANDIR = ${PREFIX}/share/man
|
MANDIR = ${PREFIX}/share/man
|
||||||
LOCALEDIR = ${PREFIX}/share/locale
|
LOCALEDIR = ${PREFIX}/share/locale
|
||||||
|
|
||||||
SRC = src
|
|
||||||
PO = po
|
|
||||||
MAN = man
|
|
||||||
|
|
||||||
PKG_CONFIG = pkg-config
|
PKG_CONFIG = pkg-config
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
MSGMERGE = msgmerge
|
MSGMERGE = msgmerge
|
||||||
MSGFMT = msgfmt
|
MSGFMT = msgfmt
|
||||||
XGETTEXT = xgettext
|
XGETTEXT = xgettext
|
||||||
|
|
||||||
|
CFLAGS = -Wall -W -O2
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
|
|
||||||
|
SRC = src
|
||||||
|
PO = po
|
||||||
|
MAN = man
|
||||||
|
|
||||||
DNSMASQ_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
|
DNSMASQ_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
|
||||||
DNSMASQ_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
|
DNSMASQ_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
|
||||||
SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi`
|
SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi`
|
||||||
|
|
||||||
all : dnsmasq
|
OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \
|
||||||
|
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
|
||||||
|
helper.o tftp.o log.o
|
||||||
|
|
||||||
dnsmasq :
|
all :
|
||||||
@cd $(SRC) && $(MAKE) \
|
@cd $(SRC) && $(MAKE) \
|
||||||
DNSMASQ_CFLAGS="$(DNSMASQ_CFLAGS)" \
|
BUILD_CFLAGS="$(DNSMASQ_CFLAGS)" \
|
||||||
DNSMASQ_LIBS="$(DNSMASQ_LIBS) $(SUNOS_LIBS)" \
|
BUILD_LIBS="$(DNSMASQ_LIBS) $(SUNOS_LIBS)" \
|
||||||
-f ../bld/Makefile dnsmasq
|
-f ../Makefile dnsmasq
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -f *~ $(SRC)/*.mo contrib/*/*~ */*~ $(SRC)/*.pot
|
rm -f *~ $(SRC)/*.mo contrib/*/*~ */*~ $(SRC)/*.pot
|
||||||
@@ -56,13 +60,12 @@ install-common :
|
|||||||
all-i18n :
|
all-i18n :
|
||||||
@cd $(SRC) && $(MAKE) \
|
@cd $(SRC) && $(MAKE) \
|
||||||
I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' \
|
I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' \
|
||||||
DNSMASQ_CFLAGS="$(DNSMASQ_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \
|
BUILD_CFLAGS="$(DNSMASQ_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \
|
||||||
DNSMASQ_LIBS="$(DNSMASQ_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \
|
BUILD_LIBS="$(DNSMASQ_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \
|
||||||
-f ../bld/Makefile dnsmasq
|
-f ../Makefile dnsmasq
|
||||||
@cd $(PO); for f in *.po; do \
|
@cd $(PO); for f in *.po; do \
|
||||||
cd ../$(SRC) && $(MAKE) \
|
cd ../$(SRC) && $(MAKE) \
|
||||||
MSGMERGE=$(MSGMERGE) MSGFMT=$(MSGFMT) XGETTEXT=$(XGETTEXT) \
|
-f ../Makefile $${f%.po}.mo; \
|
||||||
-f ../bld/Makefile $${f%.po}.mo; \
|
|
||||||
done
|
done
|
||||||
|
|
||||||
install-i18n : all-i18n install-common
|
install-i18n : all-i18n install-common
|
||||||
@@ -70,9 +73,25 @@ install-i18n : all-i18n install-common
|
|||||||
cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL)
|
cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL)
|
||||||
|
|
||||||
merge :
|
merge :
|
||||||
@cd $(SRC) && $(MAKE) XGETTEXT=$(XGETTEXT) -f ../bld/Makefile dnsmasq.pot
|
@cd $(SRC) && $(MAKE) -f ../Makefile dnsmasq.pot
|
||||||
@cd $(PO); for f in *.po; do \
|
@cd $(PO); for f in *.po; do \
|
||||||
echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(SRC)/dnsmasq.pot; \
|
echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(SRC)/dnsmasq.pot; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# rules below are targets in recusive makes with cwd=$(SRC)
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $<
|
||||||
|
|
||||||
|
dnsmasq : $(OBJS)
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS)
|
||||||
|
|
||||||
|
dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h
|
||||||
|
$(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c)
|
||||||
|
|
||||||
|
%.mo : ../po/%.po dnsmasq.pot
|
||||||
|
$(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo -
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY : all clean install install-common all-i18n install-i18n merge
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
CFLAGS = -Wall -W -O2
|
|
||||||
|
|
||||||
OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \
|
|
||||||
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
|
|
||||||
helper.o tftp.o log.o
|
|
||||||
|
|
||||||
.c.o:
|
|
||||||
$(CC) $(CFLAGS) $(COPTS) $(I18N) $(DNSMASQ_CFLAGS) $(RPM_OPT_FLAGS) -c $<
|
|
||||||
|
|
||||||
dnsmasq : $(OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(DNSMASQ_LIBS) $(LIBS)
|
|
||||||
|
|
||||||
dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h
|
|
||||||
$(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c)
|
|
||||||
|
|
||||||
%.mo : ../po/%.po dnsmasq.pot
|
|
||||||
$(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo -
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
Dnsmasq from version 2.52 has a couple of rather application-specific
|
||||||
|
features designed to allow for implementation of the DHCP part of CPE
|
||||||
|
WAN management protocol.
|
||||||
|
|
||||||
|
http://www.broadband-forum.org/technical/download/TR-069_Amendment-2.pdf
|
||||||
|
http://en.wikipedia.org/wiki/TR-069
|
||||||
|
|
||||||
|
The relevant sections are F.2.1 "Gateway Requirements" and F.2.5 "DHCP
|
||||||
|
Vendor Options".
|
||||||
|
|
||||||
|
First, dnsmasq checks for DHCP requests which contain an option-125
|
||||||
|
vendor-class option which in turn holds a vendor section for IANA
|
||||||
|
enterprise number 3561 which contains sub-options codes 1 and 2. If
|
||||||
|
this is present then the network-tag "cpewan-id" is set.
|
||||||
|
This allows dnsmasq to be configured to reply with the correct
|
||||||
|
GatewayManufacturerOUI, GatewaySerialNumber and GatewayProductClass like this:
|
||||||
|
|
||||||
|
dhcp-option=cpewan-id,vi-encap:3561,4,"<GatewayManufacturerOUI>"
|
||||||
|
dhcp-option=cpewan-id,vi-encap:3561,5,"<SerialNumber>"
|
||||||
|
dhcp-option=cpewan-id,vi-encap:3561,6,"<ProductClass>"
|
||||||
|
|
||||||
|
Second, the received sub-options 1, 2, and 3 are passed to the DHCP
|
||||||
|
lease-change script as the environment variables DNSMASQ_CPEWAN_OUI,
|
||||||
|
DNSMASQ_CPEWAN_SERIAL, and DNSMASQ_CPEWAN_CLASS respectively. This allows
|
||||||
|
the script to be used to maintain a ManageableDevice table as
|
||||||
|
specified in F.2.1. Note that this data is not retained in dnsmasq's
|
||||||
|
internal DHCP lease database, so it is not available on every call to
|
||||||
|
the script (this is the same as some other data such as vendor and
|
||||||
|
user classes). It will however be available for at least the "add"
|
||||||
|
call, and should be stored then against the IP address as primary
|
||||||
|
key for future use.
|
||||||
|
|
||||||
|
|
||||||
|
This feature was added to dnsmasq under sponsorship from Ericsson.
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
This is a launchd item for Mac OS X and Mac OS X Server.
|
||||||
|
For more information about launchd, the
|
||||||
|
"System wide and per-user daemon/agent manager", see the launchd
|
||||||
|
man page, or the wikipedia page: http://en.wikipedia.org/wiki/Launchd
|
||||||
|
|
||||||
|
This launchd item uses the following flags:
|
||||||
|
--keep-in-foreground - this is crucial for use with launchd
|
||||||
|
--log-queries - this is optional and you can remove it
|
||||||
|
--log-facility=/var/log/dnsmasq.log - again optional instead of system.log
|
||||||
|
|
||||||
|
To use this launchd item for dnsmasq:
|
||||||
|
|
||||||
|
If you don't already have a folder /Library/LaunchDaemons, then create one:
|
||||||
|
sudo mkdir /Library/LaunchDaemons
|
||||||
|
sudo chown root:admin /Library/LaunchDaemons
|
||||||
|
sudo chmod 775 /Library/LaunchDaemons
|
||||||
|
|
||||||
|
Copy uk.org.thekelleys.dnsmasq.plist there and then set ownership/permissions:
|
||||||
|
sudo cp uk.org.thekelleys.dnsmasq.plist /Library/LaunchDaemons/
|
||||||
|
sudo chown root:admin /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
|
||||||
|
sudo chmod 644 /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
|
||||||
|
|
||||||
|
Optionally, edit your dnsmasq configuration file to your liking.
|
||||||
|
|
||||||
|
To start the launchd job, which starts dnsmaq, reboot or use the command:
|
||||||
|
sudo launchctl load /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
|
||||||
|
|
||||||
|
To stop the launchd job, which stops dnsmasq, use the command:
|
||||||
|
sudo launchctl unload /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
|
||||||
|
|
||||||
|
If you want to permanently stop the launchd job, so it doesn't start the job even after a reboot, use the following command:
|
||||||
|
sudo launchctl unload -w /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
|
||||||
|
|
||||||
|
If you make a change to the configuration file, you should relaunch dnsmasq;
|
||||||
|
to do this unload and then load again:
|
||||||
|
|
||||||
|
sudo launchctl unload /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
|
||||||
|
sudo launchctl load /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>uk.org.thekelleys.dnsmasq</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>/usr/local/sbin/dnsmasq</string>
|
||||||
|
<string>--keep-in-foreground</string>
|
||||||
|
</array>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Hi Simon,
|
||||||
|
|
||||||
|
I just wanted to let you know that I have built a Solaris .pkg install package of your dnsmasq utility for people to use. Feel free to point them in my direction if you have people who want this sort of thing.
|
||||||
|
|
||||||
|
http://ejesconsulting.wordpress.com/2010/05/12/gnu-dnsmasq-for-opensolaris-sparc/
|
||||||
|
|
||||||
|
Thanks
|
||||||
|
-evan
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
Ok, script attached ... seems to be working ok for me,
|
||||||
|
tried to install and remove a few times. It does the
|
||||||
|
right thing with the smf when installing, you can then
|
||||||
|
simply enable the service. Upon removal it cleans up the
|
||||||
|
files but won't clean up the services (I think until
|
||||||
|
a reboot) ... I've only started looking at the new
|
||||||
|
packages stuff in the last day or two, so I could be
|
||||||
|
missing something, but I can't find any way to force
|
||||||
|
a proper cleanup.
|
||||||
|
|
||||||
|
It requires that you have a writable repository setup
|
||||||
|
as per the docs on the opensolaris website and it will
|
||||||
|
create a dnsmasq package (package name is a variable
|
||||||
|
in the script). The script takes a version number for
|
||||||
|
the package and assumes that it's in the contrib/Solaris10
|
||||||
|
directory, it then works out the base tree directory
|
||||||
|
from $0.
|
||||||
|
|
||||||
|
i.e. $ contrib/Solaris10/create_package 2.52-1
|
||||||
|
or $ cd contrib/Solaris10; ./create_package 2.52-1
|
||||||
|
|
||||||
|
It's a bit more complex than it could be because I
|
||||||
|
prefer putting the daemon in /usr/sbin and the config
|
||||||
|
in /etc, so the script will actually create a new
|
||||||
|
version of the existing contrib dnsmasq.xml.
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# For our package, and for the SMF script, we need to define where we
|
||||||
|
# want things to go...
|
||||||
|
#
|
||||||
|
BIN_DIR="/usr/sbin"
|
||||||
|
CONF_DIR="/etc"
|
||||||
|
MAN_DIR="/usr/share/man/man8"
|
||||||
|
|
||||||
|
PACKAGE_NAME="dnsmasq"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Since we know we are in the contrib directory we can work out where
|
||||||
|
# the rest of the tree is...
|
||||||
|
#
|
||||||
|
BASEDIR="`dirname $0`/../.."
|
||||||
|
|
||||||
|
#
|
||||||
|
# We need a version number to use for the package creation...
|
||||||
|
#
|
||||||
|
if [ $# != 1 ]; then
|
||||||
|
echo "Usage: $0 <package_version_number>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
VERSION="$1"
|
||||||
|
|
||||||
|
#
|
||||||
|
# First thing we do is fix-up the smf file to use the paths we prefer...
|
||||||
|
#
|
||||||
|
if [ ! -f "${BASEDIR}/contrib/Solaris10/dnsmasq.xml" ]; then
|
||||||
|
echo "$0: unable to find contrib/Solaris10/dnsmasq.xml" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Fixing up smf file ... \c"
|
||||||
|
cat "${BASEDIR}/contrib/Solaris10/dnsmasq.xml" | \
|
||||||
|
sed -e "s%/usr/local/etc%${CONF_DIR}%" \
|
||||||
|
-e "s%/usr/local/sbin%${BIN_DIR}%" \
|
||||||
|
-e "s%/usr/local/man%${MAN_DIR}%" > ${BASEDIR}/contrib/Solaris10/dnsmasq-pkg.xml
|
||||||
|
echo "done."
|
||||||
|
|
||||||
|
echo "Creating packaging file ... \c"
|
||||||
|
cat <<EOF >${BASEDIR}/contrib/Solaris10/dnsmasq_package.inc
|
||||||
|
#
|
||||||
|
# header
|
||||||
|
#
|
||||||
|
set name=pkg.name value="dnsmasq"
|
||||||
|
set name=pkg.description value="dnsmasq daemon - dns, dhcp, tftp etc"
|
||||||
|
set name=pkg.detailed_url value="http://www.thekelleys.org.uk/dnsmasq/doc.html"
|
||||||
|
set name=info.maintainer value="TBD (tbd@tbd.com)"
|
||||||
|
set name=info.upstream value="dnsmasq-discuss@lists.thekelleys.org.uk"
|
||||||
|
set name=info.upstream_url value="http://www.thekelleys.org.uk/dnsmasq/doc.html"
|
||||||
|
#
|
||||||
|
# dependencies ... none?
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# directories
|
||||||
|
#
|
||||||
|
dir mode=0755 owner=root group=bin path=${BIN_DIR}/
|
||||||
|
dir mode=0755 owner=root group=sys path=${CONF_DIR}/
|
||||||
|
dir mode=0755 owner=root group=sys path=${MAN_DIR}/
|
||||||
|
dir mode=0755 owner=root group=sys path=/var/
|
||||||
|
dir mode=0755 owner=root group=sys path=/var/svc
|
||||||
|
dir mode=0755 owner=root group=sys path=/var/svc/manifest
|
||||||
|
dir mode=0755 owner=root group=sys path=/var/svc/manifest/network
|
||||||
|
|
||||||
|
#
|
||||||
|
# files
|
||||||
|
#
|
||||||
|
file ${BASEDIR}/src/dnsmasq mode=0555 owner=root group=bin path=${BIN_DIR}/dnsmasq
|
||||||
|
file ${BASEDIR}/man/dnsmasq.8 mode=0555 owner=root group=bin path=${MAN_DIR}/dnsmasq.8
|
||||||
|
file ${BASEDIR}/dnsmasq.conf.example mode=0644 owner=root group=sys path=${CONF_DIR}/dnsmasq.conf preserve=strawberry
|
||||||
|
file ${BASEDIR}/contrib/Solaris10/dnsmasq-pkg.xml mode=0644 owner=root group=sys path=/var/svc/manifest/network/dnsmasq.xml restart_fmri=svc:/system/manifest-import:default
|
||||||
|
|
||||||
|
EOF
|
||||||
|
echo "done."
|
||||||
|
|
||||||
|
echo "Creating package..."
|
||||||
|
eval `pkgsend open ${PACKAGE_NAME}@${VERSION}`
|
||||||
|
pkgsend include ${BASEDIR}/contrib/Solaris10/dnsmasq_package.inc
|
||||||
|
if [ "$?" = 0 ]; then
|
||||||
|
pkgsend close
|
||||||
|
else
|
||||||
|
echo "Errors"
|
||||||
|
fi
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Contributed by Darren Hoo <darren.hoo@gmail.com>
|
||||||
|
|
||||||
|
# If you use dnsmasq as DHCP server on a router, you may have
|
||||||
|
# met with attackers trying ARP Poison Routing (APR) on your
|
||||||
|
# local area network. This script will setup a 'permanent' entry
|
||||||
|
# in the router's ARP table upon each DHCP transaction so as to
|
||||||
|
# make the attacker's efforts less successful.
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# edit /etc/dnsmasq.conf and specify the path of this script
|
||||||
|
# to dhcp-script, for example:
|
||||||
|
# dhcp-script=/usr/sbin/static-arp
|
||||||
|
|
||||||
|
# if $1 is add or old, update the static arp table entry.
|
||||||
|
# if $1 is del, then delete the entry from the table
|
||||||
|
# if $1 is init which is called by dnsmasq at startup, it's ignored
|
||||||
|
|
||||||
|
ARP=/usr/sbin/arp
|
||||||
|
|
||||||
|
# Arguments.
|
||||||
|
# $1 is action (add, del, old)
|
||||||
|
# $2 is MAC
|
||||||
|
# $3 is address
|
||||||
|
# $4 is hostname (optional, may be unset)
|
||||||
|
|
||||||
|
if [ ${1} = del ] ; then
|
||||||
|
${ARP} -d $3
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${1} = old ] || [ ${1} = add ] ; then
|
||||||
|
${ARP} -s $3 $2
|
||||||
|
fi
|
||||||
|
|
||||||
+70
-58
@@ -7,8 +7,8 @@
|
|||||||
# The following two options make you a better netizen, since they
|
# The following two options make you a better netizen, since they
|
||||||
# tell dnsmasq to filter out queries which the public DNS cannot
|
# tell dnsmasq to filter out queries which the public DNS cannot
|
||||||
# answer, and which load the servers (especially the root servers)
|
# answer, and which load the servers (especially the root servers)
|
||||||
# uneccessarily. If you have a dial-on-demand link they also stop
|
# necessarily. If you have a dial-on-demand link they also stop
|
||||||
# these requests from bringing up the link uneccessarily.
|
# these requests from bringing up the link necessarily.
|
||||||
|
|
||||||
# Never forward plain names (without a dot or domain part)
|
# Never forward plain names (without a dot or domain part)
|
||||||
#domain-needed
|
#domain-needed
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
# non-public domains.
|
# non-public domains.
|
||||||
#server=/localnet/192.168.0.1
|
#server=/localnet/192.168.0.1
|
||||||
|
|
||||||
# Example of routing PTR queries to nameservers: this will send all
|
# Example of routing PTR queries to nameservers: this will send all
|
||||||
# address->name queries for 192.168.3/24 to nameserver 10.1.2.3
|
# address->name queries for 192.168.3/24 to nameserver 10.1.2.3
|
||||||
#server=/3.168.192.in-addr.arpa/10.1.2.3
|
#server=/3.168.192.in-addr.arpa/10.1.2.3
|
||||||
|
|
||||||
@@ -57,21 +57,21 @@
|
|||||||
#local=/localnet/
|
#local=/localnet/
|
||||||
|
|
||||||
# Add domains which you want to force to an IP address here.
|
# Add domains which you want to force to an IP address here.
|
||||||
# The example below send any host in doubleclick.net to a local
|
# The example below send any host in double-click.net to a local
|
||||||
# webserver.
|
# web-server.
|
||||||
#address=/doubleclick.net/127.0.0.1
|
#address=/double-click.net/127.0.0.1
|
||||||
|
|
||||||
# --address (and --server) work with IPv6 addresses too.
|
# --address (and --server) work with IPv6 addresses too.
|
||||||
#address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83
|
#address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83
|
||||||
|
|
||||||
# You can control how dnsmasq talks to a server: this forces
|
# You can control how dnsmasq talks to a server: this forces
|
||||||
# queries to 10.1.2.3 to be routed via eth1
|
# queries to 10.1.2.3 to be routed via eth1
|
||||||
# --server=10.1.2.3@eth1
|
# server=10.1.2.3@eth1
|
||||||
|
|
||||||
# and this sets the source (ie local) address used to talk to
|
# and this sets the source (ie local) address used to talk to
|
||||||
# 10.1.2.3 to 192.168.1.1 port 55 (there must be a interface with that
|
# 10.1.2.3 to 192.168.1.1 port 55 (there must be a interface with that
|
||||||
# IP on the machine, obviously).
|
# IP on the machine, obviously).
|
||||||
# --server=10.1.2.3@192.168.1.1#55
|
# server=10.1.2.3@192.168.1.1#55
|
||||||
|
|
||||||
# If you want dnsmasq to change uid and gid to something other
|
# If you want dnsmasq to change uid and gid to something other
|
||||||
# than the default, edit the following lines.
|
# than the default, edit the following lines.
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
#listen-address=
|
#listen-address=
|
||||||
# If you want dnsmasq to provide only DNS service on an interface,
|
# If you want dnsmasq to provide only DNS service on an interface,
|
||||||
# configure it as shown above, and then use the following line to
|
# configure it as shown above, and then use the following line to
|
||||||
# disable DHCP on it.
|
# disable DHCP and TFTP on it.
|
||||||
#no-dhcp-interface=
|
#no-dhcp-interface=
|
||||||
|
|
||||||
# On systems which support it, dnsmasq binds the wildcard address,
|
# On systems which support it, dnsmasq binds the wildcard address,
|
||||||
@@ -141,17 +141,29 @@
|
|||||||
# don't need to worry about this.
|
# don't need to worry about this.
|
||||||
#dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h
|
#dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h
|
||||||
|
|
||||||
# This is an example of a DHCP range with a network-id, so that
|
# This is an example of a DHCP range which sets a tag, so that
|
||||||
# some DHCP options may be set only for this network.
|
# some DHCP options may be set only for this network.
|
||||||
#dhcp-range=red,192.168.0.50,192.168.0.150
|
#dhcp-range=set:red,192.168.0.50,192.168.0.150
|
||||||
|
|
||||||
|
# Use this DHCP range only when the tag "green" is set.
|
||||||
|
#dhcp-range=tag:green,192.168.0.50,192.168.0.150,12h
|
||||||
|
|
||||||
|
# Specify a subnet which can't be used for dynamic address allocation,
|
||||||
|
# is available for hosts with matching --dhcp-host lines. Note that
|
||||||
|
# dhcp-host declarations will be ignored unless there is a dhcp-range
|
||||||
|
# of some type for the subnet in question.
|
||||||
|
# In this case the netmask is implied (it comes from the network
|
||||||
|
# configuration on the machine running dnsmasq) it is possible to give
|
||||||
|
# an explicit netmask instead.
|
||||||
|
#dhcp-range=192.168.0.0,static
|
||||||
|
|
||||||
# Supply parameters for specified hosts using DHCP. There are lots
|
# Supply parameters for specified hosts using DHCP. There are lots
|
||||||
# of valid alternatives, so we will give examples of each. Note that
|
# of valid alternatives, so we will give examples of each. Note that
|
||||||
# IP addresses DO NOT have to be in the range given above, they just
|
# IP addresses DO NOT have to be in the range given above, they just
|
||||||
# need to be on the same network. The order of the parameters in these
|
# need to be on the same network. The order of the parameters in these
|
||||||
# do not matter, it's permissble to give name,adddress and MAC in any order
|
# do not matter, it's permissible to give name,address and MAC in any order
|
||||||
|
|
||||||
# Always allocate the host with ethernet address 11:22:33:44:55:66
|
# Always allocate the host with Ethernet address 11:22:33:44:55:66
|
||||||
# The IP address 192.168.0.60
|
# The IP address 192.168.0.60
|
||||||
#dhcp-host=11:22:33:44:55:66,192.168.0.60
|
#dhcp-host=11:22:33:44:55:66,192.168.0.60
|
||||||
|
|
||||||
@@ -159,13 +171,13 @@
|
|||||||
# 11:22:33:44:55:66 to be "fred"
|
# 11:22:33:44:55:66 to be "fred"
|
||||||
#dhcp-host=11:22:33:44:55:66,fred
|
#dhcp-host=11:22:33:44:55:66,fred
|
||||||
|
|
||||||
# Always give the host with ethernet address 11:22:33:44:55:66
|
# Always give the host with Ethernet address 11:22:33:44:55:66
|
||||||
# the name fred and IP address 192.168.0.60 and lease time 45 minutes
|
# the name fred and IP address 192.168.0.60 and lease time 45 minutes
|
||||||
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
|
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
|
||||||
|
|
||||||
# Give a host with ethernet address 11:22:33:44:55:66 or
|
# Give a host with Ethernet address 11:22:33:44:55:66 or
|
||||||
# 12:34:56:78:90:12 the IP address 192.168.0.60. Dnsmasq will assume
|
# 12:34:56:78:90:12 the IP address 192.168.0.60. Dnsmasq will assume
|
||||||
# that these two ethernet interfaces will never be in use at the same
|
# that these two Ethernet interfaces will never be in use at the same
|
||||||
# time, and give the IP address to the second, even if it is already
|
# time, and give the IP address to the second, even if it is already
|
||||||
# in use by the first. Useful for laptops with wired and wireless
|
# in use by the first. Useful for laptops with wired and wireless
|
||||||
# addresses.
|
# addresses.
|
||||||
@@ -188,41 +200,41 @@
|
|||||||
# it asks for a DHCP lease.
|
# it asks for a DHCP lease.
|
||||||
#dhcp-host=judge
|
#dhcp-host=judge
|
||||||
|
|
||||||
# Never offer DHCP service to a machine whose ethernet
|
# Never offer DHCP service to a machine whose Ethernet
|
||||||
# address is 11:22:33:44:55:66
|
# address is 11:22:33:44:55:66
|
||||||
#dhcp-host=11:22:33:44:55:66,ignore
|
#dhcp-host=11:22:33:44:55:66,ignore
|
||||||
|
|
||||||
# Ignore any client-id presented by the machine with ethernet
|
# Ignore any client-id presented by the machine with Ethernet
|
||||||
# address 11:22:33:44:55:66. This is useful to prevent a machine
|
# address 11:22:33:44:55:66. This is useful to prevent a machine
|
||||||
# being treated differently when running under different OS's or
|
# being treated differently when running under different OS's or
|
||||||
# between PXE boot and OS boot.
|
# between PXE boot and OS boot.
|
||||||
#dhcp-host=11:22:33:44:55:66,id:*
|
#dhcp-host=11:22:33:44:55:66,id:*
|
||||||
|
|
||||||
# Send extra options which are tagged as "red" to
|
# Send extra options which are tagged as "red" to
|
||||||
# the machine with ethernet address 11:22:33:44:55:66
|
# the machine with Ethernet address 11:22:33:44:55:66
|
||||||
#dhcp-host=11:22:33:44:55:66,net:red
|
#dhcp-host=11:22:33:44:55:66,set:red
|
||||||
|
|
||||||
# Send extra options which are tagged as "red" to
|
# Send extra options which are tagged as "red" to
|
||||||
# any machine with ethernet address starting 11:22:33:
|
# any machine with Ethernet address starting 11:22:33:
|
||||||
#dhcp-host=11:22:33:*:*:*,net:red
|
#dhcp-host=11:22:33:*:*:*,set:red
|
||||||
|
|
||||||
# Ignore any clients which are specified in dhcp-host lines
|
# Ignore any clients which are specified in dhcp-host lines
|
||||||
# or /etc/ethers. Equivalent to ISC "deny unkown-clients".
|
# or /etc/ethers. Equivalent to ISC "deny unknown-clients".
|
||||||
# This relies on the special "known" tag which is set when
|
# This relies on the special "known" tag which is set when
|
||||||
# a host is matched.
|
# a host is matched.
|
||||||
#dhcp-ignore=#known
|
#dhcp-ignore=tag:!known
|
||||||
|
|
||||||
# Send extra options which are tagged as "red" to any machine whose
|
# Send extra options which are tagged as "red" to any machine whose
|
||||||
# DHCP vendorclass string includes the substring "Linux"
|
# DHCP vendorclass string includes the substring "Linux"
|
||||||
#dhcp-vendorclass=red,Linux
|
#dhcp-vendorclass=set:red,Linux
|
||||||
|
|
||||||
# Send extra options which are tagged as "red" to any machine one
|
# Send extra options which are tagged as "red" to any machine one
|
||||||
# of whose DHCP userclass strings includes the substring "accounts"
|
# of whose DHCP userclass strings includes the substring "accounts"
|
||||||
#dhcp-userclass=red,accounts
|
#dhcp-userclass=set:red,accounts
|
||||||
|
|
||||||
# Send extra options which are tagged as "red" to any machine whose
|
# Send extra options which are tagged as "red" to any machine whose
|
||||||
# MAC address matches the pattern.
|
# MAC address matches the pattern.
|
||||||
#dhcp-mac=red,00:60:8C:*:*:*
|
#dhcp-mac=set:red,00:60:8C:*:*:*
|
||||||
|
|
||||||
# If this line is uncommented, dnsmasq will read /etc/ethers and act
|
# If this line is uncommented, dnsmasq will read /etc/ethers and act
|
||||||
# on the ethernet-address/IP pairs found there just as if they had
|
# on the ethernet-address/IP pairs found there just as if they had
|
||||||
@@ -232,11 +244,11 @@
|
|||||||
|
|
||||||
# Send options to hosts which ask for a DHCP lease.
|
# Send options to hosts which ask for a DHCP lease.
|
||||||
# See RFC 2132 for details of available options.
|
# See RFC 2132 for details of available options.
|
||||||
# Common options can be given to dnsmasq by name:
|
# Common options can be given to dnsmasq by name:
|
||||||
# run "dnsmasq --help dhcp" to get a list.
|
# run "dnsmasq --help dhcp" to get a list.
|
||||||
# Note that all the common settings, such as netmask and
|
# Note that all the common settings, such as netmask and
|
||||||
# broadcast address, DNS server and default route, are given
|
# broadcast address, DNS server and default route, are given
|
||||||
# sane defaults by dnsmasq. You very likely will not need
|
# sane defaults by dnsmasq. You very likely will not need
|
||||||
# any dhcp-options. If you use Windows clients and Samba, there
|
# any dhcp-options. If you use Windows clients and Samba, there
|
||||||
# are some options which are recommended, they are detailed at the
|
# are some options which are recommended, they are detailed at the
|
||||||
# end of this section.
|
# end of this section.
|
||||||
@@ -250,7 +262,7 @@
|
|||||||
|
|
||||||
# Override the default route supplied by dnsmasq and send no default
|
# Override the default route supplied by dnsmasq and send no default
|
||||||
# route at all. Note that this only works for the options sent by
|
# route at all. Note that this only works for the options sent by
|
||||||
# default (1, 3, 6, 12, 28) the same line will send a zero-length option
|
# default (1, 3, 6, 12, 28) the same line will send a zero-length option
|
||||||
# for all other option numbers.
|
# for all other option numbers.
|
||||||
#dhcp-option=3
|
#dhcp-option=3
|
||||||
|
|
||||||
@@ -276,15 +288,15 @@
|
|||||||
|
|
||||||
# Specify an option which will only be sent to the "red" network
|
# Specify an option which will only be sent to the "red" network
|
||||||
# (see dhcp-range for the declaration of the "red" network)
|
# (see dhcp-range for the declaration of the "red" network)
|
||||||
# Note that the net: part must precede the option: part.
|
# Note that the tag: part must precede the option: part.
|
||||||
#dhcp-option = net:red, option:ntp-server, 192.168.1.1
|
#dhcp-option = tag:red, option:ntp-server, 192.168.1.1
|
||||||
|
|
||||||
# The following DHCP options set up dnsmasq in the same way as is specified
|
# The following DHCP options set up dnsmasq in the same way as is specified
|
||||||
# for the ISC dhcpcd in
|
# for the ISC dhcpcd in
|
||||||
# http://www.samba.org/samba/ftp/docs/textdocs/DHCP-Server-Configuration.txt
|
# http://www.samba.org/samba/ftp/docs/textdocs/DHCP-Server-Configuration.txt
|
||||||
# adapted for a typical dnsmasq installation where the host running
|
# adapted for a typical dnsmasq installation where the host running
|
||||||
# dnsmasq is also the host running samba.
|
# dnsmasq is also the host running samba.
|
||||||
# you may want to uncomment some or all of them if you use
|
# you may want to uncomment some or all of them if you use
|
||||||
# Windows clients and Samba.
|
# Windows clients and Samba.
|
||||||
#dhcp-option=19,0 # option ip-forwarding off
|
#dhcp-option=19,0 # option ip-forwarding off
|
||||||
#dhcp-option=44,0.0.0.0 # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)
|
#dhcp-option=44,0.0.0.0 # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)
|
||||||
@@ -298,10 +310,10 @@
|
|||||||
# Send RFC-3442 classless static routes (note the netmask encoding)
|
# Send RFC-3442 classless static routes (note the netmask encoding)
|
||||||
#dhcp-option=121,192.168.1.0/24,1.2.3.4,10.0.0.0/8,5.6.7.8
|
#dhcp-option=121,192.168.1.0/24,1.2.3.4,10.0.0.0/8,5.6.7.8
|
||||||
|
|
||||||
# Send vendor-class specific options encapsulated in DHCP option 43.
|
# Send vendor-class specific options encapsulated in DHCP option 43.
|
||||||
# The meaning of the options is defined by the vendor-class so
|
# The meaning of the options is defined by the vendor-class so
|
||||||
# options are sent only when the client supplied vendor class
|
# options are sent only when the client supplied vendor class
|
||||||
# matches the class given here. (A substring match is OK, so "MSFT"
|
# matches the class given here. (A substring match is OK, so "MSFT"
|
||||||
# matches "MSFT" and "MSFT 5.0"). This example sets the
|
# matches "MSFT" and "MSFT 5.0"). This example sets the
|
||||||
# mtftp address to 0.0.0.0 for PXEClients.
|
# mtftp address to 0.0.0.0 for PXEClients.
|
||||||
#dhcp-option=vendor:PXEClient,1,0.0.0.0
|
#dhcp-option=vendor:PXEClient,1,0.0.0.0
|
||||||
@@ -318,7 +330,7 @@
|
|||||||
|
|
||||||
# Send options to PXELinux. Note that we need to send the options even
|
# Send options to PXELinux. Note that we need to send the options even
|
||||||
# though they don't appear in the parameter request list, so we need
|
# though they don't appear in the parameter request list, so we need
|
||||||
# to use dhcp-option-force here.
|
# to use dhcp-option-force here.
|
||||||
# See http://syslinux.zytor.com/pxe.php#special for details.
|
# See http://syslinux.zytor.com/pxe.php#special for details.
|
||||||
# Magic number - needed before anything else is recognised
|
# Magic number - needed before anything else is recognised
|
||||||
#dhcp-option-force=208,f1:00:74:7e
|
#dhcp-option-force=208,f1:00:74:7e
|
||||||
@@ -329,7 +341,7 @@
|
|||||||
# Reboot time. (Note 'i' to send 32-bit value)
|
# Reboot time. (Note 'i' to send 32-bit value)
|
||||||
#dhcp-option-force=211,30i
|
#dhcp-option-force=211,30i
|
||||||
|
|
||||||
# Set the boot filename for netboot/PXE. You will only need
|
# Set the boot filename for netboot/PXE. You will only need
|
||||||
# this is you want to boot machines over the network and you will need
|
# this is you want to boot machines over the network and you will need
|
||||||
# a TFTP server; either dnsmasq's built in TFTP server or an
|
# a TFTP server; either dnsmasq's built in TFTP server or an
|
||||||
# external one. (See below for how to enable the TFTP server.)
|
# external one. (See below for how to enable the TFTP server.)
|
||||||
@@ -338,15 +350,15 @@
|
|||||||
# Boot for Etherboot gPXE. The idea is to send two different
|
# Boot for Etherboot gPXE. The idea is to send two different
|
||||||
# filenames, the first loads gPXE, and the second tells gPXE what to
|
# filenames, the first loads gPXE, and the second tells gPXE what to
|
||||||
# load. The dhcp-match sets the gpxe tag for requests from gPXE.
|
# load. The dhcp-match sets the gpxe tag for requests from gPXE.
|
||||||
#dhcp-match=gpxe,175 # gPXE sends a 175 option.
|
#dhcp-match=set:gpxe,175 # gPXE sends a 175 option.
|
||||||
#dhcp-boot=net:#gpxe,undionly.kpxe
|
#dhcp-boot=tag:!gpxe,undionly.kpxe
|
||||||
#dhcp-boot=mybootimage
|
#dhcp-boot=mybootimage
|
||||||
|
|
||||||
# Encapsulated options for Etherboot gPXE. All the options are
|
# Encapsulated options for Etherboot gPXE. All the options are
|
||||||
# encapsulated within option 175
|
# encapsulated within option 175
|
||||||
#dhcp-option=encap:175, 1, 5b # priority code
|
#dhcp-option=encap:175, 1, 5b # priority code
|
||||||
#dhcp-option=encap:175, 176, 1b # no-proxydhcp
|
#dhcp-option=encap:175, 176, 1b # no-proxydhcp
|
||||||
#dhcp-option=encap:175, 177, string # bus-id
|
#dhcp-option=encap:175, 177, string # bus-id
|
||||||
#dhcp-option=encap:175, 189, 1b # BIOS drive code
|
#dhcp-option=encap:175, 189, 1b # BIOS drive code
|
||||||
#dhcp-option=encap:175, 190, user # iSCSI username
|
#dhcp-option=encap:175, 190, user # iSCSI username
|
||||||
#dhcp-option=encap:175, 191, pass # iSCSI password
|
#dhcp-option=encap:175, 191, pass # iSCSI password
|
||||||
@@ -356,7 +368,7 @@
|
|||||||
#dhcp-match=peecees, option:client-arch, 0 #x86-32
|
#dhcp-match=peecees, option:client-arch, 0 #x86-32
|
||||||
#dhcp-match=itanics, option:client-arch, 2 #IA64
|
#dhcp-match=itanics, option:client-arch, 2 #IA64
|
||||||
#dhcp-match=hammers, option:client-arch, 6 #x86-64
|
#dhcp-match=hammers, option:client-arch, 6 #x86-64
|
||||||
#dhcp-match=mactels, option:client-arch, 7 #EFI x86-64
|
#dhcp-match=mactels, option:client-arch, 7 #EFI x86-64
|
||||||
|
|
||||||
# Do real PXE, rather than just booting a single file, this is an
|
# Do real PXE, rather than just booting a single file, this is an
|
||||||
# alternative to dhcp-boot.
|
# alternative to dhcp-boot.
|
||||||
@@ -365,14 +377,14 @@
|
|||||||
#pxe-prompt="Press F8 for menu.", 60
|
#pxe-prompt="Press F8 for menu.", 60
|
||||||
|
|
||||||
# Available boot services. for PXE.
|
# Available boot services. for PXE.
|
||||||
#pxe-service=x86PC, "Boot from local disk", 0
|
#pxe-service=x86PC, "Boot from local disk"
|
||||||
|
|
||||||
# Loads <tftp-root>/pxelinux.0 from dnsmasq TFTP server.
|
# Loads <tftp-root>/pxelinux.0 from dnsmasq TFTP server.
|
||||||
#pxe-service=x86PC, "Install Linux", pxelinux
|
#pxe-service=x86PC, "Install Linux", pxelinux
|
||||||
|
|
||||||
# Loads <tftp-root>/pxelinux.0 from TFTP server at 1.2.3.4.
|
# Loads <tftp-root>/pxelinux.0 from TFTP server at 1.2.3.4.
|
||||||
# Beware this fails on old PXE ROMS.
|
# Beware this fails on old PXE ROMS.
|
||||||
#pxe-service=x86PC, "Install Linux", pxelinux, 1.2.3.4
|
#pxe-service=x86PC, "Install Linux", pxelinux, 1.2.3.4
|
||||||
|
|
||||||
# Use bootserver on network, found my multicast or broadcast.
|
# Use bootserver on network, found my multicast or broadcast.
|
||||||
#pxe-service=x86PC, "Install windows from RIS server", 1
|
#pxe-service=x86PC, "Install windows from RIS server", 1
|
||||||
@@ -383,20 +395,20 @@
|
|||||||
# If you have multicast-FTP available,
|
# If you have multicast-FTP available,
|
||||||
# information for that can be passed in a similar way using options 1
|
# information for that can be passed in a similar way using options 1
|
||||||
# to 5. See page 19 of
|
# to 5. See page 19 of
|
||||||
# http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf
|
# http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Enable dnsmasq's built-in TFTP server
|
# Enable dnsmasq's built-in TFTP server
|
||||||
#enable-tftp
|
#enable-tftp
|
||||||
|
|
||||||
# Set the root directory for files availble via FTP.
|
# Set the root directory for files available via FTP.
|
||||||
#tftp-root=/var/ftpd
|
#tftp-root=/var/ftpd
|
||||||
|
|
||||||
# Make the TFTP server more secure: with this set, only files owned by
|
# Make the TFTP server more secure: with this set, only files owned by
|
||||||
# the user dnsmasq is running as will be send over the net.
|
# the user dnsmasq is running as will be send over the net.
|
||||||
#tftp-secure
|
#tftp-secure
|
||||||
|
|
||||||
# This option stops dnsmasq from negotiating a larger blocksize for TFTP
|
# This option stops dnsmasq from negotiating a larger blocksize for TFTP
|
||||||
# transfers. It will slow things down, but may rescue some broken TFTP
|
# transfers. It will slow things down, but may rescue some broken TFTP
|
||||||
# clients.
|
# clients.
|
||||||
#tftp-no-blocksize
|
#tftp-no-blocksize
|
||||||
@@ -421,16 +433,16 @@
|
|||||||
# and take over the lease for any client which broadcasts on the network,
|
# and take over the lease for any client which broadcasts on the network,
|
||||||
# whether it has a record of the lease or not. This avoids long timeouts
|
# whether it has a record of the lease or not. This avoids long timeouts
|
||||||
# when a machine wakes up on a new network. DO NOT enable this if there's
|
# when a machine wakes up on a new network. DO NOT enable this if there's
|
||||||
# the slighest chance that you might end up accidentally configuring a DHCP
|
# the slightest chance that you might end up accidentally configuring a DHCP
|
||||||
# server for your campus/company accidentally. The ISC server uses
|
# server for your campus/company accidentally. The ISC server uses
|
||||||
# the same option, and this URL provides more information:
|
# the same option, and this URL provides more information:
|
||||||
# http://www.isc.org/index.pl?/sw/dhcp/authoritative.php
|
# http://www.isc.org/files/auth.html
|
||||||
#dhcp-authoritative
|
#dhcp-authoritative
|
||||||
|
|
||||||
# Run an executable when a DHCP lease is created or destroyed.
|
# Run an executable when a DHCP lease is created or destroyed.
|
||||||
# The arguments sent to the script are "add" or "del",
|
# The arguments sent to the script are "add" or "del",
|
||||||
# then the MAC address, the IP address and finally the hostname
|
# then the MAC address, the IP address and finally the hostname
|
||||||
# if there is one.
|
# if there is one.
|
||||||
#dhcp-script=/bin/echo
|
#dhcp-script=/bin/echo
|
||||||
|
|
||||||
# Set the cachesize here.
|
# Set the cachesize here.
|
||||||
@@ -490,11 +502,11 @@
|
|||||||
# set for this to work.)
|
# set for this to work.)
|
||||||
|
|
||||||
# A SRV record sending LDAP for the example.com domain to
|
# A SRV record sending LDAP for the example.com domain to
|
||||||
# ldapserver.example.com port 289
|
# ldapserver.example.com port 389
|
||||||
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
|
#srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
|
||||||
|
|
||||||
# A SRV record sending LDAP for the example.com domain to
|
# A SRV record sending LDAP for the example.com domain to
|
||||||
# ldapserver.example.com port 289 (using domain=)
|
# ldapserver.example.com port 389 (using domain=)
|
||||||
#domain=example.com
|
#domain=example.com
|
||||||
#srv-host=_ldap._tcp,ldapserver.example.com,389
|
#srv-host=_ldap._tcp,ldapserver.example.com,389
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
<HTML>
|
<HTML>
|
||||||
<HEAD>
|
<HEAD>
|
||||||
<TITLE> Dnsmasq - a DNS forwarder for NAT firewalls.</TITLE>
|
<TITLE> Dnsmasq - a DNS forwarder for NAT firewalls.</TITLE>
|
||||||
|
<link rel="icon"
|
||||||
|
href="http://www.thekelleys.org.uk/dnsmasq/images/favicon.ico">
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY BGCOLOR="WHITE">
|
<BODY BGCOLOR="WHITE">
|
||||||
<H1 ALIGN=center>Dnsmasq</H1>
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td align="left" valign="middle"><img border="0" src="http://www.thekelleys.org.uk/dnsmasq/images/icon.png" /></td>
|
||||||
|
<td align="middle" valign="middle"><h1>Dnsmasq</h1></td>
|
||||||
|
<td align="right" valign="middle"><img border="0" src="http://www.thekelleys.org.uk/dnsmasq/images/icon.png" /></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP
|
Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP
|
||||||
server. It is designed to provide DNS and, optionally, DHCP, to a
|
server. It is designed to provide DNS and, optionally, DHCP, to a
|
||||||
small network. It can serve the names of local machines which are
|
small network. It can serve the names of local machines which are
|
||||||
|
|||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
Dnsmasq logo, contributed by Justin Clift.
|
||||||
|
|
||||||
|
The source format is Inkscape SVG vector format, which is scalable and
|
||||||
|
easy to export to other formats. For convenience I've included a 56x31
|
||||||
|
png export and a 16x16 ico suitable for use as a web favicon.
|
||||||
|
|
||||||
|
Simon Kelley, 22/10/2010
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
+157
@@ -0,0 +1,157 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
width="56"
|
||||||
|
height="31"
|
||||||
|
viewBox="0 0 56 31"
|
||||||
|
enable-background="new 0 0 72.833 46.667"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg2"
|
||||||
|
inkscape:version="0.47 r22583"
|
||||||
|
sodipodi:docname="dnsmasq_icon.svg"
|
||||||
|
inkscape:export-filename="/x/centos_home/jc/workspace/git_repos/libvirt-media/libvirt-media/png/dnsmasq_icon.png"
|
||||||
|
inkscape:export-xdpi="90"
|
||||||
|
inkscape:export-ydpi="90"><metadata
|
||||||
|
id="metadata27"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs25"><inkscape:perspective
|
||||||
|
sodipodi:type="inkscape:persp3d"
|
||||||
|
inkscape:vp_x="0 : 23.3335 : 1"
|
||||||
|
inkscape:vp_y="0 : 1000 : 0"
|
||||||
|
inkscape:vp_z="72.833 : 23.3335 : 1"
|
||||||
|
inkscape:persp3d-origin="36.4165 : 15.555667 : 1"
|
||||||
|
id="perspective4857" />
|
||||||
|
<filter
|
||||||
|
id="filter3802"
|
||||||
|
inkscape:label="filter1"
|
||||||
|
color-interpolation-filters="sRGB" /><linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#SVGID_3_"
|
||||||
|
id="linearGradient4929"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="30.564501"
|
||||||
|
y1="-8.8144999"
|
||||||
|
x2="32.937"
|
||||||
|
y2="32.715599" />
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#SVGID_3_"
|
||||||
|
id="linearGradient5798"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="30.564501"
|
||||||
|
y1="-8.8144999"
|
||||||
|
x2="32.937"
|
||||||
|
y2="32.715599" /><linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#SVGID_3_"
|
||||||
|
id="linearGradient5812"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="30.564501"
|
||||||
|
y1="-8.8144999"
|
||||||
|
x2="32.937"
|
||||||
|
y2="32.715599" /><filter
|
||||||
|
id="filter6262"
|
||||||
|
inkscape:label="Drop shadow"
|
||||||
|
width="1.5"
|
||||||
|
height="1.5"
|
||||||
|
x="-0.25"
|
||||||
|
y="-0.25"
|
||||||
|
color-interpolation-filters="sRGB"><feGaussianBlur
|
||||||
|
id="feGaussianBlur6264"
|
||||||
|
in="SourceAlpha"
|
||||||
|
stdDeviation="2.500000"
|
||||||
|
result="blur" /><feColorMatrix
|
||||||
|
id="feColorMatrix6266"
|
||||||
|
result="bluralpha"
|
||||||
|
type="matrix"
|
||||||
|
values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.500000 0 " /><feOffset
|
||||||
|
id="feOffset6268"
|
||||||
|
in="bluralpha"
|
||||||
|
dx="2.700000"
|
||||||
|
dy="2.600000"
|
||||||
|
result="offsetBlur" /><feMerge
|
||||||
|
id="feMerge6270"><feMergeNode
|
||||||
|
id="feMergeNode6272"
|
||||||
|
in="offsetBlur" /><feMergeNode
|
||||||
|
id="feMergeNode6274"
|
||||||
|
in="SourceGraphic" /></feMerge></filter></defs><sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1568"
|
||||||
|
inkscape:window-height="1076"
|
||||||
|
id="namedview23"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="8"
|
||||||
|
inkscape:cx="31.966768"
|
||||||
|
inkscape:cy="21.211869"
|
||||||
|
inkscape:window-x="567"
|
||||||
|
inkscape:window-y="328"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:showpageshadow="false"
|
||||||
|
showborder="true" />
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="dnsmasq"
|
||||||
|
style="display:inline"
|
||||||
|
transform="translate(5.2838057,-15.545371)"><g
|
||||||
|
id="g3790"
|
||||||
|
transform="matrix(0.8183832,0,0,0.8183832,65.304897,9.8747678)"
|
||||||
|
style="filter:url(#filter6262)"
|
||||||
|
inkscape:export-xdpi="90"
|
||||||
|
inkscape:export-ydpi="90"><g
|
||||||
|
transform="translate(-91.018462,1.0687099)"
|
||||||
|
id="g9">
|
||||||
|
<path
|
||||||
|
style="fill:#6700ad"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path11"
|
||||||
|
d="M 54.997,12.151 C 50.083,9.132 43.29,7.266 35.791,7.266 c -7.5,0 -14.29,1.866 -19.204,4.885 -4.915,3.016 -7.956,7.184 -7.956,11.789 0,4.604 3.041,8.772 7.956,11.788 4.914,3.02 11.704,-4.271 19.204,-4.271 7.499,0 14.292,7.291 19.206,4.271 4.914,-3.016 7.955,-7.185 7.955,-11.788 0,-4.606 -3.041,-8.773 -7.955,-11.789 z M 24.996,24.318 c -2.698,0 -4.885,-0.922 -4.885,-2.061 0,-1.14 2.187,-2.063 4.885,-2.063 2.697,0 4.885,0.924 4.885,2.063 0,1.139 -2.188,2.061 -4.885,2.061 z m 21.501,0.191 c -2.686,0 -4.861,-0.856 -4.861,-1.912 0,-1.054 2.176,-1.911 4.861,-1.911 2.685,0 4.863,0.857 4.863,1.911 0,1.056 -2.178,1.912 -4.863,1.912 z" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#ffb616;stroke-width:1.85353255"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path13"
|
||||||
|
d="M 54.997,12.151 C 50.083,9.132 43.29,7.266 35.791,7.266 c -7.5,0 -14.29,1.866 -19.204,4.885 -4.915,3.016 -7.956,7.184 -7.956,11.789 0,4.604 3.041,8.772 7.956,11.788 4.914,3.02 11.704,-4.271 19.204,-4.271 7.499,0 14.292,7.291 19.206,4.271 4.914,-3.016 7.955,-7.185 7.955,-11.788 0,-4.606 -3.041,-8.773 -7.955,-11.789 z M 24.996,24.318 c -2.698,0 -4.885,-0.922 -4.885,-2.061 0,-1.14 2.187,-2.063 4.885,-2.063 2.697,0 4.885,0.924 4.885,2.063 0,1.139 -2.188,2.061 -4.885,2.061 z m 21.501,0.191 c -2.686,0 -4.861,-0.856 -4.861,-1.912 0,-1.054 2.176,-1.911 4.861,-1.911 2.685,0 4.863,0.857 4.863,1.911 0,1.056 -2.178,1.912 -4.863,1.912 z" />
|
||||||
|
</g><g
|
||||||
|
transform="translate(-91.018462,1.0687099)"
|
||||||
|
id="Layer_2">
|
||||||
|
<linearGradient
|
||||||
|
y2="32.715599"
|
||||||
|
x2="32.937"
|
||||||
|
y1="-8.8144999"
|
||||||
|
x1="30.564501"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
id="SVGID_3_">
|
||||||
|
<stop
|
||||||
|
id="stop17"
|
||||||
|
style="stop-color:#FFFFFF;stop-opacity:0.73"
|
||||||
|
offset="0" />
|
||||||
|
<stop
|
||||||
|
id="stop19"
|
||||||
|
style="stop-color:#FFFFFF;stop-opacity:0"
|
||||||
|
offset="1" />
|
||||||
|
</linearGradient>
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:url(#linearGradient5812)"
|
||||||
|
id="path21"
|
||||||
|
d="m 54.1,15.361 c -0.924,1.078 -2.782,1.265 -3.857,1.06 C 38,14.083 22.75,12.75 16.027,23.031 14.858,24.819 11.992,25.39 10.293,23.887 8.631,22.417 13.105,15.804 17.646,13.033 22.194,10.252 28.474,8.53 35.41,8.53 c 6.936,0 13.215,1.722 17.756,4.502 0.731,0.442 1.627,1.52 0.934,2.329 z" />
|
||||||
|
</g></g></g></svg>
|
||||||
|
After Width: | Height: | Size: 6.0 KiB |
+330
-113
@@ -23,7 +23,7 @@ options. It includes a secure, read-only,
|
|||||||
TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP.
|
TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP.
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq
|
Dnsmasq
|
||||||
supports IPv6 for DNS, but not DHCP.
|
supports IPv6 for DNS and TFTP, but not DHCP.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
Note that in general missing parameters are allowed and switch off
|
Note that in general missing parameters are allowed and switch off
|
||||||
functions, for instance "--pid-file" disables writing a PID file. On
|
functions, for instance "--pid-file" disables writing a PID file. On
|
||||||
@@ -65,6 +65,12 @@ cache the reply. This option gives a default value for time-to-live
|
|||||||
(in seconds) which dnsmasq uses to cache negative replies even in
|
(in seconds) which dnsmasq uses to cache negative replies even in
|
||||||
the absence of an SOA record.
|
the absence of an SOA record.
|
||||||
.TP
|
.TP
|
||||||
|
.B --max-ttl=<time>
|
||||||
|
Set a maximum TTL value that will be handed out to clients. The specified
|
||||||
|
maximum TTL will be given to clients instead of the true TTL value if it is
|
||||||
|
lower. The true TTL value is however kept in the cache to avoid flooding
|
||||||
|
the upstream DNS servers.
|
||||||
|
.TP
|
||||||
.B \-k, --keep-in-foreground
|
.B \-k, --keep-in-foreground
|
||||||
Do not go into the background at startup but otherwise run as
|
Do not go into the background at startup but otherwise run as
|
||||||
normal. This is intended for use when dnsmasq is run under daemontools
|
normal. This is intended for use when dnsmasq is run under daemontools
|
||||||
@@ -84,7 +90,8 @@ Set the facility to which dnsmasq will send syslog entries, this
|
|||||||
defaults to DAEMON, and to LOCAL0 when debug mode is in operation. If
|
defaults to DAEMON, and to LOCAL0 when debug mode is in operation. If
|
||||||
the facility given contains at least one '/' character, it is taken to
|
the facility given contains at least one '/' character, it is taken to
|
||||||
be a filename, and dnsmasq logs to the given file, instead of
|
be a filename, and dnsmasq logs to the given file, instead of
|
||||||
syslog. (Errors whilst reading configuration will still go to syslog,
|
syslog. If the facility is '-' then dnsmasq logs to stderr.
|
||||||
|
(Errors whilst reading configuration will still go to syslog,
|
||||||
but all output from a successful startup, and all output whilst
|
but all output from a successful startup, and all output whilst
|
||||||
running, will go exclusively to the file.) When logging to a file,
|
running, will go exclusively to the file.) When logging to a file,
|
||||||
dnsmasq will close and reopen the file when it receives SIGUSR2. This
|
dnsmasq will close and reopen the file when it receives SIGUSR2. This
|
||||||
@@ -123,8 +130,7 @@ to zero completely disables DNS function, leaving only DHCP and/or TFTP.
|
|||||||
.TP
|
.TP
|
||||||
.B \-P, --edns-packet-max=<size>
|
.B \-P, --edns-packet-max=<size>
|
||||||
Specify the largest EDNS.0 UDP packet which is supported by the DNS
|
Specify the largest EDNS.0 UDP packet which is supported by the DNS
|
||||||
forwarder. Defaults to 1280, which is the RFC2671-recommended maximum
|
forwarder. Defaults to 4096, which is the RFC5625-recommended size.
|
||||||
for ethernet.
|
|
||||||
.TP
|
.TP
|
||||||
.B \-Q, --query-port=<query_port>
|
.B \-Q, --query-port=<query_port>
|
||||||
Send outbound DNS queries from, and listen for their replies on, the
|
Send outbound DNS queries from, and listen for their replies on, the
|
||||||
@@ -277,6 +283,17 @@ Reject (and log) addresses from upstream nameservers which are in the
|
|||||||
private IP ranges. This blocks an attack where a browser behind a
|
private IP ranges. This blocks an attack where a browser behind a
|
||||||
firewall is used to probe machines on the local network.
|
firewall is used to probe machines on the local network.
|
||||||
.TP
|
.TP
|
||||||
|
.B --rebind-localhost-ok
|
||||||
|
Exempt 127.0.0.0/8 from rebinding checks. This address range is
|
||||||
|
returned by realtime black hole servers, so blocking it may disable
|
||||||
|
these services.
|
||||||
|
.TP
|
||||||
|
.B --rebind-domain-ok=[<domain>]|[[/<domain>/[<domain>/]
|
||||||
|
Do not detect and block dns-rebind on queries to these domains. The
|
||||||
|
argument may be either a single domain, or multiple domains surrounded
|
||||||
|
by '/', like the --server syntax, eg.
|
||||||
|
.B --rebind-domain-ok=/domain1/domain2/domain3/
|
||||||
|
.TP
|
||||||
.B \-n, --no-poll
|
.B \-n, --no-poll
|
||||||
Don't poll /etc/resolv.conf for changes.
|
Don't poll /etc/resolv.conf for changes.
|
||||||
.TP
|
.TP
|
||||||
@@ -309,7 +326,19 @@ dots in them. A non-standard port may be specified as
|
|||||||
part of the IP
|
part of the IP
|
||||||
address using a # character.
|
address using a # character.
|
||||||
More than one -S flag is allowed, with
|
More than one -S flag is allowed, with
|
||||||
repeated domain or ipaddr parts as required.
|
repeated domain or ipaddr parts as required.
|
||||||
|
|
||||||
|
More specific domains take precendence over less specific domains, so:
|
||||||
|
.B --server=/google.com/1.2.3.4
|
||||||
|
.B --server=/www.google.com/2.3.4.5
|
||||||
|
will send queries for *.google.com to 1.2.3.4, except *www.google.com,
|
||||||
|
which will go to 2.3.4.5
|
||||||
|
|
||||||
|
The special server address '#' means, "use the standard servers", so
|
||||||
|
.B --server=/google.com/1.2.3.4
|
||||||
|
.B --server=/www.google.com/#
|
||||||
|
will send queries for *.google.com to 1.2.3.4, except *www.google.com which will
|
||||||
|
be forwarded as usual.
|
||||||
|
|
||||||
Also permitted is a -S
|
Also permitted is a -S
|
||||||
flag which gives a domain but no IP address; this tells dnsmasq that
|
flag which gives a domain but no IP address; this tells dnsmasq that
|
||||||
@@ -386,7 +415,9 @@ all that match are returned.
|
|||||||
.TP
|
.TP
|
||||||
.B \-Y, --txt-record=<name>[[,<text>],<text>]
|
.B \-Y, --txt-record=<name>[[,<text>],<text>]
|
||||||
Return a TXT DNS record. The value of TXT record is a set of strings,
|
Return a TXT DNS record. The value of TXT record is a set of strings,
|
||||||
so any number may be included, split by commas.
|
so any number may be included, delimited by commas; use quotes to put
|
||||||
|
commas into a string. Note that the maximum length of a single string
|
||||||
|
is 255 characters, longer strings are split into 255 character chunks.
|
||||||
.TP
|
.TP
|
||||||
.B --ptr-record=<name>[,<target>]
|
.B --ptr-record=<name>[,<target>]
|
||||||
Return a PTR DNS record.
|
Return a PTR DNS record.
|
||||||
@@ -413,6 +444,15 @@ the name. More than one name may be associated with an interface
|
|||||||
address by repeating the flag; in that case the first instance is used
|
address by repeating the flag; in that case the first instance is used
|
||||||
for the reverse address-to-name mapping.
|
for the reverse address-to-name mapping.
|
||||||
.TP
|
.TP
|
||||||
|
.B --add-mac
|
||||||
|
Add the MAC address of the requestor to DNS queries which are
|
||||||
|
forwarded upstream. This may be used to DNS filtering by the upstream
|
||||||
|
server. The MAC address can only be added if the requestor is on the same
|
||||||
|
subnet as the dnsmasq server. Note that the mechanism used to achieve this (an EDNS0 option)
|
||||||
|
is not yet standardised, so this should be considered
|
||||||
|
experimental. Also note that exposing MAC addresses in this way may
|
||||||
|
have security and privacy implications.
|
||||||
|
.TP
|
||||||
.B \-c, --cache-size=<cachesize>
|
.B \-c, --cache-size=<cachesize>
|
||||||
Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
|
Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
|
||||||
.TP
|
.TP
|
||||||
@@ -427,7 +467,21 @@ Set the maximum number of concurrent DNS queries. The default value is
|
|||||||
where this needs to be increased is when using web-server log file
|
where this needs to be increased is when using web-server log file
|
||||||
resolvers, which can generate large numbers of concurrent queries.
|
resolvers, which can generate large numbers of concurrent queries.
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[[net:]network-id,]<start-addr>,<end-addr>[[,<netmask>],<broadcast>][,<lease time>]
|
.B --proxy-dnssec
|
||||||
|
A resolver on a client machine can do DNSSEC validation in two ways: it
|
||||||
|
can perform the cryptograhic operations on the reply it receives, or
|
||||||
|
it can rely on the upstream recursive nameserver to do the validation
|
||||||
|
and set a bit in the reply if it succeeds. Dnsmasq is not a DNSSEC
|
||||||
|
validator, so it cannot perform the validation role of the recursive nameserver,
|
||||||
|
but it can pass through the validation results from its own upstream
|
||||||
|
nameservers. This option enables this behaviour. You should only do
|
||||||
|
this if you trust all the configured upstream nameservers
|
||||||
|
.I and the network between you and them.
|
||||||
|
If you use the first DNSSEC mode, validating resolvers in clients,
|
||||||
|
this option is not required. Dnsmasq always returns all the data
|
||||||
|
needed for a client to do validation itself.
|
||||||
|
.TP
|
||||||
|
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-addr>,<end-addr>[,<netmask>[,<broadcast>]][,<lease time>]
|
||||||
Enable the DHCP server. Addresses will be given out from the range
|
Enable the DHCP server. Addresses will be given out from the range
|
||||||
<start-addr> to <end-addr> and from statically defined addresses given
|
<start-addr> to <end-addr> and from statically defined addresses given
|
||||||
in
|
in
|
||||||
@@ -443,10 +497,13 @@ networks on which the machine running dnsmasq has an interface) the
|
|||||||
netmask is optional. It is, however, required for networks which
|
netmask is optional. It is, however, required for networks which
|
||||||
receive DHCP service via a relay agent. The broadcast address is
|
receive DHCP service via a relay agent. The broadcast address is
|
||||||
always optional. It is always
|
always optional. It is always
|
||||||
allowed to have more than one dhcp-range in a single subnet. The optional
|
allowed to have more than one dhcp-range in a single subnet.
|
||||||
network-id is a alphanumeric label which marks this network so that
|
|
||||||
|
The optional
|
||||||
|
.B set:<tag>
|
||||||
|
sets an alphanumeric label which marks this network so that
|
||||||
dhcp options may be specified on a per-network basis.
|
dhcp options may be specified on a per-network basis.
|
||||||
When it is prefixed with 'net:' then its meaning changes from setting
|
When it is prefixed with 'tag:' instead, then its meaning changes from setting
|
||||||
a tag to matching it. Only one tag may be set, but more than one tag may be matched.
|
a tag to matching it. Only one tag may be set, but more than one tag may be matched.
|
||||||
The end address may be replaced by the keyword
|
The end address may be replaced by the keyword
|
||||||
.B static
|
.B static
|
||||||
@@ -463,8 +520,11 @@ subnet. (See
|
|||||||
and
|
and
|
||||||
.B pxe-service
|
.B pxe-service
|
||||||
for details.)
|
for details.)
|
||||||
|
|
||||||
|
The interface:<interface name> section is not normally used. See the
|
||||||
|
NOTES section for details of this.
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
||||||
Specify per host parameters for the DHCP server. This allows a machine
|
Specify per host parameters for the DHCP server. This allows a machine
|
||||||
with a particular hardware address to be always allocated the same
|
with a particular hardware address to be always allocated the same
|
||||||
hostname, IP address and lease time. A hostname specified like this
|
hostname, IP address and lease time. A hostname specified like this
|
||||||
@@ -479,9 +539,15 @@ an infinite DHCP lease.
|
|||||||
.B --dhcp-host=lap,192.168.0.199
|
.B --dhcp-host=lap,192.168.0.199
|
||||||
tells
|
tells
|
||||||
dnsmasq to always allocate the machine lap the IP address
|
dnsmasq to always allocate the machine lap the IP address
|
||||||
192.168.0.199. Addresses allocated like this are not constrained to be
|
192.168.0.199.
|
||||||
in the range given by the --dhcp-range option, but they must be on the
|
|
||||||
network being served by the DHCP server. It is allowed to use client identifiers rather than
|
Addresses allocated like this are not constrained to be
|
||||||
|
in the range given by the --dhcp-range option, but they must be in
|
||||||
|
the same subnet as some valid dhcp-range. For
|
||||||
|
subnets which don't need a pool of dynamically allocated addresses,
|
||||||
|
use the "static" keyword in the dhcp-range declaration.
|
||||||
|
|
||||||
|
It is allowed to use client identifiers rather than
|
||||||
hardware addresses to identify hosts by prefixing with 'id:'. Thus:
|
hardware addresses to identify hosts by prefixing with 'id:'. Thus:
|
||||||
.B --dhcp-host=id:01:02:03:04,.....
|
.B --dhcp-host=id:01:02:03:04,.....
|
||||||
refers to the host with client identifier 01:02:03:04. It is also
|
refers to the host with client identifier 01:02:03:04. It is also
|
||||||
@@ -495,7 +561,14 @@ but not others.
|
|||||||
If a name appears in /etc/hosts, the associated address can be
|
If a name appears in /etc/hosts, the associated address can be
|
||||||
allocated to a DHCP lease, but only if a
|
allocated to a DHCP lease, but only if a
|
||||||
.B --dhcp-host
|
.B --dhcp-host
|
||||||
option specifying the name also exists. The special keyword "ignore"
|
option specifying the name also exists. Only one hostname can be
|
||||||
|
given in a
|
||||||
|
.B dhcp-host
|
||||||
|
option, but aliases are possible by using CNAMEs. (See
|
||||||
|
.B --cname
|
||||||
|
).
|
||||||
|
|
||||||
|
The special keyword "ignore"
|
||||||
tells dnsmasq to never offer a DHCP lease to a machine. The machine
|
tells dnsmasq to never offer a DHCP lease to a machine. The machine
|
||||||
can be specified by hardware address, client ID or hostname, for
|
can be specified by hardware address, client ID or hostname, for
|
||||||
instance
|
instance
|
||||||
@@ -504,13 +577,15 @@ This is
|
|||||||
useful when there is another DHCP server on the network which should
|
useful when there is another DHCP server on the network which should
|
||||||
be used by some machines.
|
be used by some machines.
|
||||||
|
|
||||||
The net:<network-id> sets the network-id tag
|
The set:<tag> contruct sets the tag
|
||||||
whenever this dhcp-host directive is in use. This can be used to
|
whenever this dhcp-host directive is in use. This can be used to
|
||||||
selectively send DHCP options just for this host. When a host matches any
|
selectively send DHCP options just for this host. More than one tag
|
||||||
|
can be set in a dhcp-host directive (but not in other places where
|
||||||
|
"set:<tag>" is allowed). When a host matches any
|
||||||
dhcp-host directive (or one implied by /etc/ethers) then the special
|
dhcp-host directive (or one implied by /etc/ethers) then the special
|
||||||
network-id tag "known" is set. This allows dnsmasq to be configured to
|
tag "known" is set. This allows dnsmasq to be configured to
|
||||||
ignore requests from unknown machines using
|
ignore requests from unknown machines using
|
||||||
.B --dhcp-ignore=#known
|
.B --dhcp-ignore=tag:!known
|
||||||
Ethernet addresses (but not client-ids) may have
|
Ethernet addresses (but not client-ids) may have
|
||||||
wildcard bytes, so for example
|
wildcard bytes, so for example
|
||||||
.B --dhcp-host=00:20:e0:3b:13:*,ignore
|
.B --dhcp-host=00:20:e0:3b:13:*,ignore
|
||||||
@@ -538,15 +613,17 @@ time and there is no way for dnsmasq to enforce this. It is, for instance,
|
|||||||
useful to allocate a stable IP address to a laptop which
|
useful to allocate a stable IP address to a laptop which
|
||||||
has both wired and wireless interfaces.
|
has both wired and wireless interfaces.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-hostsfile=<file>
|
.B --dhcp-hostsfile=<path>
|
||||||
Read DHCP host information from the specified file. The file contains
|
Read DHCP host information from the specified file. If a directory
|
||||||
|
is given, then read all the files contained in that directory. The file contains
|
||||||
information about one host per line. The format of a line is the same
|
information about one host per line. The format of a line is the same
|
||||||
as text to the right of '=' in --dhcp-host. The advantage of storing DHCP host information
|
as text to the right of '=' in --dhcp-host. The advantage of storing DHCP host information
|
||||||
in this file is that it can be changed without re-starting dnsmasq:
|
in this file is that it can be changed without re-starting dnsmasq:
|
||||||
the file will be re-read when dnsmasq receives SIGHUP.
|
the file will be re-read when dnsmasq receives SIGHUP.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-optsfile=<file>
|
.B --dhcp-optsfile=<path>
|
||||||
Read DHCP option information from the specified file. The advantage of
|
Read DHCP option information from the specified file. If a directory
|
||||||
|
is given, then read all the files contained in that directory. The advantage of
|
||||||
using this option is the same as for --dhcp-hostsfile: the
|
using this option is the same as for --dhcp-hostsfile: the
|
||||||
dhcp-optsfile will be re-read when dnsmasq receives SIGHUP. Note that
|
dhcp-optsfile will be re-read when dnsmasq receives SIGHUP. Note that
|
||||||
it is possible to encode the information in a
|
it is possible to encode the information in a
|
||||||
@@ -564,7 +641,7 @@ have exactly the same effect as
|
|||||||
options containing the same information. /etc/ethers is re-read when
|
options containing the same information. /etc/ethers is re-read when
|
||||||
dnsmasq receives SIGHUP.
|
dnsmasq receives SIGHUP.
|
||||||
.TP
|
.TP
|
||||||
.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][encap:<opt>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
|
.B \-O, --dhcp-option=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
|
||||||
Specify different or extra options to DHCP clients. By default,
|
Specify different or extra options to DHCP clients. By default,
|
||||||
dnsmasq sends some standard options to DHCP clients, the netmask and
|
dnsmasq sends some standard options to DHCP clients, the netmask and
|
||||||
broadcast address are set to the same as the host running dnsmasq, and
|
broadcast address are set to the same as the host running dnsmasq, and
|
||||||
@@ -587,8 +664,8 @@ or
|
|||||||
The special address 0.0.0.0 is taken to mean "the address of the
|
The special address 0.0.0.0 is taken to mean "the address of the
|
||||||
machine running dnsmasq". Data types allowed are comma separated
|
machine running dnsmasq". Data types allowed are comma separated
|
||||||
dotted-quad IP addresses, a decimal number, colon-separated hex digits
|
dotted-quad IP addresses, a decimal number, colon-separated hex digits
|
||||||
and a text string. If the optional network-ids are given then
|
and a text string. If the optional tags are given then
|
||||||
this option is only sent when all the network-ids are matched.
|
this option is only sent when all the tags are matched.
|
||||||
|
|
||||||
Special processing is done on a text argument for option 119, to
|
Special processing is done on a text argument for option 119, to
|
||||||
conform with RFC 3397. Text or dotted-quad IP addresses as arguments
|
conform with RFC 3397. Text or dotted-quad IP addresses as arguments
|
||||||
@@ -632,10 +709,16 @@ options are given which are encapsulated with the same option number
|
|||||||
then they will be correctly combined into one encapsulated option.
|
then they will be correctly combined into one encapsulated option.
|
||||||
encap: and vendor: are may not both be set in the same dhcp-option.
|
encap: and vendor: are may not both be set in the same dhcp-option.
|
||||||
|
|
||||||
|
The final variant on encapsulated options is "Vendor-Identifying
|
||||||
|
Vendor Options" as specified by RFC3925. These are denoted like this:
|
||||||
|
.B --dhcp-option=vi-encap:2, 10, "text"
|
||||||
|
The number in the vi-encap: section is the IANA enterprise number
|
||||||
|
used to identify this option.
|
||||||
|
|
||||||
The address 0.0.0.0 is not treated specially in
|
The address 0.0.0.0 is not treated specially in
|
||||||
encapsulated options.
|
encapsulated options.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-option-force=[<network-id>,[<network-id>,]][encap:<opt>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
|
.B --dhcp-option-force=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
|
||||||
This works in exactly the same way as
|
This works in exactly the same way as
|
||||||
.B --dhcp-option
|
.B --dhcp-option
|
||||||
except that the option will always be sent, even if the client does
|
except that the option will always be sent, even if the client does
|
||||||
@@ -650,20 +733,20 @@ DHCP options. This make extra space available in the DHCP packet for
|
|||||||
options but can, rarely, confuse old or broken clients. This flag
|
options but can, rarely, confuse old or broken clients. This flag
|
||||||
forces "simple and safe" behaviour to avoid problems in such a case.
|
forces "simple and safe" behaviour to avoid problems in such a case.
|
||||||
.TP
|
.TP
|
||||||
.B \-U, --dhcp-vendorclass=<network-id>,<vendor-class>
|
.B \-U, --dhcp-vendorclass=set:<tag>,<vendor-class>
|
||||||
Map from a vendor-class string to a network id tag. Most DHCP clients provide a
|
Map from a vendor-class string to a tag. Most DHCP clients provide a
|
||||||
"vendor class" which represents, in some sense, the type of host. This option
|
"vendor class" which represents, in some sense, the type of host. This option
|
||||||
maps vendor classes to tags, so that DHCP options may be selectively delivered
|
maps vendor classes to tags, so that DHCP options may be selectively delivered
|
||||||
to different classes of hosts. For example
|
to different classes of hosts. For example
|
||||||
.B dhcp-vendorclass=printers,Hewlett-Packard JetDirect
|
.B dhcp-vendorclass=set:printers,Hewlett-Packard JetDirect
|
||||||
will allow options to be set only for HP printers like so:
|
will allow options to be set only for HP printers like so:
|
||||||
.B --dhcp-option=printers,3,192.168.4.4
|
.B --dhcp-option=tag:printers,3,192.168.4.4
|
||||||
The vendor-class string is
|
The vendor-class string is
|
||||||
substring matched against the vendor-class supplied by the client, to
|
substring matched against the vendor-class supplied by the client, to
|
||||||
allow fuzzy matching.
|
allow fuzzy matching. The set: prefix is optional but allowed for consistency.
|
||||||
.TP
|
.TP
|
||||||
.B \-j, --dhcp-userclass=<network-id>,<user-class>
|
.B \-j, --dhcp-userclass=set:<tag>,<user-class>
|
||||||
Map from a user-class string to a network id tag (with substring
|
Map from a user-class string to a tag (with substring
|
||||||
matching, like vendor classes). Most DHCP clients provide a
|
matching, like vendor classes). Most DHCP clients provide a
|
||||||
"user class" which is configurable. This option
|
"user class" which is configurable. This option
|
||||||
maps user classes to tags, so that DHCP options may be selectively delivered
|
maps user classes to tags, so that DHCP options may be selectively delivered
|
||||||
@@ -671,24 +754,41 @@ to different classes of hosts. It is possible, for instance to use
|
|||||||
this to set a different printer server for hosts in the class
|
this to set a different printer server for hosts in the class
|
||||||
"accounts" than for hosts in the class "engineering".
|
"accounts" than for hosts in the class "engineering".
|
||||||
.TP
|
.TP
|
||||||
.B \-4, --dhcp-mac=<network-id>,<MAC address>
|
.B \-4, --dhcp-mac=set:<tag>,<MAC address>
|
||||||
Map from a MAC address to a network-id tag. The MAC address may include
|
Map from a MAC address to a tag. The MAC address may include
|
||||||
wildcards. For example
|
wildcards. For example
|
||||||
.B --dhcp-mac=3com,01:34:23:*:*:*
|
.B --dhcp-mac=set:3com,01:34:23:*:*:*
|
||||||
will set the tag "3com" for any host whose MAC address matches the pattern.
|
will set the tag "3com" for any host whose MAC address matches the pattern.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-circuitid=<network-id>,<circuit-id>, --dhcp-remoteid=<network-id>,<remote-id>
|
.B --dhcp-circuitid=set:<tag>,<circuit-id>, --dhcp-remoteid=set:<tag>,<remote-id>
|
||||||
Map from RFC3046 relay agent options to network-id tags. This data may
|
Map from RFC3046 relay agent options to tags. This data may
|
||||||
be provided by DHCP relay agents. The circuit-id or remote-id is
|
be provided by DHCP relay agents. The circuit-id or remote-id is
|
||||||
normally given as colon-separated hex, but is also allowed to be a
|
normally given as colon-separated hex, but is also allowed to be a
|
||||||
simple string. If an exact match is achieved between the circuit or
|
simple string. If an exact match is achieved between the circuit or
|
||||||
agent ID and one provided by a relay agent, the network-id tag is set.
|
agent ID and one provided by a relay agent, the tag is set.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-subscrid=<network-id>,<subscriber-id>
|
.B --dhcp-subscrid=set:<tag>,<subscriber-id>
|
||||||
Map from RFC3993 subscriber-id relay agent options to network-id tags.
|
Map from RFC3993 subscriber-id relay agent options to tags.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-match=<network-id>,<option number>|option:<option name>[,<value>]
|
.B --dhcp-proxy[=<ip addr>]......
|
||||||
Without a value, set the network-id tag if the client sends a DHCP
|
A normal DHCP relay agent is only used to forward the initial parts of
|
||||||
|
a DHCP interaction to the DHCP server. Once a client is configured, it
|
||||||
|
communicates directly with the server. This is undesirable if the
|
||||||
|
relay agent is addding extra information to the DHCP packets, such as
|
||||||
|
that used by
|
||||||
|
.B dhcp-circuitid
|
||||||
|
and
|
||||||
|
.B dhcp-remoteid.
|
||||||
|
A full relay implementation can use the RFC 5107 serverid-override
|
||||||
|
option to force the DHCP server to use the relay as a full proxy, with all
|
||||||
|
packets passing through it. This flag provides an alternative method
|
||||||
|
of doing the same thing, for relays which don't support RFC
|
||||||
|
5107. Given alone, it manipulates the server-id for all interactions
|
||||||
|
via relays. If a list of IP addresses is given, only interactions via
|
||||||
|
relays at those addresses are affected.
|
||||||
|
.TP
|
||||||
|
.B --dhcp-match=set:<tag>,<option number>|option:<option name>|vi-encap:<enterprise>[,<value>]
|
||||||
|
Without a value, set the tag if the client sends a DHCP
|
||||||
option of the given number or name. When a value is given, set the tag only if
|
option of the given number or name. When a value is given, set the tag only if
|
||||||
the option is sent and matches the value. The value may be of the form
|
the option is sent and matches the value. The value may be of the form
|
||||||
"01:ff:*:02" in which case the value must match (apart from widcards)
|
"01:ff:*:02" in which case the value must match (apart from widcards)
|
||||||
@@ -698,45 +798,64 @@ value. The value may also be of the same form as in
|
|||||||
in which case the option sent is treated as an array, and one element
|
in which case the option sent is treated as an array, and one element
|
||||||
must match, so
|
must match, so
|
||||||
|
|
||||||
--dhcp-match=efi-ia32,option:client-arch,6
|
--dhcp-match=set:efi-ia32,option:client-arch,6
|
||||||
|
|
||||||
will set the tag "efi-ia32" if the the number 6 appears in the list of
|
will set the tag "efi-ia32" if the the number 6 appears in the list of
|
||||||
architectures sent by the client in option 93. (See RFC 4578 for
|
architectures sent by the client in option 93. (See RFC 4578 for
|
||||||
details.) If the value is a string, substring matching is used.
|
details.) If the value is a string, substring matching is used.
|
||||||
|
|
||||||
|
The special form with vi-encap:<enterpise number> matches against
|
||||||
|
vendor-identifying vendor classes for the specified enterprise. Please
|
||||||
|
see RFC 3925 for more details of these rare and interesting beasts.
|
||||||
.TP
|
.TP
|
||||||
.B \-J, --dhcp-ignore=<network-id>[,<network-id>]
|
.B --tag-if=set:<tag>[,set:<tag>[,tag:<tag>[,tag:<tag>]]]
|
||||||
When all the given network-ids match the set of network-ids derived
|
Perform boolean operations on tags. Any tag appearing as set:<tag> is set if
|
||||||
from the net, host, vendor and user classes, ignore the host and do
|
all the tags which appear as tag:<tag> are set, (or unset when tag:!<tag> is used)
|
||||||
|
If no tag:<tag> appears set:<tag> tags are set unconditionally.
|
||||||
|
Any number of set: and tag: forms may appear, in any order.
|
||||||
|
Tag-if lines ares executed in order, so if the tag in tag:<tag> is a
|
||||||
|
tag set by another
|
||||||
|
.B tag-if,
|
||||||
|
the line which sets the tag must precede the one which tests it.
|
||||||
|
.TP
|
||||||
|
.B \-J, --dhcp-ignore=tag:<tag>[,tag:<tag>]
|
||||||
|
When all the given tags appear in the tag set ignore the host and do
|
||||||
not allocate it a DHCP lease.
|
not allocate it a DHCP lease.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-ignore-names[=<network-id>[,<network-id>]]
|
.B --dhcp-ignore-names[=tag:<tag>[,tag:<tag>]]
|
||||||
When all the given network-ids match the set of network-ids derived
|
When all the given tags appear in the tag set, ignore any hostname
|
||||||
from the net, host, vendor and user classes, ignore any hostname
|
|
||||||
provided by the host. Note that, unlike dhcp-ignore, it is permissible
|
provided by the host. Note that, unlike dhcp-ignore, it is permissible
|
||||||
to supply no netid tags, in which case DHCP-client supplied hostnames
|
to supply no tags, in which case DHCP-client supplied hostnames
|
||||||
are always ignored, and DHCP hosts are added to the DNS using only
|
are always ignored, and DHCP hosts are added to the DNS using only
|
||||||
dhcp-host configuration in dnsmasq and the contents of /etc/hosts and
|
dhcp-host configuration in dnsmasq and the contents of /etc/hosts and
|
||||||
/etc/ethers.
|
/etc/ethers.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-broadcast=<network-id>[,<network-id>]
|
.B --dhcp-generate-names=tag:<tag>[,tag:<tag>]
|
||||||
When all the given network-ids match the set of network-ids derived
|
Generate a name for DHCP clients which do not otherwise have one,
|
||||||
from the net, host, vendor and user classes, always use broadcast to
|
using the MAC address expressed in hex, seperated by dashes. Note that
|
||||||
communicate with the host when it is unconfigured. Most DHCP clients which
|
if a host provides a name, it will be used by preference to this,
|
||||||
|
unless
|
||||||
|
.B --dhcp-ignore-names
|
||||||
|
is set.
|
||||||
|
.TP
|
||||||
|
.B --dhcp-broadcast[=tag:<tag>[,tag:<tag>]]
|
||||||
|
When all the given tags appear in the tag set, always use broadcast to
|
||||||
|
communicate with the host when it is unconfigured. It is permissible
|
||||||
|
to supply no tags, in which case this is unconditional. Most DHCP clients which
|
||||||
need broadcast replies set a flag in their requests so that this
|
need broadcast replies set a flag in their requests so that this
|
||||||
happens automatically, some old BOOTP clients do not.
|
happens automatically, some old BOOTP clients do not.
|
||||||
.TP
|
.TP
|
||||||
.B \-M, --dhcp-boot=[net:<network-id>,]<filename>,[<servername>[,<server address>]]
|
.B \-M, --dhcp-boot=[tag:<tag>,]<filename>,[<servername>[,<server address>]]
|
||||||
Set BOOTP options to be returned by the DHCP server. Server name and
|
Set BOOTP options to be returned by the DHCP server. Server name and
|
||||||
address are optional: if not provided, the name is left empty, and the
|
address are optional: if not provided, the name is left empty, and the
|
||||||
address set to the address of the machine running dnsmasq. If dnsmasq
|
address set to the address of the machine running dnsmasq. If dnsmasq
|
||||||
is providing a TFTP service (see
|
is providing a TFTP service (see
|
||||||
.B --enable-tftp
|
.B --enable-tftp
|
||||||
) then only the filename is required here to enable network booting.
|
) then only the filename is required here to enable network booting.
|
||||||
If the optional network-id(s) are given,
|
If the optional tag(s) are given,
|
||||||
they must match for this configuration to be sent. Note that
|
they must match for this configuration to be sent.
|
||||||
network-ids are prefixed by "net:" to distinguish them.
|
|
||||||
.TP
|
.TP
|
||||||
.B --pxe-service=[net:<network-id>,]<CSA>,<menu text>,<basename>|<bootservicetype>[,<server address>]
|
.B --pxe-service=[tag:<tag>,]<CSA>,<menu text>[,<basename>|<bootservicetype>][,<server address>]
|
||||||
Most uses of PXE boot-ROMS simply allow the PXE
|
Most uses of PXE boot-ROMS simply allow the PXE
|
||||||
system to obtain an IP address and then download the file specified by
|
system to obtain an IP address and then download the file specified by
|
||||||
.B dhcp-boot
|
.B dhcp-boot
|
||||||
@@ -759,11 +878,12 @@ suffix (normally ".0") is supplied by PXE, and should not be added to
|
|||||||
the basename. If an integer boot service type, rather than a basename
|
the basename. If an integer boot service type, rather than a basename
|
||||||
is given, then the PXE client will search for a
|
is given, then the PXE client will search for a
|
||||||
suitable boot service for that type on the network. This search may be done
|
suitable boot service for that type on the network. This search may be done
|
||||||
by multicast or broadcast, or direct to a server if its IP address is provided. A boot service
|
by broadcast, or direct to a server if its IP address is provided.
|
||||||
type of 0 is special, and will abort the net boot procedure and
|
If no boot service type or filename is provided (or a boot service type of 0 is specified)
|
||||||
|
then the menu entry will abort the net boot procedure and
|
||||||
continue booting from local media.
|
continue booting from local media.
|
||||||
.TP
|
.TP
|
||||||
.B --pxe-prompt=[net:<network-id>,]<prompt>[,<timeout>]
|
.B --pxe-prompt=[tag:<tag>,]<prompt>[,<timeout>]
|
||||||
Setting this provides a prompt to be displayed after PXE boot. If the
|
Setting this provides a prompt to be displayed after PXE boot. If the
|
||||||
timeout is given then after the
|
timeout is given then after the
|
||||||
timeout has elapsed with no keyboard input, the first available menu
|
timeout has elapsed with no keyboard input, the first available menu
|
||||||
@@ -789,7 +909,7 @@ keyword in
|
|||||||
.TP
|
.TP
|
||||||
.B \-X, --dhcp-lease-max=<number>
|
.B \-X, --dhcp-lease-max=<number>
|
||||||
Limits dnsmasq to the specified maximum number of DHCP leases. The
|
Limits dnsmasq to the specified maximum number of DHCP leases. The
|
||||||
default is 150. This limit is to prevent DoS attacks from hosts which
|
default is 1000. This limit is to prevent DoS attacks from hosts which
|
||||||
create thousands of leases and use lots of memory in the dnsmasq
|
create thousands of leases and use lots of memory in the dnsmasq
|
||||||
process.
|
process.
|
||||||
.TP
|
.TP
|
||||||
@@ -826,14 +946,16 @@ tried. This flag disables this check. Use with caution.
|
|||||||
.TP
|
.TP
|
||||||
.B --log-dhcp
|
.B --log-dhcp
|
||||||
Extra logging for DHCP: log all the options sent to DHCP clients and
|
Extra logging for DHCP: log all the options sent to DHCP clients and
|
||||||
the netid tags used to determine them.
|
the tags used to determine them.
|
||||||
.TP
|
.TP
|
||||||
.B \-l, --dhcp-leasefile=<path>
|
.B \-l, --dhcp-leasefile=<path>
|
||||||
Use the specified file to store DHCP lease information.
|
Use the specified file to store DHCP lease information.
|
||||||
.TP
|
.TP
|
||||||
.B \-6 --dhcp-script=<path>
|
.B \-6 --dhcp-script=<path>
|
||||||
Whenever a new DHCP lease is created, or an old one destroyed, the
|
Whenever a new DHCP lease is created, or an old one destroyed, the
|
||||||
executable specified by this option is run. The arguments to the process
|
executable specified by this option is run. <path>
|
||||||
|
must be an absolute pathname, no PATH search occurs.
|
||||||
|
The arguments to the process
|
||||||
are "add", "old" or "del", the MAC
|
are "add", "old" or "del", the MAC
|
||||||
address of the host, the IP address, and the hostname,
|
address of the host, the IP address, and the hostname,
|
||||||
if known. "add" means a lease has been created, "del" means it has
|
if known. "add" means a lease has been created, "del" means it has
|
||||||
@@ -844,37 +966,62 @@ If the MAC address is from a network type other than ethernet,
|
|||||||
it will have the network type prepended, eg "06-01:23:45:67:89:ab" for
|
it will have the network type prepended, eg "06-01:23:45:67:89:ab" for
|
||||||
token ring. The process is run as root (assuming that dnsmasq was originally run as
|
token ring. The process is run as root (assuming that dnsmasq was originally run as
|
||||||
root) even if dnsmasq is configured to change UID to an unprivileged user.
|
root) even if dnsmasq is configured to change UID to an unprivileged user.
|
||||||
The environment is inherited from the invoker of dnsmasq, and if the
|
|
||||||
host provided a client-id, this is stored in the environment variable
|
The environment is inherited from the invoker of dnsmasq, with some or
|
||||||
DNSMASQ_CLIENT_ID. If the fully-qualified domain name of the host is
|
all of the following variables added.
|
||||||
known, the domain part is stored in DNSMASQ_DOMAIN.
|
|
||||||
If the client provides vendor-class, hostname or user-class,
|
DNSMASQ_CLIENT_ID if the host provided a client-id.
|
||||||
these are provided in DNSMASQ_VENDOR_CLASS
|
|
||||||
|
DNSMASQ_DOMAIN if the fully-qualified domain name of the host is
|
||||||
|
known, this is set to the domain part. (Note that the hostname passed
|
||||||
|
to the script as an argument is never fully-qualified.)
|
||||||
|
|
||||||
|
If the client provides vendor-class, hostname or user-class,
|
||||||
|
these are provided in DNSMASQ_VENDOR_CLASS
|
||||||
DNSMASQ_SUPPLIED_HOSTNAME and
|
DNSMASQ_SUPPLIED_HOSTNAME and
|
||||||
DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for
|
DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for
|
||||||
"add" actions or "old" actions when a host resumes an existing lease,
|
"add" actions or "old" actions when a host resumes an existing lease,
|
||||||
since these data are not held in dnsmasq's lease
|
since these data are not held in dnsmasq's lease
|
||||||
database. If dnsmasq was compiled with HAVE_BROKEN_RTC, then
|
database.
|
||||||
|
|
||||||
|
If dnsmasq was compiled with HAVE_BROKEN_RTC, then
|
||||||
the length of the lease (in seconds) is stored in
|
the length of the lease (in seconds) is stored in
|
||||||
DNSMASQ_LEASE_LENGTH, otherwise the time of lease expiry is stored in
|
DNSMASQ_LEASE_LENGTH, otherwise the time of lease expiry is stored in
|
||||||
DNSMASQ_LEASE_EXPIRES. The number of seconds until lease expiry is
|
DNSMASQ_LEASE_EXPIRES. The number of seconds until lease expiry is
|
||||||
always stored in DNSMASQ_TIME_REMAINING.
|
always stored in DNSMASQ_TIME_REMAINING.
|
||||||
|
|
||||||
If a lease used to have a hostname, which is
|
If a lease used to have a hostname, which is
|
||||||
removed, an "old" event is generated with the new state of the lease,
|
removed, an "old" event is generated with the new state of the lease,
|
||||||
ie no name, and the former name is provided in the environment
|
ie no name, and the former name is provided in the environment
|
||||||
variable DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE stores the name of
|
variable DNSMASQ_OLD_HOSTNAME.
|
||||||
|
|
||||||
|
DNSMASQ_INTERFACE stores the name of
|
||||||
the interface on which the request arrived; this is not set for "old"
|
the interface on which the request arrived; this is not set for "old"
|
||||||
actions when dnsmasq restarts. DNSMASQ_RELAY_ADDRESS is set if the client
|
actions when dnsmasq restarts.
|
||||||
used a DHCP relay to contact dnsmasq and the IP address of the relay is known.
|
|
||||||
|
DNSMASQ_RELAY_ADDRESS is set if the client
|
||||||
|
used a DHCP relay to contact dnsmasq and the IP address of the relay
|
||||||
|
is known.
|
||||||
|
|
||||||
|
DNSMASQ_TAGS contains all the tags set during the
|
||||||
|
DHCP transaction, separated by spaces.
|
||||||
|
|
||||||
All file descriptors are
|
All file descriptors are
|
||||||
closed except stdin, stdout and stderr which are open to /dev/null
|
closed except stdin, stdout and stderr which are open to /dev/null
|
||||||
(except in debug mode).
|
(except in debug mode).
|
||||||
The script is not invoked concurrently: if subsequent lease
|
|
||||||
changes occur, the script is not invoked again until any existing
|
The script is not invoked concurrently: at most one instance
|
||||||
invocation exits. At dnsmasq startup, the script will be invoked for
|
of the script is ever running (dnsmasq waits for an instance of script to exit
|
||||||
|
before running the next). Changes to the lease database are which
|
||||||
|
require the script to be invoked are queued awaiting exit of a running instance.
|
||||||
|
If this queueing allows multiple state changes occur to a single
|
||||||
|
lease before the script can be run then
|
||||||
|
earlier states are discarded and the current state of that lease is
|
||||||
|
reflected when the script finally runs.
|
||||||
|
|
||||||
|
At dnsmasq startup, the script will be invoked for
|
||||||
all existing leases as they are read from the lease file. Expired
|
all existing leases as they are read from the lease file. Expired
|
||||||
leases will be called with "del" and others with "old". <path>
|
leases will be called with "del" and others with "old". When dnsmasq
|
||||||
must be an absolute pathname, no PATH search occurs. When dnsmasq
|
|
||||||
receives a HUP signal, the script will be invoked for existing leases
|
receives a HUP signal, the script will be invoked for existing leases
|
||||||
with an "old " event.
|
with an "old " event.
|
||||||
.TP
|
.TP
|
||||||
@@ -901,7 +1048,7 @@ as if they had arrived at <interface>. This option is necessary when
|
|||||||
using "old style" bridging on BSD platforms, since
|
using "old style" bridging on BSD platforms, since
|
||||||
packets arrive at tap interfaces which don't have an IP address.
|
packets arrive at tap interfaces which don't have an IP address.
|
||||||
.TP
|
.TP
|
||||||
.B \-s, --domain=<domain>[,<address range>]
|
.B \-s, --domain=<domain>[,<address range>[,local]]
|
||||||
Specifies DNS domains for the DHCP server. Domains may be be given
|
Specifies DNS domains for the DHCP server. Domains may be be given
|
||||||
unconditionally (without the IP range) or for limited IP ranges. This has two effects;
|
unconditionally (without the IP range) or for limited IP ranges. This has two effects;
|
||||||
firstly it causes the DHCP server to return the domain to any hosts
|
firstly it causes the DHCP server to return the domain to any hosts
|
||||||
@@ -920,11 +1067,22 @@ and have a machine whose DHCP hostname is "laptop". The IP address for that mach
|
|||||||
.B dnsmasq
|
.B dnsmasq
|
||||||
both as "laptop" and "laptop.thekelleys.org.uk". If the domain is
|
both as "laptop" and "laptop.thekelleys.org.uk". If the domain is
|
||||||
given as "#" then the domain is read from the first "search" directive
|
given as "#" then the domain is read from the first "search" directive
|
||||||
in /etc/resolv.conf (or equivalent). The address range can be of the form
|
in /etc/resolv.conf (or equivalent).
|
||||||
|
|
||||||
|
The address range can be of the form
|
||||||
<ip address>,<ip address> or <ip address>/<netmask> or just a single
|
<ip address>,<ip address> or <ip address>/<netmask> or just a single
|
||||||
<ip address>. See
|
<ip address>. See
|
||||||
.B --dhcp-fqdn
|
.B --dhcp-fqdn
|
||||||
which can change the behaviour of dnsmasq with domains.
|
which can change the behaviour of dnsmasq with domains.
|
||||||
|
|
||||||
|
If the address range is given as ip-address/network-size, then a
|
||||||
|
additional flag "local" may be supplied which has the effect of adding
|
||||||
|
--local declarations for forward and reverse DNS queries. Eg.
|
||||||
|
.B --domain=thekelleys.org.uk,192.168.0.0/24,local
|
||||||
|
is identical to
|
||||||
|
.B --domain=thekelleys.org.uk,192.168.0.0/24
|
||||||
|
--local=/thekelleys.org.uk/ --local=/0.168.192.in-addr.arpa/
|
||||||
|
The network size must be 8, 16 or 24 for this to be legal.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-fqdn
|
.B --dhcp-fqdn
|
||||||
In the default mode, dnsmasq inserts the unqualified names of
|
In the default mode, dnsmasq inserts the unqualified names of
|
||||||
@@ -943,17 +1101,20 @@ without an address specified when
|
|||||||
.B --dhcp-fqdn
|
.B --dhcp-fqdn
|
||||||
is set.
|
is set.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp
|
.B --enable-tftp[=<interface>]
|
||||||
Enable the TFTP server function. This is deliberately limited to that
|
Enable the TFTP server function. This is deliberately limited to that
|
||||||
needed to net-boot a client. Only reading is allowed; the tsize and
|
needed to net-boot a client. Only reading is allowed; the tsize and
|
||||||
blksize extensions are supported (tsize is only supported in octet mode).
|
blksize extensions are supported (tsize is only supported in octet
|
||||||
|
mode). See NOTES section for use of the interface argument.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-root=<directory>
|
.B --tftp-root=<directory>[,<interface>]
|
||||||
Look for files to transfer using TFTP relative to the given
|
Look for files to transfer using TFTP relative to the given
|
||||||
directory. When this is set, TFTP paths which include ".." are
|
directory. When this is set, TFTP paths which include ".." are
|
||||||
rejected, to stop clients getting outside the specified root.
|
rejected, to stop clients getting outside the specified root.
|
||||||
Absolute paths (starting with /) are allowed, but they must be within
|
Absolute paths (starting with /) are allowed, but they must be within
|
||||||
the tftp-root.
|
the tftp-root. If the optional interface argument is given, the
|
||||||
|
directory is only used for TFTP requests via that interface.
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-unique-root
|
.B --tftp-unique-root
|
||||||
Add the IP address of the TFTP client as a path component on the end
|
Add the IP address of the TFTP client as a path component on the end
|
||||||
@@ -1001,7 +1162,8 @@ of concurrent TFTP connections is limited by the size of the port range.
|
|||||||
.TP
|
.TP
|
||||||
.B \-C, --conf-file=<file>
|
.B \-C, --conf-file=<file>
|
||||||
Specify a different configuration file. The conf-file option is also allowed in
|
Specify a different configuration file. The conf-file option is also allowed in
|
||||||
configuration files, to include multiple configuration files.
|
configuration files, to include multiple configuration files. A
|
||||||
|
filename of "-" causes dnsmasq to read configuration from stdin.
|
||||||
.TP
|
.TP
|
||||||
.B \-7, --conf-dir=<directory>[,<file-extension>......]
|
.B \-7, --conf-dir=<directory>[,<file-extension>......]
|
||||||
Read all the files in the given directory as configuration
|
Read all the files in the given directory as configuration
|
||||||
@@ -1140,31 +1302,41 @@ the CNAME. To work around this, add the CNAME to /etc/hosts so that
|
|||||||
the CNAME is shadowed too.
|
the CNAME is shadowed too.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
The network-id system works as follows: For each DHCP request, dnsmasq
|
The tag system works as follows: For each DHCP request, dnsmasq
|
||||||
collects a set of valid network-id tags, one from the
|
collects a set of valid tags from active configuration lines which
|
||||||
|
include set:<tag>, including one from the
|
||||||
.B dhcp-range
|
.B dhcp-range
|
||||||
used to allocate the address, one from any matching
|
used to allocate the address, one from any matching
|
||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
(and "known" if a dhcp-host matches)
|
(and "known" if a dhcp-host matches)
|
||||||
the tag "bootp" for BOOTP requests, a tag whose name is the
|
The tag "bootp" is set for BOOTP requests, and a tag whose name is the
|
||||||
name if the interface on which the request arrived,
|
name of the interface on which the request arrived is also set.
|
||||||
and possibly many from matching vendor classes and user
|
|
||||||
classes sent by the DHCP client. Any
|
Any configuration lines which includes one or more tag:<tag> contructs
|
||||||
|
will only be valid if all that tags are matched in the set derived
|
||||||
|
above. Typically this is dhcp-option.
|
||||||
.B dhcp-option
|
.B dhcp-option
|
||||||
which has network-id tags will be used in preference to an untagged
|
which has tags will be used in preference to an untagged
|
||||||
.B dhcp-option,
|
.B dhcp-option,
|
||||||
provided that _all_ the tags match somewhere in the
|
provided that _all_ the tags match somewhere in the
|
||||||
set collected as described above. The prefix '#' on a tag means 'not'
|
set collected as described above. The prefix '!' on a tag means 'not'
|
||||||
so --dhcp=option=#purple,3,1.2.3.4 sends the option when the
|
so --dhcp=option=tag:!purple,3,1.2.3.4 sends the option when the
|
||||||
network-id tag purple is not in the set of valid tags.
|
tag purple is not in the set of valid tags. (If using this in a
|
||||||
|
command line rather than a configuration file, be sure to escape !,
|
||||||
|
which is a shell metacharacter)
|
||||||
.PP
|
.PP
|
||||||
If the network-id in a
|
Note that for
|
||||||
.B dhcp-range
|
.B dhcp-range
|
||||||
is prefixed with 'net:' then its meaning changes from setting a
|
both tag:<tag> and set:<tag> are allowed, to both select the range in
|
||||||
tag to matching it. Thus if there is more than dhcp-range on a subnet,
|
use based on (eg) dhcp-host, and to affect the options sent, based on
|
||||||
and one is tagged with a network-id which is set (for instance
|
the range selected.
|
||||||
from a vendorclass option) then hosts which set the netid tag will be
|
|
||||||
allocated addresses in the tagged range.
|
This system evolved from an earlier, more limited one and for backward
|
||||||
|
compatibility "net:" may be used instead of "tag:" and "set:" may be
|
||||||
|
omitted. (Except in
|
||||||
|
.B dhcp-host,
|
||||||
|
where "net:" may be used instead of "set:".) For the same reason, '#'
|
||||||
|
may be used instead of '!' to indicate NOT.
|
||||||
.PP
|
.PP
|
||||||
The DHCP server in dnsmasq will function as a BOOTP server also,
|
The DHCP server in dnsmasq will function as a BOOTP server also,
|
||||||
provided that the MAC address and IP address for clients are given,
|
provided that the MAC address and IP address for clients are given,
|
||||||
@@ -1177,11 +1349,56 @@ configurations or in
|
|||||||
configuration option is present to activate the DHCP server
|
configuration option is present to activate the DHCP server
|
||||||
on a particular network. (Setting --bootp-dynamic removes the need for
|
on a particular network. (Setting --bootp-dynamic removes the need for
|
||||||
static address mappings.) The filename
|
static address mappings.) The filename
|
||||||
parameter in a BOOTP request is matched against netids in
|
parameter in a BOOTP request is used as a tag,
|
||||||
.B dhcp-option
|
as is the tag "bootp", allowing some control over the options returned to
|
||||||
configurations, as is the tag "bootp", allowing some control over the options returned to
|
|
||||||
different classes of hosts.
|
different classes of hosts.
|
||||||
|
|
||||||
|
.B dhcp-range
|
||||||
|
may have an interface name supplied as
|
||||||
|
"interface:<interface-name>". The semantics if this are as follows:
|
||||||
|
For DHCP, if any other dhcp-range exists _without_ an interface name,
|
||||||
|
then the interface name is ignored and and dnsmasq behaves as if the
|
||||||
|
interface parts did not exist, otherwise DHCP is only provided to
|
||||||
|
interfaces mentioned in dhcp-range
|
||||||
|
declarations. For DNS, if there are no
|
||||||
|
.B --interface
|
||||||
|
or
|
||||||
|
.B --listen-address
|
||||||
|
flags, behaviour is unchanged by the interface part. If either of
|
||||||
|
these flags are present, the interfaces mentioned in
|
||||||
|
dhcp-ranges are added to the set which get DNS service.
|
||||||
|
|
||||||
|
Similarly,
|
||||||
|
.B enable-tftp
|
||||||
|
may take an interface name, which enables TFTP only for a particular
|
||||||
|
interface, ignoring
|
||||||
|
.B --interface
|
||||||
|
or
|
||||||
|
.B --listen-address
|
||||||
|
flags. In addition
|
||||||
|
.B --tftp-secure
|
||||||
|
and
|
||||||
|
.B --tftp-unique-root
|
||||||
|
and
|
||||||
|
.B --tftp-no-blocksize
|
||||||
|
are ignored for requests from such interfaces. (A
|
||||||
|
.B --tftp-root
|
||||||
|
directive giving a root path and an interface should be
|
||||||
|
provided too.)
|
||||||
|
|
||||||
|
These rules may seem odd at first sight, but they
|
||||||
|
allow a single line of the form "dhcp-range=interface:virt0,192.168.0.4,192.168.0.200"
|
||||||
|
to be added to dnsmasq configuration which then supplies
|
||||||
|
DHCP and DNS services to that interface, without affecting
|
||||||
|
what services are supplied to other interfaces and irrespective of
|
||||||
|
the existance or lack of "interface=<interface>"
|
||||||
|
lines elsewhere in the dnsmasq configuration.
|
||||||
|
"enable-tftp=virt0" and "tftp-root=<root>,virt0" do the same job for TFTP.
|
||||||
|
The idea is
|
||||||
|
that such a line can be added automatically by libvirt
|
||||||
|
or equivalent systems, without disturbing any manual
|
||||||
|
configuration.
|
||||||
|
|
||||||
.SH EXIT CODES
|
.SH EXIT CODES
|
||||||
.PP
|
.PP
|
||||||
0 - Dnsmasq successfully forked into the background, or terminated
|
0 - Dnsmasq successfully forked into the background, or terminated
|
||||||
@@ -1212,10 +1429,7 @@ following applies to dnsmasq-2.37: earlier versions did not scale as well.
|
|||||||
|
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq is capable of handling DNS and DHCP for at least a thousand
|
Dnsmasq is capable of handling DNS and DHCP for at least a thousand
|
||||||
clients. Clearly to do this the value of
|
clients. The DHCP lease times should not be very short (less than one hour). The
|
||||||
.B --dhcp-lease-max
|
|
||||||
must be increased,
|
|
||||||
and lease times should not be very short (less than one hour). The
|
|
||||||
value of
|
value of
|
||||||
.B --dns-forward-max
|
.B --dns-forward-max
|
||||||
can be increased: start with it equal to
|
can be increased: start with it equal to
|
||||||
@@ -1271,6 +1485,9 @@ assume that it is the system default.
|
|||||||
.IR /usr/local/etc/dnsmasq.conf
|
.IR /usr/local/etc/dnsmasq.conf
|
||||||
|
|
||||||
.IR /etc/resolv.conf
|
.IR /etc/resolv.conf
|
||||||
|
.IR /var/run/dnsmasq/resolv.conf
|
||||||
|
.IR /etc/ppp/resolv.conf
|
||||||
|
.IR /etc/dhcpc/resolv.conf
|
||||||
|
|
||||||
.IR /etc/hosts
|
.IR /etc/hosts
|
||||||
|
|
||||||
|
|||||||
+327
-120
@@ -49,7 +49,8 @@ ese directorio.
|
|||||||
.TP
|
.TP
|
||||||
.B \-E, --expand-hosts
|
.B \-E, --expand-hosts
|
||||||
Agregar el dominio a nombres sencillos (sin punto) en /etc/hosts de la
|
Agregar el dominio a nombres sencillos (sin punto) en /etc/hosts de la
|
||||||
misma manera que con nombres derivados de DHCP.
|
misma manera que con nombres derivados de DHCP. Nótese que esto no
|
||||||
|
aplica a nombres de dominio en cnames, expedientes PTR, TXT, etc.
|
||||||
.TP
|
.TP
|
||||||
.B \-T, --local-ttl=<tiempo>
|
.B \-T, --local-ttl=<tiempo>
|
||||||
Al responder con información desde /etc/hosts o desde el archivo
|
Al responder con información desde /etc/hosts o desde el archivo
|
||||||
@@ -67,8 +68,14 @@ informaci
|
|||||||
dnsmasq usa para hacer caché. Si las respuestas de servidores upstream
|
dnsmasq usa para hacer caché. Si las respuestas de servidores upstream
|
||||||
omiten esta información, dnsmasq no mete la respuesta en el caché.
|
omiten esta información, dnsmasq no mete la respuesta en el caché.
|
||||||
Esta opción brinda un valor predeterminado para el time-to-live que
|
Esta opción brinda un valor predeterminado para el time-to-live que
|
||||||
dnsmasq usa para meter respuestas en el caché aún en la ausencia de
|
dnsmasq usa para meter respuestas negativas en el caché aún en la
|
||||||
un expediente SOA.
|
ausencia de un expediente SOA.
|
||||||
|
.TP
|
||||||
|
.B --max-ttl=<tiempo>
|
||||||
|
Fijar un valor TTL (tiempo de vida) máximo que será entregado a
|
||||||
|
clientes. El TTL máximo especificado será otorgado a clientes en vez
|
||||||
|
del TTL verdadero si es menor. El valor TTL real es mantenido en el caché
|
||||||
|
para prevenir la inundación de los servidores DNS upstream.
|
||||||
.TP
|
.TP
|
||||||
.B \-k, --keep-in-foreground
|
.B \-k, --keep-in-foreground
|
||||||
No ir hacia el fondo al iniciar, pero aparte de eso ejecutar como
|
No ir hacia el fondo al iniciar, pero aparte de eso ejecutar como
|
||||||
@@ -90,7 +97,8 @@ Fijar la facilidad a la cual dnsmasq deber
|
|||||||
esto es DAEMON por predeterminado, y LOCAL0 cuando el modo debug está
|
esto es DAEMON por predeterminado, y LOCAL0 cuando el modo debug está
|
||||||
en operación. Si la facilidad brindada contiene por lo menos un carácter
|
en operación. Si la facilidad brindada contiene por lo menos un carácter
|
||||||
"/", se trata como un nombre de archivo, y dnsmasq bitacoreará a dicho
|
"/", se trata como un nombre de archivo, y dnsmasq bitacoreará a dicho
|
||||||
archivo, en vez de syslog. (Errores durante la lectura de la configuración
|
archivo, en vez de syslog. Si la facilidad es '-' entonces dnsmasq
|
||||||
|
bitacorea a stderr. (Errores durante la lectura de la configuración
|
||||||
irán a syslog todavía, pero todo output desde un inicio exitoso, y todo
|
irán a syslog todavía, pero todo output desde un inicio exitoso, y todo
|
||||||
output mientras en ejecución, irá a este archivo exclusivamente.)
|
output mientras en ejecución, irá a este archivo exclusivamente.)
|
||||||
Al bitacorear a un archivo, dnsmasq cerrará y reabrirá el archivo al
|
Al bitacorear a un archivo, dnsmasq cerrará y reabrirá el archivo al
|
||||||
@@ -133,8 +141,8 @@ solo DHCP y/o TFTP.
|
|||||||
.TP
|
.TP
|
||||||
.B \-P, --edns-packet-max=<tamaño>
|
.B \-P, --edns-packet-max=<tamaño>
|
||||||
Especificar el paquete UDP EDNS.0 más grande que es soportado por
|
Especificar el paquete UDP EDNS.0 más grande que es soportado por
|
||||||
el reenviador DNS. Por predeterminado es 1280, lo cual es el
|
el reenviador DNS. Por predeterminado es 4096, lo cual es el
|
||||||
máximo recomendado en RFC2671 para ethernet.
|
tamaño recomendado en RFC5625.
|
||||||
.TP
|
.TP
|
||||||
.B \-Q, --query-port=<puerto>
|
.B \-Q, --query-port=<puerto>
|
||||||
Enviar búsquedas outbound desde, y escuchar por respuestas en,
|
Enviar búsquedas outbound desde, y escuchar por respuestas en,
|
||||||
@@ -303,6 +311,17 @@ Denegar (y bitacorear) direcciones de servidores upstream que est
|
|||||||
dentro de rangos IP privados. Esto bloquea un ataque donde un navegador
|
dentro de rangos IP privados. Esto bloquea un ataque donde un navegador
|
||||||
detrás de un firewall es usado para analizar máquinas en la red local.
|
detrás de un firewall es usado para analizar máquinas en la red local.
|
||||||
.TP
|
.TP
|
||||||
|
.B --rebind-localhost-ok
|
||||||
|
Eximir a 127.0.0.0/8 de verificaciones de rebinding. Este rango de
|
||||||
|
direcciones es retornado por servidores de tiempo real tipo hoyo
|
||||||
|
negro, así que bloquearlo puede deshabilitar estos servicios.
|
||||||
|
.TP
|
||||||
|
.B --rebind-domain-ok=[<domain>]|[[/<domain>/[<domain>/]
|
||||||
|
No detectar y bloquear dns-rebind en búsquedas a estos dominios. El
|
||||||
|
argumento puede ser o un dominio sencillo, o múltiples dominios
|
||||||
|
rodeados por '/', como el syntax de --server, por ejemplo
|
||||||
|
.B --rebind-domain-ok=/dominio1/dominio2/dominio3/
|
||||||
|
.TP
|
||||||
.B \-n, --no-poll
|
.B \-n, --no-poll
|
||||||
No revisar periodicamente a /etc/resolv.conf en busca de cambios.
|
No revisar periodicamente a /etc/resolv.conf en busca de cambios.
|
||||||
.TP
|
.TP
|
||||||
@@ -338,6 +357,20 @@ ser especificado como parte de la direcci
|
|||||||
#. Más de una opción -S es permitida, con partes de dominio o
|
#. Más de una opción -S es permitida, con partes de dominio o
|
||||||
dirección IP repetidas como sea necesario.
|
dirección IP repetidas como sea necesario.
|
||||||
|
|
||||||
|
Dominios más específicos toman precedencia sobre los menos específicos,
|
||||||
|
así que:
|
||||||
|
.B --server=/google.com/1.2.3.4
|
||||||
|
.B --server=/www.google.com/2.3.4.5
|
||||||
|
enviará búsquedas por *.google.com hacia 1.2.3.4, excepto
|
||||||
|
*www.google.com, el cual irá a 2.3.4.5.
|
||||||
|
|
||||||
|
La dirección especial de servidor '#' significa "usar los servidores
|
||||||
|
estándares", así que
|
||||||
|
.B --server=/google.com/1.2.3.4
|
||||||
|
.B --server=/www.google.com/#
|
||||||
|
enviará búsquedas por *.google.com hacia 1.2.3.4, excepto
|
||||||
|
*www.google.com, el cual será reenviado de manera usual.
|
||||||
|
|
||||||
También se permite una opción -S la cual brinda un dominio pero
|
También se permite una opción -S la cual brinda un dominio pero
|
||||||
ninguna dirección IP; esto le dice a dnsmasq que un dominio es local
|
ninguna dirección IP; esto le dice a dnsmasq que un dominio es local
|
||||||
y puede responder a búsquedas desde /etc/hosts o DHCP pero nunca
|
y puede responder a búsquedas desde /etc/hosts o DHCP pero nunca
|
||||||
@@ -459,7 +492,7 @@ de casos. La
|
|||||||
es al usar resolvedores de bitácoras de servidores web, los cuales pueden
|
es al usar resolvedores de bitácoras de servidores web, los cuales pueden
|
||||||
generar un número inmenso de búsquedas simultáneas.
|
generar un número inmenso de búsquedas simultáneas.
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[[net:]network-id,]<dirección-inicio>,<dirección-final>[[,<máscara>],<broadcast>][,<tiempo de arriendo>]
|
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<dirección-inicio>,<dirección-final>[,<netmask>[,<broadcast>]][,<tiempo de arriendo>]
|
||||||
Habilitar el servidor DHCP. Direcciones serán distribuidas desde el
|
Habilitar el servidor DHCP. Direcciones serán distribuidas desde el
|
||||||
rango <dirección-inicio> hasta <dirección-final> y desde direcciones definidas
|
rango <dirección-inicio> hasta <dirección-final> y desde direcciones definidas
|
||||||
estáticamente en opciones
|
estáticamente en opciones
|
||||||
@@ -476,10 +509,13 @@ cuales la m
|
|||||||
máscara de subred es opcional. Pero, es requerida para redes que
|
máscara de subred es opcional. Pero, es requerida para redes que
|
||||||
reciben servicio DHCP vía un agente de relay. La dirección de
|
reciben servicio DHCP vía un agente de relay. La dirección de
|
||||||
broadcast siempre es opcional. Siempre se permite tener más de
|
broadcast siempre es opcional. Siempre se permite tener más de
|
||||||
un rango dhcp (dhcp-range) en una subred. El parámetro opcional
|
un rango dhcp (dhcp-range) en una subred.
|
||||||
network-id es una etiqueta alfanumérica la cual marca esta red de
|
|
||||||
|
El parámetro opcional
|
||||||
|
.B set:<tag>
|
||||||
|
fija una etiqueta alfanumérica la cual marca esta red de
|
||||||
tal forma que opciones dhcp puedan ser especificadas en base a cada red.
|
tal forma que opciones dhcp puedan ser especificadas en base a cada red.
|
||||||
Cuando es prefijada con 'net:' entonces el significado cambia
|
Cuando es prefijada con 'tag:' en vez, entonces el significado cambia
|
||||||
de "fijar etiqueta" a "coincidir con etiqueta". Solo una etiqueta puede
|
de "fijar etiqueta" a "coincidir con etiqueta". Solo una etiqueta puede
|
||||||
ser fijada, pero más de una puede ser revisada por coincidencias. La
|
ser fijada, pero más de una puede ser revisada por coincidencias. La
|
||||||
dirección final puede ser remplazada por la palabra clave
|
dirección final puede ser remplazada por la palabra clave
|
||||||
@@ -496,8 +532,11 @@ caso en el cual dnsmasq proveer
|
|||||||
y
|
y
|
||||||
.B pxe-service
|
.B pxe-service
|
||||||
para detalles.)
|
para detalles.)
|
||||||
|
|
||||||
|
La sección interface:<interface name> no es normalmente usada. Ver la
|
||||||
|
sección NOTAS para detalles sobre esto.
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<dirección de hardware>][,id:<client_id>|*][,net:<netid>][,<dirección IP>][,<nombre de host>][,<tiempo de arriendo>][,ignore]
|
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<tiempo_de_arriendo>][,ignorar]
|
||||||
Especificar parámetros por host para el servidor DHCP. Esto permite
|
Especificar parámetros por host para el servidor DHCP. Esto permite
|
||||||
que una máquina con una dirección de hardware particular sea siempre
|
que una máquina con una dirección de hardware particular sea siempre
|
||||||
alocada el mismo nombre de host, dirección IP, y tiempo de arriendo.
|
alocada el mismo nombre de host, dirección IP, y tiempo de arriendo.
|
||||||
@@ -512,10 +551,15 @@ le dice a dnsmasq que debe darle a la m
|
|||||||
ethernet 00:20:e0:3b:13:af el nombre wap, y un arriendo DHCP infinito.
|
ethernet 00:20:e0:3b:13:af el nombre wap, y un arriendo DHCP infinito.
|
||||||
.B --dhcp-host=lap,192.168.0.199
|
.B --dhcp-host=lap,192.168.0.199
|
||||||
le dice a dnsmasq que siempre debe alocarle a la maquina lap
|
le dice a dnsmasq que siempre debe alocarle a la maquina lap
|
||||||
la dirección IP 192.168.0.199. Direcciones alocadas de esta manera
|
la dirección IP 192.168.0.199.
|
||||||
no tienen que estar dentro del rango dado con la opción --dhcp-range,
|
|
||||||
pero deben estar en la red siendo servida por el servidor DHCP. Se
|
Direcciones alocadas de esta manera no tienen que estar dentro
|
||||||
permite usar identificadores de clientes en vez de direcciones de
|
del rango dado con la opción --dhcp-range, pero deben estar en la subred
|
||||||
|
de un rango DHCP (dhcp-range) válido. Para subredes que no necesitan
|
||||||
|
una collección de direcciones dinamicamente alocadas, usar la palabra
|
||||||
|
clave "static" in la declaración dhcp-range.
|
||||||
|
|
||||||
|
Es permitido usar identificadores de cliente en vez de direcciones de
|
||||||
hardware para identificar hosts prefijando 'id:'. O sea que:
|
hardware para identificar hosts prefijando 'id:'. O sea que:
|
||||||
.B --dhcp-host=id:01:02:03:04,.....
|
.B --dhcp-host=id:01:02:03:04,.....
|
||||||
se refiere al host con identificador de cliente 01:02:03:04.
|
se refiere al host con identificador de cliente 01:02:03:04.
|
||||||
@@ -529,7 +573,14 @@ presenta un ID de cliente algunas veces pero otras no.
|
|||||||
Si un nombre aparece en /etc/hosts, la dirección asociada puede
|
Si un nombre aparece en /etc/hosts, la dirección asociada puede
|
||||||
ser alocada a un arriendo DHCP, pero solo si existe una opción
|
ser alocada a un arriendo DHCP, pero solo si existe una opción
|
||||||
.B --dhcp-host
|
.B --dhcp-host
|
||||||
la cual especifica el nombre también. La palabra clave "ignore"
|
la cual especifica el nombre también. Solo un hostname puede ser
|
||||||
|
brindado en una opción
|
||||||
|
.B dhcp-host
|
||||||
|
pero aliases son posibles por medio del uso de CNAMEs. (Ver
|
||||||
|
.B --cname
|
||||||
|
).
|
||||||
|
|
||||||
|
La palabra clave "ignore"
|
||||||
le dice a dnsmasq que no debe ofrecer jamás un arriendo DHCP a
|
le dice a dnsmasq que no debe ofrecer jamás un arriendo DHCP a
|
||||||
una máquina. La máquina puede ser especificada por dirección de
|
una máquina. La máquina puede ser especificada por dirección de
|
||||||
hardware, ID de cliente, o nombre de host, por ejemplo:
|
hardware, ID de cliente, o nombre de host, por ejemplo:
|
||||||
@@ -537,14 +588,16 @@ hardware, ID de cliente, o nombre de host, por ejemplo:
|
|||||||
Esto es útil cuando hay otro servidor DHCP en la red que debe ser
|
Esto es útil cuando hay otro servidor DHCP en la red que debe ser
|
||||||
usado por algúnas máquinas.
|
usado por algúnas máquinas.
|
||||||
|
|
||||||
El net:<network-id> fija la etiqueta network-id cuando sea que
|
El set:<tag> fija la etiqueta cuando sea que
|
||||||
esta directiva dhcp-host está en uso. Esto puede ser usado para
|
esta directiva dhcp-host está en uso. Esto puede ser usado para
|
||||||
enviar selectivamente opciones DHCP a este host. Cuando un host
|
enviar selectivamente opciones DHCP a este host. Más de una etiqueta
|
||||||
coincide con cualquier directiva dhcp-host (o una implicada por
|
puede ser fijada en una directiva dhcp-host (pero no en otros lugares
|
||||||
/etc/ethers) entonces la etiqueta network-id especial "known" es
|
donde "set:<tag>" es permitido). Cuando un host coincide con
|
||||||
|
cualquier directiva dhcp-host (o una implicada por
|
||||||
|
/etc/ethers) entonces la etiqueta especial "known" es
|
||||||
fijada. Esto permite que dnsmasq sea configurado para ignorar
|
fijada. Esto permite que dnsmasq sea configurado para ignorar
|
||||||
pedidos desde máquinas desconocidas usando
|
pedidos desde máquinas desconocidas usando
|
||||||
.B --dhcp-ignore=#known
|
.B --dhcp-ignore=tag:!known
|
||||||
Direcciones ethernet (pero no client-ids) pueden tener bytes
|
Direcciones ethernet (pero no client-ids) pueden tener bytes
|
||||||
comodínes, así que por ejemplo
|
comodínes, así que por ejemplo
|
||||||
.B --dhcp-host=00:20:e0:3b:13:*,ignore
|
.B --dhcp-host=00:20:e0:3b:13:*,ignore
|
||||||
@@ -578,6 +631,11 @@ Leer informaci
|
|||||||
Leer información sobre opciones DHCP desde el archivo especificado. La
|
Leer información sobre opciones DHCP desde el archivo especificado. La
|
||||||
ventaja de usar esta opción es la misma que con --dhcp-hostsfile: el
|
ventaja de usar esta opción es la misma que con --dhcp-hostsfile: el
|
||||||
archivo dhcp-optsfile será re-leído cuando dnsmasq recibe un SIGHUP.
|
archivo dhcp-optsfile será re-leído cuando dnsmasq recibe un SIGHUP.
|
||||||
|
Nótese que es posible colocar la información mediante
|
||||||
|
.B --dhcp-boot
|
||||||
|
como opciones DHCP, usando los nombres de opción bootfile-name,
|
||||||
|
server-ip-address, y tftp-server. Esto permite que sean incluidas en
|
||||||
|
un archivo dhcp-optsfile.
|
||||||
.TP
|
.TP
|
||||||
.B \-Z, --read-ethers
|
.B \-Z, --read-ethers
|
||||||
Leer /etc/ethers en busca de información sobre hosts para el servidor
|
Leer /etc/ethers en busca de información sobre hosts para el servidor
|
||||||
@@ -585,9 +643,10 @@ DHCP. El formato de /etc/ethers es una direcci
|
|||||||
por ya sea un nombre de host o una dirección IP. Al ser leidas por
|
por ya sea un nombre de host o una dirección IP. Al ser leidas por
|
||||||
dnsmasq, estas líneas tienen exáctamente el mismo efecto que opciones
|
dnsmasq, estas líneas tienen exáctamente el mismo efecto que opciones
|
||||||
.B --dhcp-host
|
.B --dhcp-host
|
||||||
que contienen la misma información. /etc/ethers es re-leída cuando dnsmasq recibe un SIGHUP.
|
que contienen la misma información. /etc/ethers es re-leída cuando
|
||||||
|
dnsmasq recibe un SIGHUP.
|
||||||
.TP
|
.TP
|
||||||
.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][encap:<opt>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
|
.B \-O, --dhcp-option=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
|
||||||
Especificar opciones diferentes o extra a clientes DHCP. Por
|
Especificar opciones diferentes o extra a clientes DHCP. Por
|
||||||
predeterminado, dnsmasq envía algunas opciones estándar a clientes
|
predeterminado, dnsmasq envía algunas opciones estándar a clientes
|
||||||
DHCP. La máscara de subred y dirección broadcast son fijadas igual
|
DHCP. La máscara de subred y dirección broadcast son fijadas igual
|
||||||
@@ -612,9 +671,9 @@ o
|
|||||||
La dirección especial 0.0.0.0 es entendida que significa "la
|
La dirección especial 0.0.0.0 es entendida que significa "la
|
||||||
dirección de la máquina que corre dnsmasq". Tipos de data permitidos
|
dirección de la máquina que corre dnsmasq". Tipos de data permitidos
|
||||||
son direcciones IP de cuatro segmentos, un número decimal, dígitos hex
|
son direcciones IP de cuatro segmentos, un número decimal, dígitos hex
|
||||||
separados por colones, y un string de texto. Si las network-ids
|
separados por colones, y un string de texto. Si las etiquetas
|
||||||
opcionales son brindadas, entonces esta opción es solo enviada cuando
|
opcionales son brindadas, entonces esta opción es solo enviada cuando
|
||||||
todas las network-ids coinciden.
|
todas las etiquetas coinciden.
|
||||||
|
|
||||||
Procesamiento especial es llevado a cabo en un argumento de texto para
|
Procesamiento especial es llevado a cabo en un argumento de texto para
|
||||||
la opción 119, en conforme con RFC3397. Direcciones IP textuales o de
|
la opción 119, en conforme con RFC3397. Direcciones IP textuales o de
|
||||||
@@ -657,9 +716,16 @@ enviar
|
|||||||
opciones son brindadas que están encapsuladas con el mismo número de
|
opciones son brindadas que están encapsuladas con el mismo número de
|
||||||
opción entonces serán correctamente combinadas en una opción encapsulada.
|
opción entonces serán correctamente combinadas en una opción encapsulada.
|
||||||
encap: y vendor: no pueden ser fijadas ambas dentro de la misma opción dhcp-option.
|
encap: y vendor: no pueden ser fijadas ambas dentro de la misma opción dhcp-option.
|
||||||
|
|
||||||
|
La variante final en opciones encapsuladas es "Vendor-Identifying Vendor Options"
|
||||||
|
como especificado en RFC3925. Estos son denotados así:
|
||||||
|
.B --dhcp-option=rfc3925-encap:2, 10, "text"
|
||||||
|
El número en la sección rfc3925-encap: es el número enterprise usado
|
||||||
|
para identificar esta opción.
|
||||||
|
|
||||||
La dirección 0.0.0.0 no es tratada de forma especial en opciones encapsuladas.
|
La dirección 0.0.0.0 no es tratada de forma especial en opciones encapsuladas.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-option-force=[<network-id>,[<network-id>,]][encap:<opt>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
|
.B --dhcp-option-force=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
|
||||||
Esto funciona exáctamente de la misma forma que
|
Esto funciona exáctamente de la misma forma que
|
||||||
.B --dhcp-option
|
.B --dhcp-option
|
||||||
excepto que la opción siempre será enviada, aún si el cliente no la pide en
|
excepto que la opción siempre será enviada, aún si el cliente no la pide en
|
||||||
@@ -674,20 +740,21 @@ hacia opciones DHCP. Esto crea espacio extra en el paquete DHCP para opciones,
|
|||||||
pero puede raramente confundir clientes viejos o defectuosos. Esta opción forza
|
pero puede raramente confundir clientes viejos o defectuosos. Esta opción forza
|
||||||
comportamiento "simple y sencillo" para prevenir problemas en tales casos.
|
comportamiento "simple y sencillo" para prevenir problemas en tales casos.
|
||||||
.TP
|
.TP
|
||||||
.B \-U, --dhcp-vendorclass=<network-id>,<vendor-class>
|
.B \-U, --dhcp-vendorclass=set:<tag>,<vendor-class>
|
||||||
Trazar desde un string vendor-class a un network id. La mayoría de los
|
Trazar desde un string vendor-class a una etiqueta. La mayoría de los
|
||||||
clientes DHCP proveen una "vendor class" la cual representa, en cierto
|
clientes DHCP proveen una "vendor class" la cual representa, en cierto
|
||||||
sentido, el tipo de host. Esta opción traza clases de vendedor a network
|
sentido, el tipo de host. Esta opción traza clases de vendedor a network
|
||||||
ids, de tal forma que opciones DHCP pueden ser selectivamente entregadas
|
ids, de tal forma que opciones DHCP pueden ser selectivamente entregadas
|
||||||
a diferentes clases de hosts. Por ejemplo
|
a diferentes clases de hosts. Por ejemplo
|
||||||
.B dhcp-vendorclass=printers,Hewlett-Packard JetDirect
|
.B dhcp-vendorclass=set:printers,Hewlett-Packard JetDirect
|
||||||
peritiría que opciones sean fijadas solo para impresoras HP así:
|
peritiría que opciones sean fijadas solo para impresoras HP así:
|
||||||
.B --dhcp-option=printers,3,192.168.4.4
|
.B --dhcp-option=tag:printers,3,192.168.4.4
|
||||||
El string vendor-class es coordinado con el vendor-class proveido por
|
El string vendor-class es coordinado con el vendor-class proveido por
|
||||||
el cliente, para permitir coincidencias borrosas.
|
el cliente, para permitir coincidencias borrosas. El prefijo set: es
|
||||||
|
opcional, pero permitido por razones de consistencia.
|
||||||
.TP
|
.TP
|
||||||
.B \-j, --dhcp-userclass=<network-id>,<user-class>
|
.B \-j, --dhcp-userclass=set:<tag>,<user-class>
|
||||||
Trazar desde un string user-class a un network id (con coordinación
|
Trazar desde un string user-class a una etiqueta (con coordinación
|
||||||
substring, como con vendor-class). La mayoría de los clientes DHCP
|
substring, como con vendor-class). La mayoría de los clientes DHCP
|
||||||
proveen un "user class" el cual es configurable. Esta opción traza
|
proveen un "user class" el cual es configurable. Esta opción traza
|
||||||
clases user a network ids, de tal manera que opciones DHCP puedan
|
clases user a network ids, de tal manera que opciones DHCP puedan
|
||||||
@@ -695,26 +762,43 @@ ser selectivamente enviadas a diferentes tipos de hosts. Es posible,
|
|||||||
por ejemplo, usar esto para especificar una impresora diferente para
|
por ejemplo, usar esto para especificar una impresora diferente para
|
||||||
hosts en la clase "cuentas" que para los de la clase "ingenieria".
|
hosts en la clase "cuentas" que para los de la clase "ingenieria".
|
||||||
.TP
|
.TP
|
||||||
.B \-4, --dhcp-mac=<network-id>,<dirección MAC>
|
.B \-4, --dhcp-mac=set:<tag>,<MAC address>
|
||||||
Trazar desde una dirección MAC a una network id. La dirección MAC
|
Trazar desde una dirección MAC a una etiqueta. La dirección MAC
|
||||||
puede incluir comodínes. Por ejemplo:
|
puede incluir comodínes. Por ejemplo:
|
||||||
.B --dhcp-mac=3com,01:34:23:*:*:*
|
.B --dhcp-mac=set:3com,01:34:23:*:*:*
|
||||||
fijaría el tag "3com" a cualquier host el cual su MAC coincida con
|
fijaría el tag "3com" a cualquier host el cual su MAC coincida con
|
||||||
el patrón.
|
el patrón.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-circuitid=<network-id>,<circuit-id>, --dhcp-remoteid=<network-id>,<remote-id>
|
.B --dhcp-circuitid=<network-id>,<circuit-id>, --dhcp-remoteid=<network-id>,<remote-id>
|
||||||
Trazar de opciones agente de relay RFC3046 a opciones network-id. Estos
|
Trazar de opciones agente de relay RFC3046 a etiquetas. Estos
|
||||||
datos pueden ser proveídos por agentes de relay DHCP. El circuit-id o
|
datos pueden ser proveídos por agentes de relay DHCP. El circuit-id o
|
||||||
remote-id es normlamente brindado como hex separado por doblepuntos, pero
|
remote-id es normlamente brindado como hex separado por doblepuntos, pero
|
||||||
también se permite un string simple. Si se obtiene una coincidencia exacta
|
también se permite un string simple. Si se obtiene una coincidencia exacta
|
||||||
entre el circuit o agent ID y uno proveído por un agente de relay,
|
entre el circuit o agent ID y uno proveído por un agente de relay,
|
||||||
network-id es fijado.
|
la etiqueta es fijada.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-subscrid=<network-id>,<subscriber-id>
|
.B --dhcp-subscrid=set:<tag>,<subscriber-id>
|
||||||
Trazar de opciones relay subscriber-id RFC3993 a opciones network-id.
|
Trazar de opciones relay subscriber-id RFC3993 a etiquetas.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-match=<network-id>,<option number>|option:<option name>[,<value>]
|
.B --dhcp-proxy[=<ip addr>]......
|
||||||
Sin un valor, fijar la etiqueta network-id si el cliente envía una opción
|
Un agente de relay normal es usado solamente para reenviar las partes
|
||||||
|
iniciales de una interacción DHCP con el servidor DHCP. Una vez que
|
||||||
|
un cliente es configurado, se comunica diectamente con el servidor. Esto
|
||||||
|
es indeseable si el agente de relay está agregando información extra a
|
||||||
|
los paquetes DHCP, tal como usado por
|
||||||
|
.B dhcp-circuitid
|
||||||
|
y
|
||||||
|
.B dhcp-remoteid.
|
||||||
|
Una implementación relay completa puede usar la opción serverid-override
|
||||||
|
RFC 5107 para obligar al servidor DHCP a usar el relay como un proxy
|
||||||
|
completo, con todos los paquetes pasando a travez de el. Esta opción
|
||||||
|
provee una manera alternativa de hacer la misma cosa, para relays que
|
||||||
|
no tienen soporte RFC 5107. Brindada por si sola, manipula el server-id
|
||||||
|
para todas las interacciones via relays. Si una lista de IPs es brindada,
|
||||||
|
solo interacciones via relays en esas direcciones son afectadas.
|
||||||
|
.TP
|
||||||
|
.B --dhcp-match=set:<tag>,<option number>|option:<option name>|vi-encap:<enterprise>[,<value>]
|
||||||
|
Sin un valor, fijar la etiqueta si el cliente envía una opción
|
||||||
DHCP del número o valor brindado. Cuando un valor es brindado, fijar la
|
DHCP del número o valor brindado. Cuando un valor es brindado, fijar la
|
||||||
etiqueta solo si la opción es enviada y coincide con el valor. El valor puede
|
etiqueta solo si la opción es enviada y coincide con el valor. El valor puede
|
||||||
ser de la forma "01:ff:*:02", caso en el cual el valor debe coincidir (aparte
|
ser de la forma "01:ff:*:02", caso en el cual el valor debe coincidir (aparte
|
||||||
@@ -724,45 +808,66 @@ del final del valor. El valor tambi
|
|||||||
caso en el cual la opción enviada es tratada como un array, y un elemento debe
|
caso en el cual la opción enviada es tratada como un array, y un elemento debe
|
||||||
coincidir, así que
|
coincidir, así que
|
||||||
|
|
||||||
--dhcp-match=efi-ia32,option:client-arch,6
|
--dhcp-match=set:efi-ia32,option:client-arch,6
|
||||||
|
|
||||||
fijará la etiqueta a "efi-ia32" si el número 6 aparece en la lista de
|
fijará la etiqueta a "efi-ia32" si el número 6 aparece en la lista de
|
||||||
architecturas enviada por los clientes en opción 93. (Ver RFC 4578 para
|
architecturas enviada por los clientes en opción 93. (Ver RFC 4578 para
|
||||||
detalles.) Si el valor es un string, coincidencia substring es usada.
|
detalles.) Si el valor es un string, coincidencia substring es usada.
|
||||||
.B \-J, --dhcp-ignore=<network-id>[,<network-id>]
|
|
||||||
Cuando todos los network ids brindados coincidan con el juego de
|
La forma especial con vi-encap:<enterpise number> busca coincidencia con
|
||||||
network ids derivados de las clases net, host, y vendor, ignorar
|
clases de vendedor identificadoras para el enterprise especificado. Por
|
||||||
el host y no brindarle un arriendo DHCP.
|
favor ver RFC 3925 para mas detalles sobre estas bestias raras e interesantes.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-ignore-names[=<network-id>[,<network-id>]]
|
.B --tag-if=set:<tag>[,set:<tag>[,tag:<tag>[,tag:<tag>]]]
|
||||||
Cuando todos los network-ids brindados coinciden con el juego de
|
Llevar a cabo operaciones boolean en etiquetas. Cualquier etiqueta
|
||||||
network-ids derivado de la red, host, classes de vendedor y usuario,
|
que aparece como set:<tag> es fijada si todas las etiquetas que aparecen
|
||||||
ignorar cualquier nombre de host proveido por el host. Nótese que,
|
como tag:<tag> estan fijadas, (o desfijadas cuando tag:!<tag> es
|
||||||
a diferencia de dhcp-ignore, es permisible no brindar ningún tag netid,
|
usado). Si ningún tag:<tag> aparece, etiquetas set:<tag> son fijadas
|
||||||
|
incondicionalmente. Cualquier cantidad de formas set: y tag:
|
||||||
|
pueden aparecer, en cualquier orden. Líneas tag-if son ejecutadas
|
||||||
|
en orden, así que si la etiqueta en tag:<tag> es una etiqueta fijada
|
||||||
|
por otra
|
||||||
|
.B tag-if,
|
||||||
|
la línea que fija la etiqueta debe preceder a la que comprueba.
|
||||||
|
.TP
|
||||||
|
.B \-J, --dhcp-ignore=tag:<tag>[,tag:<tag>]
|
||||||
|
Cuando todoas las etiquetas brindadas aparecen en el juego de etiquetas
|
||||||
|
ignorar el host y no brindarle un arriendo DHCP.
|
||||||
|
.TP
|
||||||
|
.B --dhcp-ignore-names[=tag:<tag>[,tag:<tag>]]
|
||||||
|
Cuando todos las etiquetas brindadas aparecen en el juego de etiquetas, ignorar cualquier nombre de host proveido por el host. Nótese que,
|
||||||
|
a diferencia de dhcp-ignore, es permisible no brindar ninguna etiqueta,
|
||||||
y en tal caso nombres de host proveidos por clientes DHCP siempre son
|
y en tal caso nombres de host proveidos por clientes DHCP siempre son
|
||||||
ignorados, y hosts DHCP son agregados al DNS usando solo la configuración
|
ignorados, y hosts DHCP son agregados al DNS usando solo la configuración
|
||||||
dhcp-host en dnsmasq y el contenido de /etc/hosts y /etc/ethers.
|
dhcp-host en dnsmasq y el contenido de /etc/hosts y /etc/ethers.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-broadcast=<network-id>[,<network-id>]
|
.B --dhcp-generate-names=tag:<tag>[,tag:<tag>]
|
||||||
Cuando todos los network-ids brindados coinciden con el juego de network-ids
|
Generar un nombre para clientes DHCP que de otra forma no tienen uno,
|
||||||
derivados de la red, host, clases de vendedor y usuarios, siempre usar
|
usando la dirección MAC expresada en hex, separada por guiones. Nótese
|
||||||
broadcast para comunicarse con el host cuando está sin configurar. La
|
que si un host provee un nombre, será usado preferiblemente sobre este,
|
||||||
mayoría de clientes DHCP que necesitan respuestas broadcast fijan una
|
a menos que
|
||||||
opción en sus pedidos para que esto pase automaticamente, algunos
|
.B --dhcp-ignore-names
|
||||||
clientes BOOTP viejos no lo hacen.
|
esté fijado.
|
||||||
.TP
|
.TP
|
||||||
.B \-M, --dhcp-boot=[net:<network-id>,]<filename>,[<servername>[,<server address>]]
|
.B --dhcp-broadcast[=tag:<tag>[,tag:<tag>]]
|
||||||
|
Cuando todas las etiquetas aparecen en el juego de etiquetas, siempre
|
||||||
|
usar broadcast para comunicar con el host cuando no está configurado.
|
||||||
|
Es permisible omitir las etiquetas, caso en el cual esto es
|
||||||
|
incondicional. La mayoría de clientes DHCP que necesitan
|
||||||
|
respuestas broadcast fijan una opción en sus pedidos para que esto pase automaticamente, algunos clientes BOOTP viejos no lo hacen.
|
||||||
|
.TP
|
||||||
|
.B \-M, --dhcp-boot=[tag:<tag>,]<filename>,[<servername>[,<server address>]]
|
||||||
Fijar opciones BOOTP que han de ser devueltas por el servidor DHCP. Nombre
|
Fijar opciones BOOTP que han de ser devueltas por el servidor DHCP. Nombre
|
||||||
y dirección de servidor son opcionales: si no son brindadas, el nombre es
|
y dirección de servidor son opcionales: si no son brindadas, el nombre es
|
||||||
dejado en blanco, y la dirección es fijada a la de la máquina que corre
|
dejado en blanco, y la dirección es fijada a la de la máquina que corre
|
||||||
dnsmasq. Si dnsmasq está brindando servicio TFTP (ver
|
dnsmasq. Si dnsmasq está brindando servicio TFTP (ver
|
||||||
.B --enable-tftp
|
.B --enable-tftp
|
||||||
) entonces solo el nombre de archivo es requirido aquí para habilitar
|
) entonces solo el nombre de archivo es requirido aquí para habilitar
|
||||||
el inicio atravéz de una red. Si las opcionales network-ids son brindadas,
|
el inicio atravéz de una red. Si las opcionales etiquetas son brindadas,
|
||||||
ellas deberán coincidir para que esta configuración sea enviada. Nótese
|
ellas deberán coincidir para que esta configuración sea enviada. Nótese
|
||||||
que network-ids están prefijadas con "net:" para distinguirlas.
|
que network-ids están prefijadas con "net:" para distinguirlas.
|
||||||
.TP
|
.TP
|
||||||
.B --pxe-service=[net:<network-id>,]<CSA>,<texto de menú>,<nombre base>|<tipo de servicio boot>[,<dirección de servidor>]
|
.B --pxe-service=[tag:<tag>,]<CSA>,<menu text>[,<basename>|<bootservicetype>][,<server address>]
|
||||||
La mayoría de usos para boot-ROMS PXE simplemente permiten al sistema PXE
|
La mayoría de usos para boot-ROMS PXE simplemente permiten al sistema PXE
|
||||||
obtener una dirección IP y entonces bajar el archivo especificado por
|
obtener una dirección IP y entonces bajar el archivo especificado por
|
||||||
.B dhcp-boot
|
.B dhcp-boot
|
||||||
@@ -784,12 +889,13 @@ direcci
|
|||||||
Nótese que el sufijo "layer" (normalmente ".0") es brindado por PXE, y
|
Nótese que el sufijo "layer" (normalmente ".0") es brindado por PXE, y
|
||||||
no debe ser agregado al nombre base. Si un número entero es brindado en vez
|
no debe ser agregado al nombre base. Si un número entero es brindado en vez
|
||||||
de un nombre base, entonces el cliente PXE buscará un servicio boot adecuado
|
de un nombre base, entonces el cliente PXE buscará un servicio boot adecuado
|
||||||
para ese tipo de red. Esta búsqueda puede ser hecha mediante multicast o
|
para ese tipo de red. Esta búsqueda puede ser hecha mediante broadcast,
|
||||||
broadcast, o directamente a un servidor si la dirección IP es brindada. Un
|
o directamente a un servidor si la dirección IP es brindada. Si ningún tipo
|
||||||
tipo de servicio boot de 0 es especial, y abortará el proceso boot de red
|
de servicio boot o nombre de archivo es brindado (o un tipo de servicio boot
|
||||||
y continuará desde medio local.
|
de 0 es especificado), entonces la opción de menú abortará el proceso net boot
|
||||||
|
y continuará desde el medio local.
|
||||||
.TP
|
.TP
|
||||||
.B --pxe-prompt=[net:<network-id>,]<prompt>[,<timeout>]
|
.B --pxe-prompt=[tag:<tag>,]<prompt>[,<timeout>]
|
||||||
Fijar esto hace que un aviso sea expuesto despues del boot PXE. Si el timeout
|
Fijar esto hace que un aviso sea expuesto despues del boot PXE. Si el timeout
|
||||||
es brindado, entonces despues que el timeout se haya vencido sin input del
|
es brindado, entonces despues que el timeout se haya vencido sin input del
|
||||||
teclado, la primera opción del menú sera automaticamente ejecutada. Si el
|
teclado, la primera opción del menú sera automaticamente ejecutada. Si el
|
||||||
@@ -815,7 +921,7 @@ en
|
|||||||
.TP
|
.TP
|
||||||
.B \-X, --dhcp-lease-max=<número>
|
.B \-X, --dhcp-lease-max=<número>
|
||||||
Limita a dnsmasq a el número especificado de arriendos DHCP. El
|
Limita a dnsmasq a el número especificado de arriendos DHCP. El
|
||||||
predeterminado es 150. El limite es para prevenir ataques DoS desde
|
predeterminado es 1000. El limite es para prevenir ataques DoS desde
|
||||||
hosts que crean cientos de arriendos y usan mucha de la memoria del
|
hosts que crean cientos de arriendos y usan mucha de la memoria del
|
||||||
proceso dnsmasq.
|
proceso dnsmasq.
|
||||||
.TP
|
.TP
|
||||||
@@ -855,7 +961,7 @@ cuidado.
|
|||||||
.TP
|
.TP
|
||||||
.B --log-dhcp
|
.B --log-dhcp
|
||||||
Bitacoréo extra para DHCP: Bitacorear todas las opciones enviadas a
|
Bitacoréo extra para DHCP: Bitacorear todas las opciones enviadas a
|
||||||
clientes DHCP y las etiquetas netid usadas para determinarlos.
|
clientes DHCP y las etiquetas usadas para determinarlos.
|
||||||
.TP
|
.TP
|
||||||
.B \-l, --dhcp-leasefile=<path>
|
.B \-l, --dhcp-leasefile=<path>
|
||||||
Usar el archivo especificado para almacenar información de arriendos
|
Usar el archivo especificado para almacenar información de arriendos
|
||||||
@@ -864,6 +970,7 @@ DHCP.
|
|||||||
.B \-6 --dhcp-script=<path>
|
.B \-6 --dhcp-script=<path>
|
||||||
Cuando un arriendo DHCP nuevo es creado, o uno viejo es
|
Cuando un arriendo DHCP nuevo es creado, o uno viejo es
|
||||||
destruido, el ejecutable especificado por esta opción es ejecutado.
|
destruido, el ejecutable especificado por esta opción es ejecutado.
|
||||||
|
<path> debe ser un pathname absoluto, ninguna búsqueda PATH ocurre.
|
||||||
Los argumentos para el binario son "add", "old", o "del", la dirección
|
Los argumentos para el binario son "add", "old", o "del", la dirección
|
||||||
MAC del host, la dirección IP, y el hostname, si es
|
MAC del host, la dirección IP, y el hostname, si es
|
||||||
conocido. "add" significa que un arriendo ha sido creado, "del" que
|
conocido. "add" significa que un arriendo ha sido creado, "del" que
|
||||||
@@ -875,36 +982,64 @@ que no es ethernet, tendr
|
|||||||
"06-01:23:45:67:89:ab" para token ring. El proceso es ejecutado como root
|
"06-01:23:45:67:89:ab" para token ring. El proceso es ejecutado como root
|
||||||
(asumiendo que dnsmasq fue originalmente ejecutado como root) aún si dnsmasq
|
(asumiendo que dnsmasq fue originalmente ejecutado como root) aún si dnsmasq
|
||||||
está configurado para cambiar su UID a un usuario sin privilegios.
|
está configurado para cambiar su UID a un usuario sin privilegios.
|
||||||
El ambiente es heredado del usuario que ha invocado a dnsmasq, y si el
|
|
||||||
host brindó un client-id, es almacenado en la variable de ambiente
|
|
||||||
DNSMASQ_CLIENT_ID. Si el dominio completamente calificado del host
|
El ambiente es heredado del usuario que ha invocado a dnsmasq, con algunas
|
||||||
es conocido, la parte de dominio es almacenada en DNSMASQ_DOMAIN. Si
|
o todas de las siguientes variables agregadas.
|
||||||
el cliente brinda información de clase de vendedoro usuario,
|
|
||||||
estos son brindados en las variables DNSMASQ_VENDOR_CLASS y
|
DNSMASQ_CLIENT_ID si el host brindo un client-id.
|
||||||
|
|
||||||
|
DNSMASQ_DOMAIN si el nombre de dominio completamente calificado del host
|
||||||
|
es conocido, esto es fijado a la parte del dominio.
|
||||||
|
|
||||||
|
Si el cliente brinda vendor-class, hostname o user-class, estos son
|
||||||
|
brindados en las variables
|
||||||
|
DNSMASQ_VENDOR_CLASS, DNSMASQ_SUPPLIED_HOSTNAME, y
|
||||||
DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn, pero solo para acciones "add"
|
DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn, pero solo para acciones "add"
|
||||||
y "old" cuando un host resume un arriendo existente, dado a que estos
|
y "old" cuando un host reanuda un arriendo existente, dado a que estos
|
||||||
datos no son almacenados en la base de datos de arriendos de dnsmasq.
|
datos no son almacenados en la base de datos de arriendos de dnsmasq.
|
||||||
|
|
||||||
Si dnsmasq fue compilado con HAVE_BROKEN_RTC, entonces la duración del
|
Si dnsmasq fue compilado con HAVE_BROKEN_RTC, entonces la duración del
|
||||||
arriendo (en segundos) es almacenada en DNSMASQ_LEASE_LENGTH, de otra
|
arriendo (en segundos) es almacenada en DNSMASQ_LEASE_LENGTH, de otra
|
||||||
manera el tiempo de vencimiento es almacenado en DNSMASQ_LEASE_EXPIRES.
|
manera el tiempo de vencimiento es almacenado en DNSMASQ_LEASE_EXPIRES.
|
||||||
El número de segundos faltante para el vencimiento del arriendo siempre
|
El número de segundos faltante para el vencimiento del arriendo siempre
|
||||||
es almacenado en DNSMASQ_TIME_REMAINING.
|
es almacenado en DNSMASQ_TIME_REMAINING.
|
||||||
|
|
||||||
Si un arriendo solía tener un nombre de host, el cual es removido, un
|
Si un arriendo solía tener un nombre de host, el cual es removido, un
|
||||||
evento "old" es generado con el nuevo estado del arriendo, (por ejemplo, sin
|
evento "old" es generado con el nuevo estado del arriendo, (por ejemplo, sin
|
||||||
nombre), y el nombre anterior es brindado en la variable de ambiente
|
nombre), y el nombre anterior es brindado en la variable de ambiente
|
||||||
DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE almacena el nombre de la interface
|
DNSMASQ_OLD_HOSTNAME.
|
||||||
|
|
||||||
|
DNSMASQ_INTERFACE almacena el nombre de la interface
|
||||||
en la cual llegó el pedido; esto no es fijado para acciones "viejas"
|
en la cual llegó el pedido; esto no es fijado para acciones "viejas"
|
||||||
cuando dnsmasq re-inicia.
|
cuando dnsmasq re-inicia.
|
||||||
|
|
||||||
|
DNSMASQ_RELAY_ADDRESS es fijado si el cliente
|
||||||
|
usó un relay DHCP para contactar a dnsmasq y la dirección IP del relay
|
||||||
|
es conocida.
|
||||||
|
|
||||||
|
DNSMASQ_TAGS contiene todas las etiquetas network-id fijadas
|
||||||
|
durante la transacción DHCP, separadas por espacios.
|
||||||
|
|
||||||
Todos los descriptores de archivo están cerrados
|
Todos los descriptores de archivo están cerrados
|
||||||
excepto stdin, stdout, y stderr los cuales están abiertos a /dev/null
|
excepto stdin, stdout, y stderr los cuales están abiertos a /dev/null
|
||||||
(excepto en modo debug).
|
(excepto en modo debug).
|
||||||
Este guión no es invocado concurrentemente: si cambios de arriendos
|
|
||||||
subsiguientes ocurren, el guión no es invocado otra vez hasta que
|
Este guión no es invocado concurrentemente: máximo una instamcia del
|
||||||
cualquier invocación existente haga exit. Al inicio de dnsmasq, el guión
|
guión está corriendo a la vez (dnsmasq espera a que una instancia de
|
||||||
|
guión haga exit antes de correr la siguiente). Cambios a la base de
|
||||||
|
datos de arriendos que requieren que el guión sea invocado son puestos
|
||||||
|
en cola esperando el exit de una instancia corriente. Si esta cola permite
|
||||||
|
que cambios multiples de estado le ocurran a un arriendo individual antes
|
||||||
|
de que el guión pueda ser ejecutado entonces estados anteriores son descartados
|
||||||
|
y el estado actual del arriendo es reflejado cuando el guión finalmente corre.
|
||||||
|
|
||||||
|
Al inicio de dnsmasq, el guión
|
||||||
será invocado para todos los arriendos existentes mientras van siendo
|
será invocado para todos los arriendos existentes mientras van siendo
|
||||||
leídos desde el archivo de arriendos. Arriendos vencidos serán llamados
|
leídos desde el archivo de arriendos. Arriendos vencidos serán llamados
|
||||||
con "del" y otros con "old". <path> debe ser un path absoluto, ninguna
|
con "del" y otros con "old". <path> debe ser un path absoluto, ninguna
|
||||||
búsqueda PATH ocurre. Cuando dnsmasq recibe una señal HUP, el guión será
|
búsqueda PATH ocurre cuando arriendos dnsmasq serán llamados con "del"
|
||||||
|
y otros con "old". Cuando dnsmasq recibe una señal HUP, el guión será
|
||||||
invocado para arriendos existentes con un evento "old".
|
invocado para arriendos existentes con un evento "old".
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-scriptuser
|
.B --dhcp-scriptuser
|
||||||
@@ -977,18 +1112,20 @@ sin una direcci
|
|||||||
.B --dhcp-fqdn
|
.B --dhcp-fqdn
|
||||||
está fijado.
|
está fijado.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp
|
.B --enable-tftp[=<interface>]
|
||||||
Habilitar la función de servidor TFTP. Esto está deliberadamente limitado
|
Habilitar la función de servidor TFTP. Esto está deliberadamente limitado
|
||||||
a lo necesario para hacerle a un cliente un inicio vía red. Solo lectura es
|
a lo necesario para hacerle a un cliente un inicio vía red. Solo lectura es
|
||||||
permitida; las extensiones tsize y blksize son soportadas (tsize solo es
|
permitida; las extensiones tsize y blksize son soportadas (tsize solo es
|
||||||
soportada en modo octeto).
|
soportada en modo octeto). Ver sección de NOTAS para el uso de el argumento
|
||||||
|
de interface.
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-root=<directorio>
|
.B --tftp-root=<directory>[,<interface>]
|
||||||
Buscar, relativo al directorio brindado, archivos para transferir mediante el
|
Buscar, relativo al directorio brindado, archivos para transferir mediante el
|
||||||
uso de TFTP. Cuando esta opción está fijada, paths TFTP que incluyen ".." son
|
uso de TFTP. Cuando esta opción está fijada, paths TFTP que incluyen ".." son
|
||||||
rechazados, para prevenir que clientes salgan de la raíz especificada. Paths
|
rechazados, para prevenir que clientes salgan de la raíz especificada. Paths
|
||||||
absolutos (los que comienzan con "/") están permitidos, pero deben estar
|
absolutos (los que comienzan con "/") están permitidos, pero deben estar
|
||||||
dentro del tftp-root.
|
dentro del tftp-root. Si el argumento opcional de interface es brindado, el
|
||||||
|
directorio es solo usado para pedidos TFTP vía esa interface.
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-unique-root
|
.B --tftp-unique-root
|
||||||
Agregar la dirección IP del cliente TFTP como un componente path del lado del
|
Agregar la dirección IP del cliente TFTP como un componente path del lado del
|
||||||
@@ -1040,11 +1177,13 @@ Especificar un archivo de configuraci
|
|||||||
también es permitida en archivos de configuración, para incluir múltiples
|
también es permitida en archivos de configuración, para incluir múltiples
|
||||||
archivos de configuración.
|
archivos de configuración.
|
||||||
.TP
|
.TP
|
||||||
.B \-7, --conf-dir=<directorio>
|
.B \-7, --conf-dir=<directorio>[,<file-extension>......]
|
||||||
Leer todos los archivos dentro del directorio brindado como archivos
|
Leer todos los archivos dentro del directorio brindado como archivos
|
||||||
de configuración. Archivos cuyos nombres terminen con ~ o comienzen
|
de configuración. Si extensiones son brindadas, cualquier archivo que
|
||||||
con . o comienzen y terminen con # son ignorados. Esta opción puede
|
termine en esas extensiones son ignorados. Cualquier archivos cuyos nombres
|
||||||
ser brindada en la línea de comandos o en un archivo de configuración.
|
terminen con ~ o comienzen con . o comienzen y terminen con # siempre son
|
||||||
|
ignorados. Esta opción puede ser brindada en la línea de comandos o en un
|
||||||
|
archivo de configuración.
|
||||||
.SH ARCHIVO DE CONFIGURACION
|
.SH ARCHIVO DE CONFIGURACION
|
||||||
Al inicio, dnsmasq lee
|
Al inicio, dnsmasq lee
|
||||||
.I /etc/dnsmasq.conf,
|
.I /etc/dnsmasq.conf,
|
||||||
@@ -1174,36 +1313,46 @@ apunta a un nombre sombreado, entonces buscando el CNAME a trav
|
|||||||
dnsmasq resultará en que la dirección no-sombreada será asociada con
|
dnsmasq resultará en que la dirección no-sombreada será asociada con
|
||||||
el destino del CNAME. Para circumventar esto, agregar el CNAME a
|
el destino del CNAME. Para circumventar esto, agregar el CNAME a
|
||||||
/etc/hosts de tal manera que el CNAME es sombreado también.
|
/etc/hosts de tal manera que el CNAME es sombreado también.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
El sistema network-id funciona de la siguiente manera: Para cada pedido
|
El sistema de etiquetas funciona de la siguiente manera: Para cada pedido
|
||||||
DHCP, dnsmasq colecciona un juego de etiquetas network-id válidas,
|
DHCP, dnsmasq colecciona un juego de etiquetas válidas de líneas de
|
||||||
una del
|
configuración activas que incluyen set:<tag>, incluyendo una del
|
||||||
.B dhcp-range
|
.B dhcp-range
|
||||||
usado para alocar la dirección, una de cualquier
|
usado para alocar la dirección, una de cualquier
|
||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
que coincida (y "known" si un dhcp-host coincide), la etiqueta "bootp"
|
que coincida (y "known" si un dhcp-host coincide).
|
||||||
para pedidos BOOTP, una etiqueta cuyo nombre es el nombre de la
|
La etiqueta "bootp" es fijada para pedidos BOOTP, y una etiqueta cuyo
|
||||||
interface donde llegó el pedido, y posiblemente muchas de clases
|
nombre es el nombre de la interface donde llegó el pedido tambien es
|
||||||
de vendedor y usuario que coincidan que hayan sido enviadas por
|
fijada.
|
||||||
el cliente DHCP. Cualquier opción
|
|
||||||
|
Cualquier linea de configuración que incluya uno o mas
|
||||||
|
construcciones tag:<tag> solo será válida si todas las etiquetas
|
||||||
|
coinciden en el juego derivado arriba. Típicamente esto es dhcp-option.
|
||||||
.B dhcp-option
|
.B dhcp-option
|
||||||
que tenga etiquetas network-id será usada en preferencia de una opción
|
que tenga etiquetas será usada en preferencia de una opción
|
||||||
.B dhcp-option,
|
.B dhcp-option,
|
||||||
sin etiqueta, con tal que _todas_ las etiquetas coincidan en alguna
|
sin etiqueta, con tal que _todas_ las etiquetas coincidan en alguna
|
||||||
parte del juego coleccionado describido arriba. El prefijo "#" en una
|
parte del juego coleccionado describido arriba. El prefijo '!' en una
|
||||||
etiqueta significa "no" así que --dhcp=option=#purple,3,1.2.3.4 envía
|
etiqueta significa "no" así que --dhcp=option=tag:!purple,3,1.2.3.4 envía
|
||||||
la opción cuando la etiqueta network-id "purple" no está en el juego
|
la opción cuando la etiqueta "purple" no está en el juego
|
||||||
de etiquetas válidas.
|
de etiquetas válidas. (Si se está usando esto en una línea de comandos
|
||||||
|
en vez de un archivo de configuración, asegurese de escapar !, el cual
|
||||||
|
es un metacaracter de shell.)
|
||||||
|
.PP
|
||||||
|
Nótese que para
|
||||||
|
.B dhcp-range
|
||||||
|
ambos tag:<tag> y set:<tag> son permitidos, para seleccionar el rango
|
||||||
|
en uso basado en (por ejemplo) dhcp-host, y para afectar las opciones
|
||||||
|
enviadas, basadas en el rango seleccionado.
|
||||||
|
|
||||||
|
Este sistema evolucionó de uno anterior mas limitado y para compatibildad
|
||||||
|
reversa "net:" puede ser usada en vez de "tag:" y "set:" puede ser
|
||||||
|
omitida. (Excepto en
|
||||||
|
.B dhcp-host,
|
||||||
|
donde "net:" puede ser usado en vez de "set:".) Por la misma razón, '#'
|
||||||
|
puede ser usado en vez de '!' para indicar NO.
|
||||||
.PP
|
.PP
|
||||||
Si el network-id en un
|
|
||||||
.B dhcp-range
|
|
||||||
es prefijado con "net:", entonces su significado cambia de "fijar
|
|
||||||
etiqueta" a "coincidir con etiqueta". O sea que si hay más de un
|
|
||||||
dhcp-range en en una subred, y uno tiene una etiqueta network-id la
|
|
||||||
cual está fijada (por ejemplo una opción de clase de vendedor) entonces
|
|
||||||
hosts que fijen la etiqueta network-id serán alocados direcciones en
|
|
||||||
el rango etiquetado.
|
|
||||||
.PP
|
|
||||||
El servidor DHCP de dnsmasq funcionará como servidor BOOTP tambien,
|
El servidor DHCP de dnsmasq funcionará como servidor BOOTP tambien,
|
||||||
con tal que las direcciones MAC y IP de los clientes sean brindadas,
|
con tal que las direcciones MAC y IP de los clientes sean brindadas,
|
||||||
ya sea usando configuraciones
|
ya sea usando configuraciones
|
||||||
@@ -1214,11 +1363,54 @@ o en
|
|||||||
.B dhcp-range
|
.B dhcp-range
|
||||||
esté presente para activar el servidor DHCP en una red particular.
|
esté presente para activar el servidor DHCP en una red particular.
|
||||||
(Fijar --bootp-dynamic elimina la necesidad de trazados estáticos.) El
|
(Fijar --bootp-dynamic elimina la necesidad de trazados estáticos.) El
|
||||||
parámetro de nombre de archivos en un pedido BOOTP es revisado para
|
parámetro de nombre de archivos en un pedido BOOTP es usado como
|
||||||
ver si coincide con algún network-id en configuraciónes
|
una etiqueta, al igual que la etiqueta "bootp", permitiendo así algún
|
||||||
.B dhcp-option
|
control sobre las opciones devueltas a diferentes clases de hosts.
|
||||||
al igual que la etiqueta "bootp", permitiendo así algún control sobre
|
|
||||||
las opciones devueltas a diferentes clases de hosts.
|
.B dhcp-range
|
||||||
|
puede tener un nombre de interface brindado como
|
||||||
|
"interface:<interface-name>". La semántica de esto es así:
|
||||||
|
Para DHCP, si cualquier otro dhcp-range existe _sin_ un nombre de
|
||||||
|
interface, entonces el nombre de interface es ignorado y dnsmasq
|
||||||
|
se comporta como si las partes de interface no existieran, de otra forma
|
||||||
|
DHCP solo se provee a interfaces mencionadas en declaraciones
|
||||||
|
dhcp-range. Para DNS, si no hay opciones
|
||||||
|
.B --interface
|
||||||
|
o
|
||||||
|
.B --listen-address
|
||||||
|
el comportamiento no se modifica por la parte de interface. Si cualquiera
|
||||||
|
de estas opciones está presente, las interfaces mencionadas en dhcp-ranges
|
||||||
|
son agregadas all juego que obtienen servicio DNS.
|
||||||
|
|
||||||
|
Similarmente,
|
||||||
|
.B enable-tftp
|
||||||
|
puede tomar un nombre de interface, el cual habilita TFTP solo para una
|
||||||
|
interface en particular, ignorando opciones
|
||||||
|
.B --interface
|
||||||
|
o
|
||||||
|
.B --listen-address.
|
||||||
|
Adicionalmente,
|
||||||
|
.B --tftp-secure
|
||||||
|
y
|
||||||
|
.B --tftp-unique-root
|
||||||
|
y
|
||||||
|
.B --tftp-no-blocksize
|
||||||
|
son ignorados por pedidos desde dichas interfaces. (Una directiva
|
||||||
|
.B --tftp-root
|
||||||
|
brindando un path raíz y una interface debe ser brindada tambien.)
|
||||||
|
|
||||||
|
Estas reglas pueden parecer raras a primera vista, pero permiten que
|
||||||
|
una simple linea de la forma
|
||||||
|
"dhcp-range=interface:virt0,192.168.0.4,192.168.0.200" sea agregada a
|
||||||
|
configuración dnsmasq, lo cual brinda servicios DHCP y DNS a esa interface,
|
||||||
|
sin afectar los servicios en otras interfaces y irrespectivamente de
|
||||||
|
la existencia o no de lineas "interface=<interface>" en alguna otra parte
|
||||||
|
de la configuración dnsmasq.
|
||||||
|
"enable-tftp=virt0" y "tftp-root=<root>,virt0" hacen el mismo trabajo
|
||||||
|
para TFTP.
|
||||||
|
La idea es que una linea así pueda ser agregada automaticamente
|
||||||
|
por libvirt o sistemas equivalentes, sin estorbar alguna
|
||||||
|
configuración manual.
|
||||||
|
|
||||||
.SH CÓDIGOS EXIT
|
.SH CÓDIGOS EXIT
|
||||||
.PP
|
.PP
|
||||||
@@ -1251,10 +1443,8 @@ no escalaban tan bien.
|
|||||||
|
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq es capaz de soportar con DNS y DHCP a por lo menos mil (1,000)
|
Dnsmasq es capaz de soportar con DNS y DHCP a por lo menos mil (1,000)
|
||||||
clientes. Por supuesto que para lograr esto debe aumentarse el valor de
|
clientes. Los tiempos de arriendo no deben ser muy cortos (menos
|
||||||
.B --dhcp-lease-max
|
de una hora). El valor de
|
||||||
, y tiempos de arriendo no deben ser muy cortos (menos de una hora).
|
|
||||||
El valor de
|
|
||||||
.B --dns-forward-max
|
.B --dns-forward-max
|
||||||
puede ser aumentado: comienze con el equivalente a el número de clientes y
|
puede ser aumentado: comienze con el equivalente a el número de clientes y
|
||||||
auméntelo si parece lento el DNS. Nótese que el rendimiento DNS depende
|
auméntelo si parece lento el DNS. Nótese que el rendimiento DNS depende
|
||||||
@@ -1285,6 +1475,23 @@ o en un archivo hosts adicional. La lista puede ser muy larga. Dnsmasq ha sido
|
|||||||
probado exitósamente con un millón de nombres. Ese tamaño de archivo necesita
|
probado exitósamente con un millón de nombres. Ese tamaño de archivo necesita
|
||||||
un CPU de 1GHz y aproximadamente 60MB de RAM.
|
un CPU de 1GHz y aproximadamente 60MB de RAM.
|
||||||
|
|
||||||
|
.SH INTERNACIONALIZACION
|
||||||
|
|
||||||
|
Dnsmasq puede ser compilado con soporte para internacionalización. Para hacer esto,
|
||||||
|
los targets make "all-i18n" y "install-i18n" deberán ser usados en vez de
|
||||||
|
los targets estándares "all" y "install". Cuando internacionalización es
|
||||||
|
compilada, dnsmasq producirá mensajes de bitácora en el lenguaje local y soportará
|
||||||
|
dominios internacionalizados (IDN). Nombres de dominio en /etc/hosts, /etc/ethers,
|
||||||
|
y /etc/dnsmasq.conf que contienen carácteres no-ASCII serán traducidos a
|
||||||
|
representación interna DNS punycode. Nótese que dnsmasq determina ambos el
|
||||||
|
lenguaje para mensajes y el juego de carácteres asumido para archivos de configuración
|
||||||
|
de la variable ambiental LANG. Esto debe estar fijado al valor predeterminado del sistema
|
||||||
|
por el guión responsable de iniciar dnsmasq. Al editar archivos de configuración,
|
||||||
|
tener cuidado de hacerlo usando solo el locale predeterminado del sistema y no
|
||||||
|
uno especifico del usuario, dado a que dnsmasq no tiene ninguna manera directa de
|
||||||
|
determinar el juego de caracteres en uso, y debe asumir que es el predeterminado
|
||||||
|
del sistema.
|
||||||
|
|
||||||
.SH ARCHIVOS
|
.SH ARCHIVOS
|
||||||
.IR /etc/dnsmasq.conf
|
.IR /etc/dnsmasq.conf
|
||||||
|
|
||||||
|
|||||||
+396
-150
@@ -22,7 +22,7 @@ peut être configuré pour envoyer n'importe quel option DHCP.
|
|||||||
Il inclut un serveur TFTP sécurisé en lecture seule permettant le démarrage via
|
Il inclut un serveur TFTP sécurisé en lecture seule permettant le démarrage via
|
||||||
le réseau/PXE de clients DHCP et supporte également le protocole BOOTP.
|
le réseau/PXE de clients DHCP et supporte également le protocole BOOTP.
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq supporte IPv6 pour le DNS mais pas pour le DHCP.
|
Dnsmasq supporte IPv6 pour le DNS et TFTP mais pas pour le DHCP.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
Notes : Il est possible d'utiliser des options sans leur donner de paramètre.
|
Notes : Il est possible d'utiliser des options sans leur donner de paramètre.
|
||||||
Dans ce cas, la fonction correspondante sera désactivée. Par exemple
|
Dans ce cas, la fonction correspondante sera désactivée. Par exemple
|
||||||
@@ -73,6 +73,12 @@ option permet de doner une valeur de durée de vie par défaut (en secondes) que
|
|||||||
dnsmasq utilise pour mettre les réponses négatives dans son cache, même en
|
dnsmasq utilise pour mettre les réponses négatives dans son cache, même en
|
||||||
l'absence d'enregistrement SOA.
|
l'absence d'enregistrement SOA.
|
||||||
.TP
|
.TP
|
||||||
|
.B --max-ttl=<durée>
|
||||||
|
Définie la valeur de TTL maximum qui sera fournie aux clients. La valeur maximum
|
||||||
|
de TTL spécifiée sera fournie aux clients en remplacement de la vraie valeur de TTL
|
||||||
|
si cette dernière est supérieure. La valeur réelle de TTL est cependant conservée dans
|
||||||
|
le cache afin d'éviter de saturer les serveurs DNS en amont.
|
||||||
|
.TP
|
||||||
.B \-k, --keep-in-foreground
|
.B \-k, --keep-in-foreground
|
||||||
Ne pas aller en tâche de fond au lancement, mais en dehors de cela, fonctionner
|
Ne pas aller en tâche de fond au lancement, mais en dehors de cela, fonctionner
|
||||||
normalement. Ce mode est prévu pour les cas où Dnsmasq est lancé par daemontools
|
normalement. Ce mode est prévu pour les cas où Dnsmasq est lancé par daemontools
|
||||||
@@ -94,10 +100,12 @@ réception d'un signal SIGUSR1.
|
|||||||
Définit la "facility" dans laquelle Dnsmasq enverra ses entrées syslog, par
|
Définit la "facility" dans laquelle Dnsmasq enverra ses entrées syslog, par
|
||||||
défaut DAEMON ou LOCAL0 si le mode debug est activé. Si la "facility" contient
|
défaut DAEMON ou LOCAL0 si le mode debug est activé. Si la "facility" contient
|
||||||
au moins un caractère "/", alors Dnsmasq considère qu'il s'agit d'un fichier et
|
au moins un caractère "/", alors Dnsmasq considère qu'il s'agit d'un fichier et
|
||||||
enverra les logs dans le fichier correspondant à la place du syslog. (Les
|
enverra les logs dans le fichier correspondant à la place du syslog. Si la
|
||||||
erreurs lors de la lecture de la configuration vont toujours vers le syslog,
|
"facility" est '-', alors dnsmasq envoie les logs sur la sortie d'erreur
|
||||||
mais tous les messages postérieures à un démarrage réussi seront exclusivement
|
standard stderr. (Les erreurs lors de la lecture de la configuration vont
|
||||||
envoyés vers le fichier de logs). Lorsque Dnsmasq est configuré pour envoyer
|
toujours vers le syslog, mais tous les messages postérieurs à un démarrage
|
||||||
|
réussi seront exclusivement envoyés vers le fichier de logs).
|
||||||
|
Lorsque Dnsmasq est configuré pour envoyer
|
||||||
ses traces vers un fichier, la réception d'un signal SIGUSR2 entraine la
|
ses traces vers un fichier, la réception d'un signal SIGUSR2 entraine la
|
||||||
fermeture et réouverture du fichier. Cela permet la rotation de fichiers de
|
fermeture et réouverture du fichier. Cela permet la rotation de fichiers de
|
||||||
traces sans nécessiter l'arrêt de Dnsmasq.
|
traces sans nécessiter l'arrêt de Dnsmasq.
|
||||||
@@ -140,8 +148,7 @@ que le DHCP ou le TFTP.
|
|||||||
.TP
|
.TP
|
||||||
.B \-P, --edns-packet-max=<taille>
|
.B \-P, --edns-packet-max=<taille>
|
||||||
Spécifie la taille maximum de paquet UDP EDNS.0 supporté par le relai DNS. Le
|
Spécifie la taille maximum de paquet UDP EDNS.0 supporté par le relai DNS. Le
|
||||||
défaut est de 1280, qui est la valeur maximale
|
défaut est de 4096, qui est la valeur recommandée dans la RFC5625.
|
||||||
recommandée pour ethernet dans la RFC2671.
|
|
||||||
.TP
|
.TP
|
||||||
.B \-Q, --query-port=<numéro de port>
|
.B \-Q, --query-port=<numéro de port>
|
||||||
Envoie et écoute les requêtes DNS sortantes depuis le port UDP spécifié par
|
Envoie et écoute les requêtes DNS sortantes depuis le port UDP spécifié par
|
||||||
@@ -318,6 +325,19 @@ serveurs amonts suite à une résolution de nom. Cela bloque les attaques cherch
|
|||||||
à détourner de leur usage les logiciels de navigation web ('browser') en s'en
|
à détourner de leur usage les logiciels de navigation web ('browser') en s'en
|
||||||
servant pour découvrir les machines situées sur le réseau local.
|
servant pour découvrir les machines situées sur le réseau local.
|
||||||
.TP
|
.TP
|
||||||
|
.B --rebind-localhost-ok
|
||||||
|
Exclue 127.0.0/8 des vérifications de réassociation DNS. Cette gamme d'adresses
|
||||||
|
est retournée par les serveurs Realtime Blackhole (RBL, utilisés dans la
|
||||||
|
lutte contre le spam), la bloquer peut entraîner des disfonctionnements de ces
|
||||||
|
services.
|
||||||
|
.TP
|
||||||
|
.B --rebind-domain-ok=[<domaine>]|[[/<domaine>/[<domaine>/]
|
||||||
|
Ne pas détecter ni bloquer les actions de type dns-rebind pour ces domaines.
|
||||||
|
Cette option peut prendre comme valeur soit un nom de domaine soit plusieurs
|
||||||
|
noms de domains entourés par des '/', selon une syntaxe similaire à l'option
|
||||||
|
--server, c-à-d :
|
||||||
|
.B --rebind-domain-ok=/domaine1/domaine2/domaine3/
|
||||||
|
.TP
|
||||||
.B \-n, --no-poll
|
.B \-n, --no-poll
|
||||||
Ne pas vérifier régulièrement si le fichier /etc/resolv.conf a été modifié.
|
Ne pas vérifier régulièrement si le fichier /etc/resolv.conf a été modifié.
|
||||||
.TP
|
.TP
|
||||||
@@ -355,6 +375,20 @@ option
|
|||||||
.B -S
|
.B -S
|
||||||
est autorisée, en répétant les domaines et adresses IP comme requis.
|
est autorisée, en répétant les domaines et adresses IP comme requis.
|
||||||
|
|
||||||
|
Le domaine le plus spécifique l'emporte sur le domaine le moins spécifique,
|
||||||
|
ainsi :
|
||||||
|
.B --server=/google.com/1.2.3.4
|
||||||
|
.B --server=/www.google.com/2.3.4.5
|
||||||
|
enverra les requêtes pour *.google.com à 1.2.3.4, à l'exception des requêtes
|
||||||
|
*www.google.com, qui seront envoyées à 2.3.4.5.
|
||||||
|
|
||||||
|
L'adresse spéciale '#' signifie "utiliser les serveurs standards", ainsi
|
||||||
|
.B --server=/google.com/1.2.3.4
|
||||||
|
.B --server=/www.google.com/#
|
||||||
|
enverra les requêtes pour *.google.com à 1.2.3.4, à l'exception des requêtes
|
||||||
|
pour *www.google.com qui seront envoyées comme d'habitude (c-à-d aux serveurs
|
||||||
|
définis par défaut).
|
||||||
|
|
||||||
Il est également permis de donner une option
|
Il est également permis de donner une option
|
||||||
.B -S
|
.B -S
|
||||||
avec un nom de domaine mais sans
|
avec un nom de domaine mais sans
|
||||||
@@ -457,7 +491,10 @@ retournés dans la réponse.
|
|||||||
.B \-Y, --txt-record=<nom>[[,<texte>],<texte>]
|
.B \-Y, --txt-record=<nom>[[,<texte>],<texte>]
|
||||||
Définit un enregistrement DNS de type TXT. La valeur de l'enregistrement TXT est
|
Définit un enregistrement DNS de type TXT. La valeur de l'enregistrement TXT est
|
||||||
un ensemble de chaînes de caractères, donc un nombre variable de chaînes de
|
un ensemble de chaînes de caractères, donc un nombre variable de chaînes de
|
||||||
caractères peuvent être spécifiées, séparées par des virgules.
|
caractères peuvent être spécifiées, séparées par des virgules. Utilisez des
|
||||||
|
guillemets pour mettre une virgule dans une chaîne de caractères. Notez que la
|
||||||
|
longueur maximale pour une chaîne est de 255 caractères, les chaînes plus
|
||||||
|
longues étant découpées en morceaux de 255 caractères de longs.
|
||||||
.TP
|
.TP
|
||||||
.B --ptr-record=<nom>[,<cible>]
|
.B --ptr-record=<nom>[,<cible>]
|
||||||
Définit un enregistrement DNS de type PTR.
|
Définit un enregistrement DNS de type PTR.
|
||||||
@@ -485,6 +522,16 @@ Plus d'un nom peut être associé à une interface donnée en répétant cette o
|
|||||||
plusieurs fois; dans ce cas, l'enregistrement inverse pointe vers le nom fourni
|
plusieurs fois; dans ce cas, l'enregistrement inverse pointe vers le nom fourni
|
||||||
dans la première instance de cette option.
|
dans la première instance de cette option.
|
||||||
.TP
|
.TP
|
||||||
|
.B --add-mac
|
||||||
|
Ajoute l'adresse MAC du requêteur aux requêtes DNS transmises aux serveurs
|
||||||
|
amonts. Cela peut être utilisé dans un but de filtrage DNS par les serveurs
|
||||||
|
amonts. L'adresse MAC peut uniquement être ajoutée si le requêteur est sur le
|
||||||
|
même sous-réseau que le serveur dnsmasq. Veuillez noter que le mécanisme
|
||||||
|
utilisé pour effectuer cela (une option EDNS0) n'est pas encore standardisée,
|
||||||
|
aussi cette fonctionalité doit être considérée comme expérimentale. Notez
|
||||||
|
également qu'exposer les adresses MAC de la sorte peut avoir des implications
|
||||||
|
en termes de sécurité et de vie privée.
|
||||||
|
.TP
|
||||||
.B \-c, --cache-size=<taille>
|
.B \-c, --cache-size=<taille>
|
||||||
Définit la taille du cache de Dnsmasq. La valeur par défaut est de 150 noms.
|
Définit la taille du cache de Dnsmasq. La valeur par défaut est de 150 noms.
|
||||||
Définir une valeur de zéro désactive le cache.
|
Définir une valeur de zéro désactive le cache.
|
||||||
@@ -503,7 +550,22 @@ lorsqu'un serveur web a la résolution de nom activée pour l'enregistrement de
|
|||||||
son journal des requêtes, ce qui peut générer un nombre important de requêtes
|
son journal des requêtes, ce qui peut générer un nombre important de requêtes
|
||||||
simultanées.
|
simultanées.
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[[net:]identifiant de réseau,]<adresse de début>,<adresse de fin>[[,<masque de réseau>],<broadcast>][,<durée de bail>]
|
.B --proxy-dnssec
|
||||||
|
Un resolveur sur une machine cliente peut effectuer la validation DNSSEC de
|
||||||
|
deux façons : il peut effectuer lui-même les opérations de chiffrements sur
|
||||||
|
la réponse reçue, ou il peut laisser le serveur récursif amont faire la
|
||||||
|
validation et positionner un drapeau dans la réponse au cas où celle-ci est
|
||||||
|
correcte. Dnsmasq n'est pas un validateur DNSSEC, aussi il ne peut effectuer
|
||||||
|
la validation comme un serveur de nom récursif, cependant il peut retransmettre
|
||||||
|
les résultats de validation de ses serveurs amonts. Cette option permet
|
||||||
|
l'activation de cette fonctionalité. Vous ne devriez utiliser cela que si vous
|
||||||
|
faites confiance aux serveurs amonts
|
||||||
|
.I ainsi que le réseau entre vous et eux.
|
||||||
|
Si vous utilisez le premier mode DNSSEC, la validation par le resolveur des
|
||||||
|
clients, cette option n'est pas requise. Dnsmasq retourne toujours toutes les
|
||||||
|
données nécessaires par un client pour effectuer la validation lui-même.
|
||||||
|
.TP
|
||||||
|
.B \-F, --dhcp-range=[interface:<interface>,][tag:<label>[,tag:<label>],][set:<label],]<adresse de début>,<adresse de fin>[,<masque de réseau>[,<broadcast>]][,<durée de bail>]
|
||||||
Active le serveur DHCP. Les adresses seront données dans la plage comprise entre
|
Active le serveur DHCP. Les adresses seront données dans la plage comprise entre
|
||||||
<adresse de début> et <adresse de fin> et à partir des adresses définies
|
<adresse de début> et <adresse de fin> et à partir des adresses définies
|
||||||
statiquement dans l'option
|
statiquement dans l'option
|
||||||
@@ -523,10 +585,11 @@ relais DHCP ("relay agent"). L'adresse de broadcast est toujours optionnelle.
|
|||||||
|
|
||||||
Il est toujours possible d'avoir plus d'une plage DHCP pour un même
|
Il est toujours possible d'avoir plus d'une plage DHCP pour un même
|
||||||
sous-réseau.
|
sous-réseau.
|
||||||
|
L'identifiant de label optionnel
|
||||||
L'identifiant de réseau optionnel est un label alphanumérique qui permet de
|
.B set:<label>
|
||||||
marquer ce réseau afin de fournir des options DHCP spécifiques à chaque réseau.
|
fournie une étiquette alphanumérique qui identifie ce réseau, afin de permettre
|
||||||
Lorsque préfixé par 'net:', la signification change est au lieu de définir un
|
la fourniture d'options DHCP spécifiques à chaque réseau.
|
||||||
|
Lorsque préfixé par 'tag:', la signification change, et au lieu de définir un
|
||||||
label, il définit le label pour laquelle la règle s'applique. Un seul label peut-
|
label, il définit le label pour laquelle la règle s'applique. Un seul label peut-
|
||||||
être défini mais plusieurs labels peuvent coïncider.
|
être défini mais plusieurs labels peuvent coïncider.
|
||||||
|
|
||||||
@@ -546,8 +609,11 @@ spécifié. (voir
|
|||||||
et
|
et
|
||||||
.B pxe-service
|
.B pxe-service
|
||||||
pour plus de détails).
|
pour plus de détails).
|
||||||
|
|
||||||
|
La section interface:<nom d'interface> n'est normalement pas utilisée. Se
|
||||||
|
référer aux indications de la section NOTES pour plus de détail à ce sujet.
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<adresse matérielle>][,id:<identifiant client>|*][,net:<identifiant de réseau>][,<adresse IP>][,<nom d'hôte>][,<durée de bail>][,ignore]
|
.B \-G, --dhcp-host=[<adresse matérielle>][,id:<identifiant client>|*][,set:<label>][,<adresse IP>][,<nom d'hôte>][,<durée de bail>][,ignore]
|
||||||
Spécifie les paramètres DHCP relatifs à un hôte. Cela permet à une machine
|
Spécifie les paramètres DHCP relatifs à un hôte. Cela permet à une machine
|
||||||
possédant une adresse matérielle spécifique de se voir toujours allouée les
|
possédant une adresse matérielle spécifique de se voir toujours allouée les
|
||||||
mêmes nom d'hôte, adresse IP et durée de bail. Un nom d'hôte spécifié comme
|
mêmes nom d'hôte, adresse IP et durée de bail. Un nom d'hôte spécifié comme
|
||||||
@@ -561,9 +627,15 @@ spécifie à Dnsmasq de fournir à la machine d'adresse matérielle
|
|||||||
|
|
||||||
.B --dhcp-host=lap,192.168.0.199
|
.B --dhcp-host=lap,192.168.0.199
|
||||||
spécifie à Dnsmasq d'allouer toujours à la machine portant le nom lap
|
spécifie à Dnsmasq d'allouer toujours à la machine portant le nom lap
|
||||||
l'adresse IP 92.168.0.199. Les adresses allouées comme ceci ne sont pas
|
l'adresse IP 192.168.0.199.
|
||||||
contraintes dans une plage d'adresse spécifiée par une option --dhcp-range, mais
|
|
||||||
elles doivent être sur un réseau servi par le serveur DHCP. Il est possible
|
Les adresses allouées de la sorte ne sont pas contraintes à une plage d'adresse
|
||||||
|
spécifiée par une option --dhcp-range, mais elles se trouver dans le même
|
||||||
|
sous-réseau qu'une plage dhcp-range valide. Pour les sous-réseaux qui n'ont pas
|
||||||
|
besoin d'adresses dynamiquement allouées, utiliser le mot-clef "static" dans la
|
||||||
|
déclaration de plage d'adresses dhcp-range.
|
||||||
|
|
||||||
|
Il est possible
|
||||||
d'utiliser des identifiants clients plutôt que des adresses matérielles pour
|
d'utiliser des identifiants clients plutôt que des adresses matérielles pour
|
||||||
identifier les hôtes, en préfixant par ceux-ci par 'id:'. Ainsi,
|
identifier les hôtes, en préfixant par ceux-ci par 'id:'. Ainsi,
|
||||||
.B --dhcp-host=id:01:02:03:04,.....
|
.B --dhcp-host=id:01:02:03:04,.....
|
||||||
@@ -579,7 +651,13 @@ identifiant client mais pas les autres.
|
|||||||
Si un nom apparaît dans /etc/hosts, l'adresse associée peut être allouée à un
|
Si un nom apparaît dans /etc/hosts, l'adresse associée peut être allouée à un
|
||||||
bail DHCP mais seulement si une option
|
bail DHCP mais seulement si une option
|
||||||
.B --dhcp-host
|
.B --dhcp-host
|
||||||
spécifiant le nom existe par ailleurs. Le mot clef "ignore" ("ignorer") indique
|
spécifiant le nom existe par ailleurs. Seul un nom d'hôte peut-être donné dans
|
||||||
|
une option
|
||||||
|
.B dhcp-host
|
||||||
|
, mais les alias sont possibles au travers de l'utilisation des CNAMEs. (Voir
|
||||||
|
.B --cname
|
||||||
|
).
|
||||||
|
Le mot clef "ignore" ("ignorer") indique
|
||||||
à Dnsmasq de ne jamais fournir de bail DHCP à une machine. La machine peut être
|
à Dnsmasq de ne jamais fournir de bail DHCP à une machine. La machine peut être
|
||||||
spécifiée par son adresse matérielle, son identifiant client ou son nom d'hôte.
|
spécifiée par son adresse matérielle, son identifiant client ou son nom d'hôte.
|
||||||
Par exemple
|
Par exemple
|
||||||
@@ -587,14 +665,15 @@ Par exemple
|
|||||||
Cela est utile lorsqu'un autre serveur DHCP sur le réseau doit être utilisé par
|
Cela est utile lorsqu'un autre serveur DHCP sur le réseau doit être utilisé par
|
||||||
certaines machines.
|
certaines machines.
|
||||||
|
|
||||||
Le paramètre net:<identifiant réseau> permet de définir un
|
Le paramètre set:<identifiant réseau> permet de définir un
|
||||||
identifiant de réseau lorsque l'option dhcp-host est utilisée. Cela peut servir
|
identifiant de réseau lorsque l'option dhcp-host est utilisée. Cela peut servir
|
||||||
à sélectionner des options DHCP juste pour cet hôte. Lorsqu'une machine coïncide
|
à sélectionner des options DHCP juste pour cet hôte. Plus d'un label peut être
|
||||||
avec une directive dhcp-host (ou une impliquée par /etc/ethers), alors
|
fourni dans une directive dhcp-host (et dans cette seule directive). Lorsqu'une
|
||||||
l'identifiant réseau réservé "known" ("connu") est associé. Cela permet à
|
machine coïncide avec une directive dhcp-host (ou une impliquée par
|
||||||
|
/etc/ethers), alors le label réservé "known" ("connu") est associé. Cela permet à
|
||||||
Dnsmasq d'être configuré pour ignorer les requêtes issus de machines inconnue
|
Dnsmasq d'être configuré pour ignorer les requêtes issus de machines inconnue
|
||||||
par le biais de
|
par le biais de
|
||||||
.B --dhcp-ignore=#known.
|
.B --dhcp-ignore=tag:!known.
|
||||||
|
|
||||||
Les adresses ethernet (mais pas les identifiants clients) peuvent être définies
|
Les adresses ethernet (mais pas les identifiants clients) peuvent être définies
|
||||||
avec des octets joker, ainsi par exemple
|
avec des octets joker, ainsi par exemple
|
||||||
@@ -623,20 +702,24 @@ donné et dnsmasq n'a aucun moyen de s'assurer de cela. Cela est utile,
|
|||||||
par exemple, pour allouer une adresse IP stable à un laptop qui
|
par exemple, pour allouer une adresse IP stable à un laptop qui
|
||||||
aurait à la fois une connexion filaire et sans-fil.
|
aurait à la fois une connexion filaire et sans-fil.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-hostsfile=<fichier>
|
.B --dhcp-hostsfile=<chemin>
|
||||||
Lis les informations d'hôtes DHCP dans le fichier spécifié. Le fichier contient
|
Lis les informations d'hôtes DHCP dans le fichier spécifié. Si l'argument est
|
||||||
des informations à raison d'un hôte par ligne. Le format d'une ligne est la même
|
un chemin vers un répertoire, lis tous les fichiers de ce répertoire. Le
|
||||||
que le texte fourni à la droite sur caractère "=" dans l'option
|
fichier contient des informations à raison d'un hôte par ligne. Le format
|
||||||
|
d'une ligne est la même que le texte fourni à la droite sur caractère "=" dans
|
||||||
|
l'option
|
||||||
.B --dhcp-host.
|
.B --dhcp-host.
|
||||||
L'avantage de stocker les informations sur les hôtes DHCP dans ce fichier est
|
L'avantage de stocker les informations sur les hôtes DHCP dans ce fichier est
|
||||||
que celles-ci peuvent être modifiées sans recharger Dnsmasq; le fichier sera
|
que celles-ci peuvent être modifiées sans recharger Dnsmasq; le fichier sera
|
||||||
relu lorsque Dnsmasq reçoit un signal SIGHUP.
|
relu lorsque Dnsmasq reçoit un signal SIGHUP.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-optsfile=<fichier>
|
.B --dhcp-optsfile=<chemin>
|
||||||
Lis les informations relatives aux options DHCP dans le fichier spécifié.
|
Lis les informations relatives aux options DHCP dans le fichier spécifié. Si
|
||||||
L'intérêt d'utiliser cette option est le même que pour --dhcp-hostsfile : le
|
l'argument est un chemin vers un répertoire, lis tous les fichiers de ce
|
||||||
fichier spécifié sera rechargé à la réception par dnsmasq d'un signal SIGHUP.
|
répertoire. L'intérêt d'utiliser cette option est le même que pour
|
||||||
Notez qu'il est possible d'encoder l'information via
|
--dhcp-hostsfile : le fichier spécifié sera rechargé à la réception par
|
||||||
|
dnsmasq d'un signal SIGHUP. Notez qu'il est possible d'encoder l'information
|
||||||
|
via
|
||||||
.B --dhcp-boot
|
.B --dhcp-boot
|
||||||
en utilisant les noms optionnels bootfile-name, server-ip-address et
|
en utilisant les noms optionnels bootfile-name, server-ip-address et
|
||||||
tftp-server. Ceci permet d'inclure ces options dans un fichier "dhcp-optsfile".DNSMASQ_SUPPLIED_HOSTNAME
|
tftp-server. Ceci permet d'inclure ces options dans un fichier "dhcp-optsfile".DNSMASQ_SUPPLIED_HOSTNAME
|
||||||
@@ -650,7 +733,7 @@ par Dnsmasq, ces lignes ont exactement le même effet que l'option
|
|||||||
contenant les mêmes informations. /etc/ethers est relu à la réception d'un
|
contenant les mêmes informations. /etc/ethers est relu à la réception d'un
|
||||||
signal SIGHUP par Dnsmasq.
|
signal SIGHUP par Dnsmasq.
|
||||||
.TP
|
.TP
|
||||||
.B \-O, --dhcp-option=[<identifiant_de_réseau>,[<identifiant_de_réseau>,]][encap:<option>,][vendor:[<classe_vendeur>],][<option>|option:<nom d'option>],[<valeur>[,<valeur>]]
|
.B \-O, --dhcp-option=[tag:<label>,[tag:<label>]][encap:<option>,][vi-encap:<entreprise>,][vendor:[<classe_vendeur>],][<option>|option:<nom d'option>],[<valeur>[,<valeur>]]
|
||||||
Spécifie des options différentes ou supplémentaires pour des clients DHCP. Par
|
Spécifie des options différentes ou supplémentaires pour des clients DHCP. Par
|
||||||
défaut, Dnsmasq envoie un ensemble standard d'options aux clients DHCP : le
|
défaut, Dnsmasq envoie un ensemble standard d'options aux clients DHCP : le
|
||||||
masque de réseau et l'adresse de broadcast sont les mêmes que pour l'hôte
|
masque de réseau et l'adresse de broadcast sont les mêmes que pour l'hôte
|
||||||
@@ -676,8 +759,8 @@ L'adresse 0.0.0.0 prends ici le sens "d'adresse de la machine sur laquelle
|
|||||||
tourne Dnsmasq". Les types de données autorisées sont des adresses IP sous la
|
tourne Dnsmasq". Les types de données autorisées sont des adresses IP sous la
|
||||||
forme de 4 chiffres séparés par des points, un nombre décimal, une liste de
|
forme de 4 chiffres séparés par des points, un nombre décimal, une liste de
|
||||||
caractères hexadécimaux séparés par des 2 points, ou une chaîne de caractères.
|
caractères hexadécimaux séparés par des 2 points, ou une chaîne de caractères.
|
||||||
Si des identifiants de réseaux sont fournis, alors cette option n'est envoyée
|
Si des labels optionnels sont fournis, alors cette option n'est envoyée
|
||||||
qu'aux réseaux dont tous les identifiants coïncident.
|
qu'aux réseaux dont tous les labels coïncident avec ceux de la requête.
|
||||||
|
|
||||||
Un traitement spécial est effectué sur les chaînes de caractères fournies pour
|
Un traitement spécial est effectué sur les chaînes de caractères fournies pour
|
||||||
l'option 119, conformément à la RFC 3397. Les chaînes de caractères ou les
|
l'option 119, conformément à la RFC 3397. Les chaînes de caractères ou les
|
||||||
@@ -729,10 +812,17 @@ Plusieurs options encapsulées avec le même numéro d'option seront correctemen
|
|||||||
combinées au sein d'une seule option encapsulée. Il n'est pas possible de
|
combinées au sein d'une seule option encapsulée. Il n'est pas possible de
|
||||||
spécifier encap: et vendor: au sein d'une même option dhcp.
|
spécifier encap: et vendor: au sein d'une même option dhcp.
|
||||||
|
|
||||||
|
La dernière variante pour les options encapsulées est "l'option de Vendeur
|
||||||
|
identifiant le vendeur" ("Vendor-Identifying Vendor Options") telle que
|
||||||
|
décrite dans le RFC3925. Celles-ci sont spécifiées comme suit :
|
||||||
|
.B --dhcp-option=vi-encap:2, 10, "text"
|
||||||
|
Le numéro dans la section vi-encap: est le numéro IANA de l'entreprise servant
|
||||||
|
à identifier cette option.
|
||||||
|
|
||||||
L'adresse 0.0.0.0 n'est pas traitée de manière particulière lorsque fournie dans
|
L'adresse 0.0.0.0 n'est pas traitée de manière particulière lorsque fournie dans
|
||||||
une option encapsulée.
|
une option encapsulée.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-option-force=[<identifiant de réseau>,[<identifiant de réseau>,]][encap:<option>,][vendor:[<classe de vendeur>],]<option>,[<valeur>[,<valeur>]]
|
.B --dhcp-option-force=[tag:<label>,[tag:<label>]][encap:<option>,][vi-encap:<entreprise>,][vendor:[<classe_vendeur>],][<option>|option:<nom d'option>],[<valeur>[,<valeur>]]
|
||||||
Cela fonctionne exactement de la même façon que
|
Cela fonctionne exactement de la même façon que
|
||||||
.B --dhcp-option
|
.B --dhcp-option
|
||||||
sauf que cette option sera toujours envoyée, même si le client ne la demande pas
|
sauf que cette option sera toujours envoyée, même si le client ne la demande pas
|
||||||
@@ -750,22 +840,25 @@ quelques rares cas, perturber des clients vieux ou défectueux. Cette
|
|||||||
option force le comportement à l'utilisation des valeurs "simples et sûres"
|
option force le comportement à l'utilisation des valeurs "simples et sûres"
|
||||||
afin d'éviter des problèmes dans de tels cas.
|
afin d'éviter des problèmes dans de tels cas.
|
||||||
.TP
|
.TP
|
||||||
.B \-U, --dhcp-vendorclass=<identifiant de réseau>,<classe de vendeur>
|
.B \-U, --dhcp-vendorclass=set:<label>,<classe de vendeur>
|
||||||
Associe une chaîne de classe de vendeur à un indentifiant de réseau. La plupart
|
Associe une chaîne de classe de vendeur à un label. La plupart
|
||||||
des clients DHCP fournissent une "classe de vendeur" ("vendor class") qui
|
des clients DHCP fournissent une "classe de vendeur" ("vendor class") qui
|
||||||
représente, d'une certaine façon, le type d'hôte. Cette option associe des
|
représente, d'une certaine façon, le type d'hôte. Cette option associe des
|
||||||
classes de vendeur à des labels, de telle sorte que des options DHCP peuvent-être
|
classes de vendeur à des labels, de telle sorte que des options DHCP peuvent-être
|
||||||
fournie de manière sélective aux différentes classes d'hôtes. Par exemple,
|
fournie de manière sélective aux différentes classes d'hôtes. Par exemple,
|
||||||
|
.B dhcp-vendorclass=set:printers,Hewlett-Packard JetDirect
|
||||||
|
ou
|
||||||
.B dhcp-vendorclass=printers,Hewlett-Packard JetDirect
|
.B dhcp-vendorclass=printers,Hewlett-Packard JetDirect
|
||||||
permet de n'allouer des options qu'aux imprimantes HP de la manière suivante :
|
permet de n'allouer des options qu'aux imprimantes HP de la manière suivante :
|
||||||
.B --dhcp-option=printers,3,192.168.4.4
|
.B --dhcp-option=tag:printers,3,192.168.4.4
|
||||||
La chaîne de caractères de la classe de vendeur founie en argument est cherchée
|
La chaîne de caractères de la classe de vendeur founie en argument est cherchée
|
||||||
en temps que sous-chaîne de caractères au sein de la classe de vendeur fournie
|
en temps que sous-chaîne de caractères au sein de la classe de vendeur fournie
|
||||||
par le client, de façon à permettre la recherche d'un sous-ensemble de la chaîne
|
par le client, de façon à permettre la recherche d'un sous-ensemble de la chaîne
|
||||||
de caractères ("fuzzy matching").
|
de caractères ("fuzzy matching"). Le préfixe set: est optionnel mais autorisé
|
||||||
|
afin de conserver une certaine homogénéité.
|
||||||
.TP
|
.TP
|
||||||
.B \-j, --dhcp-userclass=<identifiant de réseau>,<classe utilisateur>
|
.B \-j, --dhcp-userclass=set:<label>,<classe utilisateur>
|
||||||
Associe une chaîne de classe d'utilisateur à un identifiant réseau (effectue la
|
Associe une chaîne de classe d'utilisateur à un label (effectue la
|
||||||
recherche sur des sous-chaînes, comme pour les classes de vendeur). La plupart
|
recherche sur des sous-chaînes, comme pour les classes de vendeur). La plupart
|
||||||
des clients permettent de configurer une "classe d'utilisateur". Cette option
|
des clients permettent de configurer une "classe d'utilisateur". Cette option
|
||||||
associe une classe d'utilisateur à un label, de telle manière qu'il soit
|
associe une classe d'utilisateur à un label, de telle manière qu'il soit
|
||||||
@@ -774,28 +867,44 @@ Il est possible, par exemple, d'utiliser ceci pour définir un serveur
|
|||||||
d'impression différent pour les hôtes de la classe "comptes" et ceux de la
|
d'impression différent pour les hôtes de la classe "comptes" et ceux de la
|
||||||
classe "ingénierie".
|
classe "ingénierie".
|
||||||
.TP
|
.TP
|
||||||
.B \-4, --dhcp-mac=<identifiant de réseau>,<adresse MAC>
|
.B \-4, --dhcp-mac=set:<label>,<adresse MAC>
|
||||||
Associe une adresse matérielle (MAC) à un identifiant réseau. L'adresse
|
Associe une adresse matérielle (MAC) à un label. L'adresse
|
||||||
matérielle peut inclure des jokers. Par exemple
|
matérielle peut inclure des jokers. Par exemple
|
||||||
.B --dhcp-mac=3com,01:34:23:*:*:*
|
.B --dhcp-mac=set:3com,01:34:23:*:*:*
|
||||||
permet de définir le label "3com" pour n'importe quel hôte dont l'adresse
|
permet de définir le label "3com" pour n'importe quel hôte dont l'adresse
|
||||||
matérielle coïncide avec les critères définis.
|
matérielle coïncide avec les critères définis.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-circuitid=<identifiant de réseau>,<identifiant de circuit>, --dhcp-remoteid=<identifiant de réseau>,<identifiant distant>
|
.B --dhcp-circuitid=set:<label>,<identifiant de circuit>, --dhcp-remoteid=set:<label>,<identifiant distant>
|
||||||
Associe des options de relais DHCP issus de la RFC3046 à des identifiants de
|
Associe des options de relais DHCP issus de la RFC3046 à des labels.
|
||||||
réseau. Cette information peut-être fournie par des relais DHCP. L'identifiant
|
Cette information peut-être fournie par des relais DHCP. L'identifiant
|
||||||
de circuit ou l'identifiant distant est normalement fourni sous la forme d'une
|
de circuit ou l'identifiant distant est normalement fourni sous la forme d'une
|
||||||
chaîne de valeurs hexadécimales séparées par des ":", mais il est également
|
chaîne de valeurs hexadécimales séparées par des ":", mais il est également
|
||||||
possible qu'elle le soit sous la forme d'une simple chaîne de caractères. Si
|
possible qu'elle le soit sous la forme d'une simple chaîne de caractères. Si
|
||||||
l'identifiant de circuit ou d'agent correspond exactement à celui fourni par le
|
l'identifiant de circuit ou d'agent correspond exactement à celui fourni par le
|
||||||
relais DHCP, alors l'identifiant de réseau est positionné.
|
relais DHCP, alors le label est apposé.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-subscrid=<identifiant de réseau>,<identifiant d'abonné>
|
.B --dhcp-subscrid=set:<label>,<identifiant d'abonné>
|
||||||
Associe des options de relais DHCP issues de la RFC3993 à des identifiants de
|
Associe des options de relais DHCP issues de la RFC3993 à des labels.
|
||||||
réseau.
|
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-match=<identifiant de réseau>,<numéro d'option>|option:<nom d'option>[,<valeur>]
|
.B --dhcp-proxy[=<adresse ip>]......
|
||||||
Si aucune valeur n'est spécifiée, associe l'identifiant de réseau si le client
|
Un agent relai DHCP normal est uniquement utilisé pour faire suivre les
|
||||||
|
éléments initiaux de l'interaction avec le serveur DHCP. Une fois que le
|
||||||
|
client est configuré, il communique directement avec le serveur. Cela n'est pas
|
||||||
|
souhaitable si le relais rajoute des informations supplémentaires aux paquets
|
||||||
|
DHCP, telles que celles utilisées dans
|
||||||
|
.B dhcp-circuitid
|
||||||
|
et
|
||||||
|
.B dhcp-remoteid.
|
||||||
|
Une implémentation complète de relai peut utiliser l'option serverid-override
|
||||||
|
de la RFC 5107 afin de forcer le serveur DHCP à utiliser le relai en temps que
|
||||||
|
proxy complet, de sorte que tous les paquets passent par le relai. Cette option
|
||||||
|
permet d'obtenir le même résultat pour des relais ne supportant pas la RFC
|
||||||
|
5107. Fournie seule, elle manipule la valeur de server-id pour toutes les
|
||||||
|
interactions via des relais. Si une liste d'adresses IP est donnée, seules les
|
||||||
|
interactions avec les relais dont l'adresse est dans la liste seront affectées.
|
||||||
|
.TP
|
||||||
|
.B --dhcp-match=set:<label>,<numéro d'option>|option:<nom d'option>|vi-encap:<entreprise>[,<valeur>]
|
||||||
|
Si aucune valeur n'est spécifiée, associe le label si le client
|
||||||
envoie une option DHCP avec le numéro ou le nom spécifié. Lorsqu'une valeur est
|
envoie une option DHCP avec le numéro ou le nom spécifié. Lorsqu'une valeur est
|
||||||
fournie, positionne le label seulement dans le cas où l'option est fournie et
|
fournie, positionne le label seulement dans le cas où l'option est fournie et
|
||||||
correspond à la valeur. La valeur peut-être de la forme "01:ff:*:02", auquel
|
correspond à la valeur. La valeur peut-être de la forme "01:ff:*:02", auquel
|
||||||
@@ -805,37 +914,62 @@ valeur peut aussi être de la même forme que dans
|
|||||||
, auquel cas l'option est traitée comme un tableau de valeur, et un des
|
, auquel cas l'option est traitée comme un tableau de valeur, et un des
|
||||||
éléments doit correspondre, ainsi
|
éléments doit correspondre, ainsi
|
||||||
|
|
||||||
--dhcp-match=efi-ia32,option:client-arch,6
|
--dhcp-match=set:efi-ia32,option:client-arch,6
|
||||||
|
|
||||||
spécifie le label "efi-ia32" si le numéro 6 apparaît dnas la liste
|
spécifie le label "efi-ia32" si le numéro 6 apparaît dnas la liste
|
||||||
d'architectures envoyé par le client au sein de l'option 93. (se réferer
|
d'architectures envoyé par le client au sein de l'option 93. (se réferer
|
||||||
au RFC 4578 pour plus de détails). Si la valeur est un chaine de caractères,
|
au RFC 4578 pour plus de détails). Si la valeur est un chaine de caractères,
|
||||||
celle-ci est recherchée (correspondance en temps que sous-chaîne).
|
celle-ci est recherchée (correspondance en temps que sous-chaîne).
|
||||||
|
|
||||||
|
Pour la forme particulière vi-encap:<numéro d'entreprise>, la comparaison se
|
||||||
|
fait avec les classes de vendeur "identifiant de vendeur" ("vendor-identifying
|
||||||
|
vendor classes") pour l'entreprise dont le numéro est fourni en option.
|
||||||
|
Veuillez vous réferer à la RFC 3925 pour plus de détail.
|
||||||
.TP
|
.TP
|
||||||
.B \-J, --dhcp-ignore=<identifiant de réseau>[,<identifiant de réseau>]
|
.B --tag-if=set:<label>[,set:<label>[,tag:<label>[,tag:<label>]]]
|
||||||
Lorsque tous les identifiants de réseau fournis coïncident avec la liste
|
Effectue une opération booléenne sur les labels. Si tous les labels
|
||||||
d'identifiants réseau dérivée des classes de réseau, hôte, vendeur et
|
apparaissant dans la liste tag:<label> sont positionnés, alors tous les
|
||||||
utilisateur, ignorer l'hôte et ne pas donner de bail DHCP.
|
la de la liste "set:<labels>" sont positionnés (ou supprimés, dans le cas
|
||||||
|
où "tag:!<label>" utilisé).
|
||||||
|
Si aucun tag:<label> n'est spécifié, alors tous les labels fournis par
|
||||||
|
set:<label> sont positionnés.
|
||||||
|
N'importe quel nombre de set: ou tag: peuvent être fournis, et l'ordre est sans
|
||||||
|
importance.
|
||||||
|
Les lignes tag-if sont executées dans l'ordre, ce qui fait que si un label dans
|
||||||
|
tag:<label> est un label positionné par une rêgle
|
||||||
|
.B tag-if,
|
||||||
|
la ligne qui positionne le label doit précéder celle qui le teste.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-ignore-names[=<identifiant de réseau>[,<identifiant de réseau>]]
|
.B \-J, --dhcp-ignore=tag:<label>[,tag:<label>]
|
||||||
Lorsque tous les identifiant de réseau coïncident avec la liste d'identifiants
|
Lorsque tous les labels fournis dans l'option sont présents, ignorer l'hôte et
|
||||||
réseau dérivées des classes de réseau, hôte, vendeur et utilisateur, ignorer le
|
ne pas donner de bail DHCP.
|
||||||
|
.TP
|
||||||
|
.B --dhcp-ignore-names[=tag:<label>[,tag:<label>]]
|
||||||
|
Lorsque tous les labels fournis dans l'option sont présents, ignorer le
|
||||||
nom de machine fourni par l'hôte. Il est à noter que, à la différence de
|
nom de machine fourni par l'hôte. Il est à noter que, à la différence de
|
||||||
l'option "dhcp-ignore", il est permis de ne pas fournir d'identifiant réseau.
|
l'option "dhcp-ignore", il est permis de ne pas fournir de label.
|
||||||
Dans ce cas, les noms d'hôtes fournis par les clients DHCP seront toujours
|
Dans ce cas, les noms d'hôtes fournis par les clients DHCP seront toujours
|
||||||
ignorés, et les noms d'hôtes seront ajoutés au DNS en utilisant uniquement la
|
ignorés, et les noms d'hôtes seront ajoutés au DNS en utilisant uniquement la
|
||||||
configuration dhcp-host de Dnsmasq, ainsi que le contenu des fichiers /etc/hosts
|
configuration dhcp-host de Dnsmasq, ainsi que le contenu des fichiers /etc/hosts
|
||||||
et /etc/ethers.
|
et /etc/ethers.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-broadcast=<identifiant de réseau>[,<identifiant de réseau>]
|
.B --dhcp-generate-names=tag:<label>[,tag:<label>]
|
||||||
Lorsque tous les identifiants de réseaux fournis correspondent à ceux
|
Générer un nom pour les clients DHCP qui autrement n'en aurait pas, en
|
||||||
obtenus à partir des classes de réseau, d'hôte ou d'utilisateur, force
|
utilisant l'adresse MAC sous sa forme hexadécimale, séparée par des tirets.
|
||||||
l'utilisation du broadcast pour communiquer avec l'hôte lorsque celui-ci n'est
|
Noter que si un hôte fourni un nom, celui-ci sera utilisé de préférence au nom
|
||||||
pas configuré. La plupart des clients DHCP nécessitant une réponse par le biais
|
autogénéré, à moins que
|
||||||
|
.B --dhcp-ignore-names
|
||||||
|
ne soit positionné.
|
||||||
|
.TP
|
||||||
|
.B --dhcp-broadcast=[tag:<label>[,tag:<label>]]
|
||||||
|
Lorsque tous les labels fournis dans l'option sont présents, toujours utiliser
|
||||||
|
le broadcast pour communiquer avec l'hôte lorsque celui-ci n'est
|
||||||
|
pas configuré. Il est possible de ne spécifier aucun label, auquel cas cette
|
||||||
|
option s'applique inconditionnellement. La plupart des clients DHCP nécessitant une réponse par le biais
|
||||||
d'un broadcast activent une option dans leur requête, ce qui fait que cela
|
d'un broadcast activent une option dans leur requête, ce qui fait que cela
|
||||||
se fait automatiquement, mais ce n'est pas la cas de certains vieux clients BOOTP.
|
se fait automatiquement, mais ce n'est pas la cas de certains vieux clients BOOTP.
|
||||||
.TP
|
.TP
|
||||||
.B \-M, --dhcp-boot=[net:<identifiant de réseau>,]<nom de fichier>,[<nom de serveur>[,<adresse de serveur>]]
|
.B \-M, --dhcp-boot=[tag:<label>,]<nom de fichier>,[<nom de serveur>[,<adresse de serveur>]]
|
||||||
Spécifie les options BOOTP devant être retournées par le serveur DHCP. Le nom de
|
Spécifie les options BOOTP devant être retournées par le serveur DHCP. Le nom de
|
||||||
serveur ainsi que l'adresse sont optionnels : s'ils ne sont pas fournis, le nom
|
serveur ainsi que l'adresse sont optionnels : s'ils ne sont pas fournis, le nom
|
||||||
est laissé vide et l'adresse fournie est celle de la machine sur laquelle
|
est laissé vide et l'adresse fournie est celle de la machine sur laquelle
|
||||||
@@ -843,11 +977,10 @@ s'exécute Dnsmasq. Si Dnsmasq founit un service TFTP (voir
|
|||||||
.B --enable-tftp
|
.B --enable-tftp
|
||||||
), alors seul un nom de fichier est requis ici pour permettre un démarrage par
|
), alors seul un nom de fichier est requis ici pour permettre un démarrage par
|
||||||
le réseau.
|
le réseau.
|
||||||
Si d'éventuels identifiants de réseau sont fournis, ils doivent coïncider avec
|
Si d'éventuels labels sont fournis, ils doivent coïncider avec
|
||||||
ceux du client pour que cet élement de configuration lui soit envoyé. Il est à
|
ceux du client pour que cet élement de configuration lui soit envoyé.
|
||||||
noter que les identifiants de réseau doivent-être préfixés par "net:".
|
|
||||||
.TP
|
.TP
|
||||||
.B --pxe-service=[net:<identifiant de réseau>,]<CSA>,<entrée de menu>,<nom de fichier>|<type de service de démarrage>[,<adresse de serveur>]
|
.B --pxe-service=[tag:<label>,]<CSA>,<entrée de menu>[,<nom de fichier>|<type de service de démarrage>][,<adresse de serveur>]
|
||||||
La plupart des ROMS de démarrage PXE ne permettent au système PXE que la simple
|
La plupart des ROMS de démarrage PXE ne permettent au système PXE que la simple
|
||||||
obtention d'une adresse IP, le téléchargement du fichier spécifié dans
|
obtention d'une adresse IP, le téléchargement du fichier spécifié dans
|
||||||
.B dhcp-boot
|
.B dhcp-boot
|
||||||
@@ -870,12 +1003,14 @@ Veuillez noter que le suffixe de "couche" (en principe ".0") est fourni par PXE
|
|||||||
et ne doit pas être rajouté au nom de fichier. Si une valeur numérique entière
|
et ne doit pas être rajouté au nom de fichier. Si une valeur numérique entière
|
||||||
est fournir pour le type de démarrage, en remplacement du nom de fichier, le
|
est fournir pour le type de démarrage, en remplacement du nom de fichier, le
|
||||||
client PXE devra chercher un service de démarrage de ce type sur le réseau.
|
client PXE devra chercher un service de démarrage de ce type sur le réseau.
|
||||||
Cette recherche peut être faite via multicast ou broadcast, ou directement
|
Cette recherche peut être faite via broadcast ou directement auprès d'un
|
||||||
auprès d'un serveur si son adresse IP est fournie dans l'option. Un service de
|
serveur si son adresse IP est fournie dans l'option.
|
||||||
démarrage de type 0 est spécial et provoquera une interruption du démarrage par
|
Si aucun nom de fichier n'est donné ni aucune valeur de type de service de
|
||||||
le réseau ainsi que la poursuite du démarrage sur un média local.
|
démarrage n'est fournie (ou qu'une valeur de 0 est donnée pour le type de
|
||||||
|
service), alors l'entrée de menu provoque l'interruption du démarrage par
|
||||||
|
le réseau et la poursuite du démarrage sur un média local.
|
||||||
.TP
|
.TP
|
||||||
.B --pxe-prompt=[net:<identifiant de réseau>,]<invite>[,<délai>]
|
.B --pxe-prompt=[tag:<label>,]<invite>[,<délai>]
|
||||||
Cette option permet d'afficher une invite à la suite du démarrage PXE. Si un
|
Cette option permet d'afficher une invite à la suite du démarrage PXE. Si un
|
||||||
délai est fourni, alors la première entrée du menu de démarrage sera
|
délai est fourni, alors la première entrée du menu de démarrage sera
|
||||||
automatiquement exécutée après ce délai. Si le délai vaut 0, alors la première
|
automatiquement exécutée après ce délai. Si le délai vaut 0, alors la première
|
||||||
@@ -900,7 +1035,7 @@ dans
|
|||||||
.B dhcp-range.
|
.B dhcp-range.
|
||||||
.TP
|
.TP
|
||||||
.B \-X, --dhcp-lease-max=<nombre>
|
.B \-X, --dhcp-lease-max=<nombre>
|
||||||
Limite Dnsmasq à un maximum de <nombre> baux DHCP. Le défaut est de 150. Cette
|
Limite Dnsmasq à un maximum de <nombre> baux DHCP. Le défaut est de 1000. Cette
|
||||||
limite permet d'éviter des attaques de déni de service ("DoS") par des hôtes
|
limite permet d'éviter des attaques de déni de service ("DoS") par des hôtes
|
||||||
créant des milliers de baux et utilisant beaucoup de mémoire dans le processus
|
créant des milliers de baux et utilisant beaucoup de mémoire dans le processus
|
||||||
Dnsmasq.
|
Dnsmasq.
|
||||||
@@ -941,7 +1076,7 @@ utiliser avec précaution.
|
|||||||
.TP
|
.TP
|
||||||
.B --log-dhcp
|
.B --log-dhcp
|
||||||
Traces additionnelles pour le service DHCP : enregistre toutes les options
|
Traces additionnelles pour le service DHCP : enregistre toutes les options
|
||||||
envoyées aux clients DHCP et les identifiants de réseaux utilisés pour la
|
envoyées aux clients DHCP et les labels utilisés pour la
|
||||||
détermination de celles-ci.
|
détermination de celles-ci.
|
||||||
.TP
|
.TP
|
||||||
.B \-l, --dhcp-leasefile=<chemin de fichier>
|
.B \-l, --dhcp-leasefile=<chemin de fichier>
|
||||||
@@ -950,7 +1085,9 @@ baux DHCP.
|
|||||||
.TP
|
.TP
|
||||||
.B \-6 --dhcp-script=<chemin de fichier>
|
.B \-6 --dhcp-script=<chemin de fichier>
|
||||||
Lorsqu'un bail DHCP est créé, ou qu'un ancien est supprimé, le fichier dont le
|
Lorsqu'un bail DHCP est créé, ou qu'un ancien est supprimé, le fichier dont le
|
||||||
chemin est spécifié est exécuté. Les arguments fournis à celui-ci sont soit
|
chemin est spécifié est exécuté. Le <chemin de fichier> doit être un chemin
|
||||||
|
absolu, aucune recherche n'est effectuée via la variable d'environnement PATH.
|
||||||
|
Les arguments fournis à celui-ci sont soit
|
||||||
"add" ("ajouter"), "old" ("ancien") ou "del" ("supprimer"), suivi de l'adresse
|
"add" ("ajouter"), "old" ("ancien") ou "del" ("supprimer"), suivi de l'adresse
|
||||||
MAC de l'hôte puis l'adresse IP et le nom d'hôte si celui-ci est
|
MAC de l'hôte puis l'adresse IP et le nom d'hôte si celui-ci est
|
||||||
connu."add" signifie qu'un bail a été créé, "del" signifie qu'il a été supprimé,
|
connu."add" signifie qu'un bail a été créé, "del" signifie qu'il a été supprimé,
|
||||||
@@ -962,41 +1099,60 @@ nécessaire de la préceder du type de réseau, par exemple "06-01:23:45:67:89:a
|
|||||||
pour du token ring. Le processus est exécuté en temps que super-utilisateur
|
pour du token ring. Le processus est exécuté en temps que super-utilisateur
|
||||||
(si Dnsmasq a été lancé en temps que "root"), même si Dnsmasq est configuré
|
(si Dnsmasq a été lancé en temps que "root"), même si Dnsmasq est configuré
|
||||||
pour changer son UID pour celle d'un utilisateur non-privilégié.
|
pour changer son UID pour celle d'un utilisateur non-privilégié.
|
||||||
L'environnement est hérité de celui de l'invocation du processus Dnsmasq, et
|
|
||||||
si l'hôte fournit un identifiant de client, celui-ci est stocké dans la
|
L'environnement est hérité de celui de l'invocation du processus Dnsmasq,
|
||||||
variable d'environnement DNSMASQ_CLIENT_ID. Si un nom de domaine pleinement
|
auquel se rajoute quelques unes ou toutes les variables décrites ci-dessous :
|
||||||
qualifié (FQDN) est connu pour l'hôte, la part relative au domaine est stockée
|
|
||||||
dans DNSMASQ_DOMAIN. Si le client fournit une information de classe de vendeur,
|
DNSMASQ_CLIENT_ID, si l'hôte a fourni un identifiant de client.
|
||||||
de classe d'utilisateur ou un nom d'hôte, celles-ci sont positionnées dans les
|
|
||||||
|
DNSMASQ_DOMAIN si le nom de domaine pleinement qualifié de l'hôte est connu, la
|
||||||
|
part relative au domaine y est stockée. (Notez que le nom d'hôte transmis comme
|
||||||
|
argument au script n'est jamais pleinement qualifié).
|
||||||
|
|
||||||
|
Si le client fournit une information de classe de vendeur, un nom d'hôte, ou
|
||||||
|
des classes d'utilisateur, celles-ci sont fournies dans les
|
||||||
variables DNSMASQ_VENDOR_CLASS et DNSMASQ_USER_CLASS0 à DNSMASQ_USER_CLASSn
|
variables DNSMASQ_VENDOR_CLASS et DNSMASQ_USER_CLASS0 à DNSMASQ_USER_CLASSn
|
||||||
et DNSMASQ_SUPPLIED_HOSTNAME respectivement, mais seulement pour les actions
|
et DNSMASQ_SUPPLIED_HOSTNAME respectivement, mais seulement pour les actions
|
||||||
"add" et "old" lorsqu'un hôte reprend un bail existant, ces variables n'étant
|
"add" et "old" lorsqu'un hôte reprend un bail existant, ces variables n'étant
|
||||||
pas stockées dans la base de baux de Dnsmasq. Si Dnsmasq a été compilé avec
|
pas stockées dans la base de baux de Dnsmasq.
|
||||||
l'option HAVE_BROKEN_RTC ("horloge RTC défectueuse"), alors la durée du bail
|
|
||||||
(en secondes) est stockée dans la variable DNSMASQ_LEASE_LENGTH, sinon la date
|
Si Dnsmasq a été compilé avec l'option HAVE_BROKEN_RTC ("horloge RTC
|
||||||
d'expiration du bail est toujours stocké dans la variable d'environnement
|
défectueuse"), alors la durée du bail (en secondes) est stockée dans la
|
||||||
DNSMASQ_LEASE_EXPIRES. Le nombre de secondes avant expiration est toujours
|
variable DNSMASQ_LEASE_LENGTH, sinon la date d'expiration du bail est toujours
|
||||||
stocké dans DNSMASQ_TIME_REMAINING. Si un bail était associé à un nom d'hôte et
|
stocké dans la variable d'environnement DNSMASQ_LEASE_EXPIRES. Le nombre de
|
||||||
|
secondes avant expiration est toujours stocké dans DNSMASQ_TIME_REMAINING.
|
||||||
|
|
||||||
|
Si un bail était associé à un nom d'hôte et
|
||||||
que celui-ci est supprimé, un évênement de type "old" est généré avec le
|
que celui-ci est supprimé, un évênement de type "old" est généré avec le
|
||||||
nouveau statut du bail, c-à-d sans nom d'hôte, et le nom initial est fourni
|
nouveau statut du bail, c-à-d sans nom d'hôte, et le nom initial est fourni
|
||||||
dans la variable d'environnement DNSMASQ_OLD_HOSTNAME. La variable
|
dans la variable d'environnement DNSMASQ_OLD_HOSTNAME.
|
||||||
DNSMASQ_INTERFACE contient le nom de l'interface sur laquelle la requête est
|
|
||||||
arrivée; ceci n'est pas renseigné dans le cas des actions "old" ayant lieu
|
La variable DNSMASQ_INTERFACE contient le nom de l'interface sur laquelle la
|
||||||
après un redémarrage de dnsmasq. La variable DNSMASQ_RELAY_ADDRESS est
|
requête est arrivée; ceci n'est pas renseigné dans le cas des actions "old"
|
||||||
renseignée si le client a utilisé un relai DHCP pour contacter Dnsmasq, si
|
ayant lieu après un redémarrage de dnsmasq.
|
||||||
l'adresse IP du relai est connue.
|
|
||||||
|
La variable DNSMASQ_RELAY_ADDRESS est renseignée si le client a utilisé un
|
||||||
|
relai DHCP pour contacter Dnsmasq, si l'adresse IP du relai est connue.
|
||||||
|
|
||||||
|
DNSMASQ_TAGS contient tous les labels fournis pendant la transaction DHCP,
|
||||||
|
séparés par des espaces.
|
||||||
|
|
||||||
Tous les descripteurs de fichiers sont fermés, sauf stdin, stdout et stderr qui
|
Tous les descripteurs de fichiers sont fermés, sauf stdin, stdout et stderr qui
|
||||||
sont ouverts sur /dev/null (sauf en mode déverminage).
|
sont ouverts sur /dev/null (sauf en mode déverminage).
|
||||||
Le script n'est pas lancé de manière concurrente : si un autre changement de
|
|
||||||
bail intervient, le script ne sera relancé que lorsque l'exécution actuelle sera
|
Le script n'est pas lancé de manière concurrente : au plus une instance du
|
||||||
terminée.
|
script est executée à la fois (dnsmasq attends qu'une instance de script se
|
||||||
|
termine avant de lancer la suivante). Les changements dans la base des baux
|
||||||
|
nécessitant le lancement du script sont placé en attente dans une queue jusqu'à
|
||||||
|
terminaison d'une instance du script en cours. Si cette mise en queue fait que
|
||||||
|
plusieurs changements d'états apparaissent pour un bail donné avant que le
|
||||||
|
script puisse être lancé, alors les états les plus anciens sont supprimés et
|
||||||
|
lorsque le script sera finalement lancé, ce sera avec l'état courant du bail.
|
||||||
|
|
||||||
Au démarrage de Dnsmasq, le script sera invoqué pour chacun des baux existants
|
Au démarrage de Dnsmasq, le script sera invoqué pour chacun des baux existants
|
||||||
dans le fichier des baux. Le script sera lancé avec l'action "del" pour les baux
|
dans le fichier des baux. Le script sera lancé avec l'action "del" pour les
|
||||||
expirés, et "old" pour les autres. <chemin de fichier> doit être un chemin
|
baux expirés, et "old" pour les autres. Lorsque Dnsmasq reçoit un signal HUP,
|
||||||
absolu (c'est-à-dire partant de la racine "/"), aucune recherche n'aura lieu
|
le script sera invoqué avec une action "old" pour tous les baux existants.
|
||||||
dans les répertoires de la variable d'environnement PATH. Lorsque Dnsmasq reçoit
|
|
||||||
un signal HUP, le script sera invoqué avec une action "old" pour tous les baux
|
|
||||||
existants.
|
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-scriptuser
|
.B --dhcp-scriptuser
|
||||||
Spécifie l'utilisateur sous lequel le script lease-change doit être exécuté. La
|
Spécifie l'utilisateur sous lequel le script lease-change doit être exécuté. La
|
||||||
@@ -1028,7 +1184,7 @@ nécessaire lors de l'utilisation de pont ethernet "ancien mode" sur plate-forme
|
|||||||
BSD, puisque dans ce cas les paquets arrivent sur des interfaces "tap" n'ont
|
BSD, puisque dans ce cas les paquets arrivent sur des interfaces "tap" n'ont
|
||||||
pas d'adresse IP.
|
pas d'adresse IP.
|
||||||
.TP
|
.TP
|
||||||
.B \-s, --domain=<domaine>[,<gamme d'adresses>]
|
.B \-s, --domain=<domaine>[,<gamme d'adresses>[,local]]
|
||||||
Spécifie le domaine du serveur DHCP. Le domaine peut être donné de manière
|
Spécifie le domaine du serveur DHCP. Le domaine peut être donné de manière
|
||||||
inconditionnelle (sans spécifier de gamme d'adresses IP) ou pour des gammes
|
inconditionnelle (sans spécifier de gamme d'adresses IP) ou pour des gammes
|
||||||
d'adresses IP limitées. Cela a deux effets; tout d'abord, le
|
d'adresses IP limitées. Cela a deux effets; tout d'abord, le
|
||||||
@@ -1050,11 +1206,23 @@ et avoir une machine dont le nom DHCP serait "laptop". L'adresse IP de cette
|
|||||||
machine sera disponible à la fois pour "laptop" et "laptop.thekelleys.org.uk".
|
machine sera disponible à la fois pour "laptop" et "laptop.thekelleys.org.uk".
|
||||||
Si la valeur fournie pour <domaine> est "#", alors le nom de domaine est
|
Si la valeur fournie pour <domaine> est "#", alors le nom de domaine est
|
||||||
positionné à la première valeur de la directive "search" du fichier
|
positionné à la première valeur de la directive "search" du fichier
|
||||||
/etc/resolv.conf (ou équivalent). La gamme d'adresses peut être de la forme
|
/etc/resolv.conf (ou équivalent).
|
||||||
|
|
||||||
|
La gamme d'adresses peut être de la forme
|
||||||
<adresse ip>,<adresse ip> ou <adresse ip>/<masque de réseau> voire une simple
|
<adresse ip>,<adresse ip> ou <adresse ip>/<masque de réseau> voire une simple
|
||||||
<adresse ip>. Voir
|
<adresse ip>. Voir
|
||||||
.B --dhcp-fqdn
|
.B --dhcp-fqdn
|
||||||
qui peut changer le comportement de dnsmasq relatif aux domaines.
|
qui peut changer le comportement de dnsmasq relatif aux domaines.
|
||||||
|
|
||||||
|
Si la gamme d'adresse est fournie sous la forme
|
||||||
|
<adresse ip>/<taille de réseau>, alors le drapeau "local" peut-être rajouté
|
||||||
|
qui a pour effect d'ajouter --local-declarations aux requêtes DNS directes et
|
||||||
|
inverses. C-à-d
|
||||||
|
.B --domain=thekelleys.org.uk,192.168.0.0/24,local
|
||||||
|
est indentique à
|
||||||
|
.B --domain=thekelleys.org.uk,192.168.0.0/24
|
||||||
|
--local=/thekelleys.org.uk/ --local=/0.168.192.in-addr.arpa/
|
||||||
|
La taille de réseau doit-être de 8, 16 ou 24 pour être valide.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-fqdn
|
.B --dhcp-fqdn
|
||||||
Dans le mode par défaut, dnsmasq insère les noms non-qualifiés des clients
|
Dans le mode par défaut, dnsmasq insère les noms non-qualifiés des clients
|
||||||
@@ -1074,18 +1242,21 @@ sans gamme d'adresses de spécifié lorsque l'option
|
|||||||
.B --dhcp-fqdn
|
.B --dhcp-fqdn
|
||||||
est configurée.
|
est configurée.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp
|
.B --enable-tftp[=<interface>]
|
||||||
Active la fonction serveur TFTP. Celui-ci est de manière délibérée limité aux
|
Active la fonction serveur TFTP. Celui-ci est de manière délibérée limité aux
|
||||||
fonctions nécessaires au démarrage par le réseau ("net-boot") d'un client. Seul
|
fonctions nécessaires au démarrage par le réseau ("net-boot") d'un client. Seul
|
||||||
un accès en lecture est possible; les extensions tsize et blksize sont supportées
|
un accès en lecture est possible; les extensions tsize et blksize sont supportées
|
||||||
(tsize est seulement supporté en mode octet).
|
(tsize est seulement supporté en mode octet). Voir dans la section NOTES les
|
||||||
|
informations relatives à la spécification de l'interface.
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-root=<répertoire>
|
.B --tftp-root=<répertoire>[,<interface>]
|
||||||
Les fichiers à fournir dans les transferts TFTP seront cherchés en prenant le
|
Les fichiers à fournir dans les transferts TFTP seront cherchés en prenant le
|
||||||
répertoire fourni comme racine. Lorsque cela est fourni, les chemins TFTP
|
répertoire fourni comme racine. Lorsque cela est fourni, les chemins TFTP
|
||||||
incluant ".." sont rejetés, afin d'éviter que les clients ne puissent sortir de
|
incluant ".." sont rejetés, afin d'éviter que les clients ne puissent sortir de
|
||||||
la racine spécifiée. Les chemins absolus (commençant par "/") sont autorisés,
|
la racine spécifiée. Les chemins absolus (commençant par "/") sont autorisés,
|
||||||
mais ils doivent être à la racine TFTP fournie.
|
mais ils doivent être à la racine TFTP fournie. Si l'option interface est
|
||||||
|
spécifiée, le répertoire n'est utilisé que pour les requêtes TFTP reçues sur
|
||||||
|
cette interface.
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-unique-root
|
.B --tftp-unique-root
|
||||||
Ajouter l'adresse IP du client TFTP en temps qu'élément de chemin, à la suite
|
Ajouter l'adresse IP du client TFTP en temps qu'élément de chemin, à la suite
|
||||||
@@ -1158,7 +1329,9 @@ est limitée par la taille de la plage de ports ainsi définie.
|
|||||||
.B \-C, --conf-file=<fichier>
|
.B \-C, --conf-file=<fichier>
|
||||||
Spécifie un fichier de configuration différent. L'option "conf-file" est
|
Spécifie un fichier de configuration différent. L'option "conf-file" est
|
||||||
également autorisée dans des fichiers de configuration, ce qui permet
|
également autorisée dans des fichiers de configuration, ce qui permet
|
||||||
l'inclusion de multiples fichiers de configuration.
|
l'inclusion de multiples fichiers de configuration. L'utilisation de "-" comme
|
||||||
|
nom de fichier permet la lecture par dnsmasq de sa configuration sur l'entrée standard
|
||||||
|
stdin.
|
||||||
.TP
|
.TP
|
||||||
.B \-7, --conf-dir=<répertoire>[,<extension de fichier>...]
|
.B \-7, --conf-dir=<répertoire>[,<extension de fichier>...]
|
||||||
Lis tous les fichiers du répertoire spécifié et les traite comme des fichiers de
|
Lis tous les fichiers du répertoire spécifié et les traite comme des fichiers de
|
||||||
@@ -1307,38 +1480,48 @@ exception à ceci : si le DNS amont contient un CNAME qui pointe vers un nom
|
|||||||
présent dans /etc/hosts, alors la recherche du CNAME via Dnsmasq fournira
|
présent dans /etc/hosts, alors la recherche du CNAME via Dnsmasq fournira
|
||||||
l'adresse DNS amont. Pour contourner cela, il suffit de mettre l'entrée
|
l'adresse DNS amont. Pour contourner cela, il suffit de mettre l'entrée
|
||||||
correspondant au CNAME dans /etc/hosts.
|
correspondant au CNAME dans /etc/hosts.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
les identifiants de réseau fonctionnent comme suit : Dnsmasq associe à chaque
|
le système de label fonctionne comme suit : pour chaque requête DHCP, dnsmasq
|
||||||
requête DHCP un ensemble d'identifiants de réseau; un pour la plage d'adresse
|
associe un ensemble de labels obtenus à partir des lignes de la configuration
|
||||||
DHCP (
|
incluant set:<label>, y compris un pour la plage d'adresse (
|
||||||
.B dhcp-range
|
.B dhcp-range
|
||||||
) utilisée pour allouer l'adresse, un identifiant pour chaque entrée
|
) utilisée pour allouer l'adresse, un pour chaque entrée
|
||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
associée (il ajoute "known" lorsqu'une entrée dhcp-host coïncide), l'étiquette
|
associée (auquel est rajouté le mot-clef "known" si une entrée dhcp-host
|
||||||
"bootp" pour les requêtes BOOTP, un identifiant dont le nom est le nom de
|
coïncide).
|
||||||
l'interface sur laquelle la requête est arrivée, et éventuellement un
|
|
||||||
identifiant pour chaque classe de vendeur ou d'utilisateur
|
Le label "bootp" est associé aux requêtes BOOTP, un label dont le nom est le
|
||||||
fournie par le client DHCP dans sa requête. Les options DHCP (
|
nom de l'interface sur laquelle la requête est arrivée.
|
||||||
|
|
||||||
|
Pour les lignes de configuration comportant des éléments tag:<label>,
|
||||||
|
seules seront valides celles pour lesquels tous les labels correspondants
|
||||||
|
seront présents. C'est typiquement le cas des lignes dhcp-options.
|
||||||
|
Un
|
||||||
.B dhcp-option
|
.B dhcp-option
|
||||||
) ayant un identifiant de réseau seront utilisés de préférence à celles
|
possédant des labels sera utilisé de préférence à un
|
||||||
sans identifiants de réseau, pour peu que
|
.B dhcp-option
|
||||||
.I tous
|
sans label, pour peu que _tous_ les labels positionnés correspondent à l'ensemble
|
||||||
les labels correspondent.
|
de labels décrit plus haut.
|
||||||
Le préfixe '#' sur un label est un indicateur de négation, ainsi
|
Le préfixe '!' sur un label est un indicateur de négation, ainsi
|
||||||
.B --dhcp=option=#purple,3,1.2.3.4
|
.B --dhcp=option=tag:!purple,3,1.2.3.4
|
||||||
envoie l'option lorsque le label "purple" n'est pas dans la liste de labels
|
n'envoie l'option que lorsque le label "purple" n'est pas dans la liste de
|
||||||
valides pour l'hôte considéré.
|
labels définis pour l'hôte considéré. (dans le cas de l'utilisation dans une
|
||||||
|
ligne de commande au lieu d'un fichier de configuration, ne pas oublier
|
||||||
|
d'échapper le caractère !, qui est un méta-caractère d'interpréteur de commande
|
||||||
|
shell).
|
||||||
.PP
|
.PP
|
||||||
Si l'identifiant de réseau dans la plage d'adresses DHCP (
|
Veuillez noter que pour
|
||||||
.B dhcp-range
|
.B dhcp-range
|
||||||
) est préfixé par 'net:', alors sa signification change : au lieu d'associer un
|
, les éléments tag:<label> et set:<label> sont tous les deux autorisés
|
||||||
label à la plage spécifiée, cela indique un label de réseau devant être spécifié
|
pour sélectionner la plage à utiliser selon, par exemple, le dhcp-host,
|
||||||
par le client DHCP. Ainsi, s'il y a plus d'une plage d'adresses DHCP sur un
|
et pour affecter l'option envoyée, sur la base de la plage sélectionnée.
|
||||||
sous-réseau, et que l'une est préfixée par un identifiant de réseau (par exemple
|
|
||||||
l'un spécifié dans une option de classe de vendeur), alors un hôte ayant
|
Ce système a évolué d'un système plus ancien et aux possibilités plus limitées,
|
||||||
l'identifiant de réseau en question positionné se verra allouer une adresse dans
|
et pour des raisons de compatibilité "net:" peut être utilisé à la place de
|
||||||
la plage d'adresses DHCP préfixée.
|
"tag:" et "set:" peut-être omis (à l'exception de
|
||||||
|
.B dhcp-host,
|
||||||
|
où "net:" peut-être utilisé à la place de "set:"). Pour les mêmes raisons, '#'
|
||||||
|
peut-être utilisé à la place de '!' pour indiquer la négation.
|
||||||
.PP
|
.PP
|
||||||
Le serveur DHCP intégré dans Dnsmasq fonctionne également en temps que serveur
|
Le serveur DHCP intégré dans Dnsmasq fonctionne également en temps que serveur
|
||||||
BOOTP, pour peu que l'adresse MAC et l'adresse IP des clients soient fournies,
|
BOOTP, pour peu que l'adresse MAC et l'adresse IP des clients soient fournies,
|
||||||
@@ -1351,12 +1534,55 @@ ou dans le fichier
|
|||||||
soit présente afin d'activer le serveur DHCP pour un réseau donné (L'option
|
soit présente afin d'activer le serveur DHCP pour un réseau donné (L'option
|
||||||
.B --bootp-dynamic
|
.B --bootp-dynamic
|
||||||
supprime la nécessité des associations statiques). Le paramètre
|
supprime la nécessité des associations statiques). Le paramètre
|
||||||
"filename" (nom de fichier) de la requête BOOTP est comparé avec les
|
"filename" (nom de fichier) de la requête BOOTP est utilisé comme label, ainsi
|
||||||
identifiants de réseaux des options
|
que le label "bootp", permettant un certain contrôle sur les options retournées
|
||||||
.B dhcp-option
|
|
||||||
ainsi que le label "bootp", ce qui permet de contrôler les options retournées
|
|
||||||
aux différentes classes d'hôtes.
|
aux différentes classes d'hôtes.
|
||||||
|
|
||||||
|
Il est possible de spécifier un nom d'interface à
|
||||||
|
.B dhcp-range
|
||||||
|
sous la forme "interface:<nom d'interface>". La sémantique est comme suit :
|
||||||
|
Pour le DHCP, s'il existe une autre valeur de dhcp-range pour laquelle
|
||||||
|
_aucun_ nom d'interface n'est donné, alors le nom d'interface est ignoré
|
||||||
|
et dnsmasq se comporte comme si la partie spécifiant l'interface n'existait
|
||||||
|
pas, sinon le service DHCP n'est fourni qu'aux interfaces mentionnées dans
|
||||||
|
les déclarations dhcp-range. Pour le DNS, si il n'y a pas d'option
|
||||||
|
.B --interface
|
||||||
|
ou
|
||||||
|
.B --listen-address
|
||||||
|
, alors le comportement n'est pas impacté par la spécification d'interface. Si
|
||||||
|
l'une ou l'autre de ces options est présente, alors les interfaces mentionnées
|
||||||
|
dans les plages d'adresses dhcp-range sont rajoutées à la liste de celles
|
||||||
|
où le service DNS est assuré.
|
||||||
|
|
||||||
|
De manière similaire,
|
||||||
|
.B enable-tftp
|
||||||
|
peut prendre un nom d'interface, ce qui active le TFTP pour cette seule
|
||||||
|
interface, en ignorant les options
|
||||||
|
.B --interface
|
||||||
|
ou
|
||||||
|
.B --listen-address
|
||||||
|
De plus,
|
||||||
|
.B --tftp-secure
|
||||||
|
,
|
||||||
|
.B --tftp-unique-root
|
||||||
|
et
|
||||||
|
.B --tftp-no-blocksize
|
||||||
|
sont ignorées pour les requêtes sur de telles interfaces. (une directive
|
||||||
|
.B --tftp-root
|
||||||
|
donnant le chemin de la racine et une interface doit-être fournie).
|
||||||
|
|
||||||
|
Ces règles peuvent paraître étrange à première vue, mais elles permettent
|
||||||
|
d'ajouter à la configuration de dnsmasq des lignes de configuration de la
|
||||||
|
forme "dhcp-range=interface:virt0,192.168.0.4,192.168.0.200" afin de fournir
|
||||||
|
un service DHCP et DNS sur cette interface, sans pour autant affecter les
|
||||||
|
services fournis sur d'autres interfaces, malgré l'absence de paramètres
|
||||||
|
"interface=<interface>" sur les autres lignes de configuration.
|
||||||
|
"enable-tftp=virt0" et "tftp-root=<root>,virt0" effectuent la même chose pour
|
||||||
|
TFTP.
|
||||||
|
L'idée de tout cela est de permettre l'addition de telles lignes
|
||||||
|
automatiquement par libvirt ou un système équivalent, sans perturbation
|
||||||
|
d'une configuration manuelle existant par ailleurs.
|
||||||
|
|
||||||
.SH CODES DE SORTIE
|
.SH CODES DE SORTIE
|
||||||
.PP
|
.PP
|
||||||
0 - Dnsmasq s'est correctement lancé en tâche de fond, ou alors s'est
|
0 - Dnsmasq s'est correctement lancé en tâche de fond, ou alors s'est
|
||||||
@@ -1388,10 +1614,8 @@ ultérieur : les versions précédentes ne montaient pas en charge aussi bien.
|
|||||||
|
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq est capable de gérer le DNS et DHCP pour au moins un millier de clients.
|
Dnsmasq est capable de gérer le DNS et DHCP pour au moins un millier de clients.
|
||||||
Evidement, pour cela la valeur de
|
Pour cela, la durée des bail ne doit pas être très courte (moins d'une heure).
|
||||||
.B --dhcp-lease-max
|
La valeur de
|
||||||
doit être augmentée et la durée des baux ne doit pas être très courte (moins
|
|
||||||
d'une heure). La valeur de
|
|
||||||
.B --dns-forward-max
|
.B --dns-forward-max
|
||||||
peut-être augmentée : commencer par la rendre égale au nombre de clients et
|
peut-être augmentée : commencer par la rendre égale au nombre de clients et
|
||||||
l'augmenter si le DNS semble lent. Noter que la performance du DNS dépends
|
l'augmenter si le DNS semble lent. Noter que la performance du DNS dépends
|
||||||
@@ -1421,10 +1645,32 @@ ou d'un fichier d'hôte additionnel. Cette liste peut-être très longue, Dnsmas
|
|||||||
ayant été testé avec succès avec un million de noms. Cette taille de fichier
|
ayant été testé avec succès avec un million de noms. Cette taille de fichier
|
||||||
nécessite un processeur à 1 Ghz et environ 60 Mo de RAM.
|
nécessite un processeur à 1 Ghz et environ 60 Mo de RAM.
|
||||||
|
|
||||||
|
.SH INTERNATIONALISATION
|
||||||
|
Dnsmasq peut être compilé pour supporter l'internationalisation. Pour cela,
|
||||||
|
les cibles "all-i18n" et "install-i18n" doivent être données à make, en lieu
|
||||||
|
et place des cibles standards "all" et "install". Lorsque compilé avec le
|
||||||
|
support de l'internationalisation, dnsmasq supporte les noms de domaines
|
||||||
|
internationalisés ("internationalised domain names" ou IDN), et les messages de
|
||||||
|
traces ("logs") sont écrits dans la langue locale. Les noms de domaines dans
|
||||||
|
/etc/hosts, /etc/ethers et /etc/dnsmasq.conf contenant des caractères
|
||||||
|
non-ASCII seront transformés selon la représentation punycode interne
|
||||||
|
aux DNS. Veuillez noter que dnsmasq détermine la langue pour les messages
|
||||||
|
ainsi que le jeu de caractères susceptible d'être utilisé dans les fichiers
|
||||||
|
de configuration à partir de la variable d'environnement LANG. Ceci devrait
|
||||||
|
être configuré à la valeur par défaut du système par les scripts démarrant
|
||||||
|
dnsmasq. Lorsque les fichiers de configuration sont édités, veuillez faire
|
||||||
|
attention à le faire en utilisant la valeur de locale par défaut du système
|
||||||
|
et non une valeur spécifique à l'utilisateur, puisque dnsmasq n'a aucun
|
||||||
|
moyen de déterminer directement la valeur de jeu de caractère utilisé,
|
||||||
|
et assume de ce fait qu'il s'agit de la valeur par défaut du système.
|
||||||
|
|
||||||
.SH FICHIERS
|
.SH FICHIERS
|
||||||
.IR /etc/dnsmasq.conf
|
.IR /etc/dnsmasq.conf
|
||||||
|
|
||||||
.IR /usr/local/etc/dnsmasq.conf
|
.IR /usr/local/etc/dnsmasq.conf
|
||||||
|
.IR /var/run/dnsmasq/resolv.conf
|
||||||
|
.IR /etc/ppp/resolv.conf
|
||||||
|
.IR /etc/dhcpc/resolv.conf
|
||||||
|
|
||||||
.IR /etc/resolv.conf
|
.IR /etc/resolv.conf
|
||||||
|
|
||||||
|
|||||||
+446
-414
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -28,7 +28,64 @@ static struct iovec ifreq = {
|
|||||||
.iov_len = 0
|
.iov_len = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
#if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
|
||||||
|
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <net/route.h>
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#include <netinet/if_ether.h>
|
||||||
|
|
||||||
|
int arp_enumerate(void *parm, int (*callback)())
|
||||||
|
{
|
||||||
|
int mib[6];
|
||||||
|
size_t needed;
|
||||||
|
char *next;
|
||||||
|
struct rt_msghdr *rtm;
|
||||||
|
struct sockaddr_inarp *sin2;
|
||||||
|
struct sockaddr_dl *sdl;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
mib[0] = CTL_NET;
|
||||||
|
mib[1] = PF_ROUTE;
|
||||||
|
mib[2] = 0;
|
||||||
|
mib[3] = AF_INET;
|
||||||
|
mib[4] = NET_RT_FLAGS;
|
||||||
|
#ifdef RTF_LLINFO
|
||||||
|
mib[5] = RTF_LLINFO;
|
||||||
|
#else
|
||||||
|
mib[5] = 0;
|
||||||
|
#endif
|
||||||
|
if (sysctl(mib, 6, NULL, &needed, NULL, 0) == -1 || needed == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (!expand_buf(&ifconf, needed))
|
||||||
|
return 0;
|
||||||
|
if ((rc = sysctl(mib, 6, ifconf.iov_base, &needed, NULL, 0)) == 0 ||
|
||||||
|
errno != ENOMEM)
|
||||||
|
break;
|
||||||
|
needed += needed / 8;
|
||||||
|
}
|
||||||
|
if (rc == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (next = ifconf.iov_base ; next < (char *)ifconf.iov_base + needed; next += rtm->rtm_msglen)
|
||||||
|
{
|
||||||
|
rtm = (struct rt_msghdr *)next;
|
||||||
|
sin2 = (struct sockaddr_inarp *)(rtm + 1);
|
||||||
|
sdl = (struct sockaddr_dl *)((char *)sin2 + SA_SIZE(sin2));
|
||||||
|
if (!(*callback)(AF_INET, &sin2->sin_addr, LLADDR(sdl), sdl->sdl_alen, parm))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
int iface_enumerate(int family, void *parm, int (*callback)())
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
struct ifreq *ifr;
|
struct ifreq *ifr;
|
||||||
@@ -37,6 +94,13 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|||||||
int lastlen = 0;
|
int lastlen = 0;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
|
if (family == AF_UNSPEC)
|
||||||
|
#if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
|
||||||
|
return arp_enumerate(parm, callback);
|
||||||
|
#else
|
||||||
|
return 0; /* need code for Solaris and MacOS*/
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
|
if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -83,39 +147,42 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|||||||
ifr = (struct ifreq *)ifreq.iov_base;
|
ifr = (struct ifreq *)ifreq.iov_base;
|
||||||
memcpy(ifr, ptr, len);
|
memcpy(ifr, ptr, len);
|
||||||
|
|
||||||
if (ifr->ifr_addr.sa_family == AF_INET && ipv4_callback)
|
if (ifr->ifr_addr.sa_family == family)
|
||||||
{
|
{
|
||||||
struct in_addr addr, netmask, broadcast;
|
if (family == AF_INET)
|
||||||
broadcast.s_addr = 0;
|
|
||||||
addr = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr;
|
|
||||||
if (ioctl(fd, SIOCGIFNETMASK, ifr) == -1)
|
|
||||||
continue;
|
|
||||||
netmask = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr;
|
|
||||||
if (ioctl(fd, SIOCGIFBRDADDR, ifr) != -1)
|
|
||||||
broadcast = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr;
|
|
||||||
if (!((*ipv4_callback)(addr,
|
|
||||||
(int)if_nametoindex(ifr->ifr_name),
|
|
||||||
netmask, broadcast,
|
|
||||||
parm)))
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
else if (ifr->ifr_addr.sa_family == AF_INET6 && ipv6_callback)
|
|
||||||
{
|
|
||||||
struct in6_addr *addr = &((struct sockaddr_in6 *)&ifr->ifr_addr)->sin6_addr;
|
|
||||||
/* voodoo to clear interface field in address */
|
|
||||||
if (!(daemon->options & OPT_NOWILD) && IN6_IS_ADDR_LINKLOCAL(addr))
|
|
||||||
{
|
{
|
||||||
addr->s6_addr[2] = 0;
|
struct in_addr addr, netmask, broadcast;
|
||||||
addr->s6_addr[3] = 0;
|
broadcast.s_addr = 0;
|
||||||
|
addr = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr;
|
||||||
|
if (ioctl(fd, SIOCGIFNETMASK, ifr) == -1)
|
||||||
|
continue;
|
||||||
|
netmask = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr;
|
||||||
|
if (ioctl(fd, SIOCGIFBRDADDR, ifr) != -1)
|
||||||
|
broadcast = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr;
|
||||||
|
if (!((*callback)(addr,
|
||||||
|
(int)if_nametoindex(ifr->ifr_name),
|
||||||
|
netmask, broadcast,
|
||||||
|
parm)))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else if (family == AF_INET6)
|
||||||
|
{
|
||||||
|
struct in6_addr *addr = &((struct sockaddr_in6 *)&ifr->ifr_addr)->sin6_addr;
|
||||||
|
/* voodoo to clear interface field in address */
|
||||||
|
if (!option_bool(OPT_NOWILD) && IN6_IS_ADDR_LINKLOCAL(addr))
|
||||||
|
{
|
||||||
|
addr->s6_addr[2] = 0;
|
||||||
|
addr->s6_addr[3] = 0;
|
||||||
|
}
|
||||||
|
if (!((*callback)(addr,
|
||||||
|
(int)((struct sockaddr_in6 *)&ifr->ifr_addr)->sin6_scope_id,
|
||||||
|
(int)if_nametoindex(ifr->ifr_name),
|
||||||
|
parm)))
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
if (!((*ipv6_callback)(addr,
|
|
||||||
(int)((struct sockaddr_in6 *)&ifr->ifr_addr)->sin6_scope_id,
|
|
||||||
(int)if_nametoindex(ifr->ifr_name),
|
|
||||||
parm)))
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|||||||
+36
-127
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -75,7 +75,7 @@ void cache_init(void)
|
|||||||
struct crec *crecp;
|
struct crec *crecp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (daemon->options & OPT_LOG)
|
if (option_bool(OPT_LOG))
|
||||||
addrbuff = safe_malloc(ADDRSTRLEN);
|
addrbuff = safe_malloc(ADDRSTRLEN);
|
||||||
|
|
||||||
bignames_left = daemon->cachesize/10;
|
bignames_left = daemon->cachesize/10;
|
||||||
@@ -226,7 +226,7 @@ char *cache_get_name(struct crec *crecp)
|
|||||||
{
|
{
|
||||||
if (crecp->flags & F_BIGNAME)
|
if (crecp->flags & F_BIGNAME)
|
||||||
return crecp->name.bname->name;
|
return crecp->name.bname->name;
|
||||||
else if (crecp->flags & (F_DHCP | F_CONFIG))
|
else if (crecp->flags & F_NAMEP)
|
||||||
return crecp->name.namep;
|
return crecp->name.namep;
|
||||||
|
|
||||||
return crecp->name.sname;
|
return crecp->name.sname;
|
||||||
@@ -366,9 +366,6 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
|
|||||||
|
|
||||||
log_query(flags | F_UPSTREAM, name, addr, NULL);
|
log_query(flags | F_UPSTREAM, name, addr, NULL);
|
||||||
|
|
||||||
/* CONFIG bit means something else when stored in cache entries */
|
|
||||||
flags &= ~F_CONFIG;
|
|
||||||
|
|
||||||
/* if previous insertion failed give up now. */
|
/* if previous insertion failed give up now. */
|
||||||
if (insert_error)
|
if (insert_error)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -503,7 +500,7 @@ struct crec *cache_find_by_name(struct crec *crecp, char *name, time_t now, unsi
|
|||||||
/* first search, look for relevant entries and push to top of list
|
/* first search, look for relevant entries and push to top of list
|
||||||
also free anything which has expired */
|
also free anything which has expired */
|
||||||
struct crec *next, **up, **insert = NULL, **chainp = &ans;
|
struct crec *next, **up, **insert = NULL, **chainp = &ans;
|
||||||
int ins_flags = 0;
|
unsigned short ins_flags = 0;
|
||||||
|
|
||||||
for (up = hash_bucket(name), crecp = *up; crecp; crecp = next)
|
for (up = hash_bucket(name), crecp = *up; crecp; crecp = next)
|
||||||
{
|
{
|
||||||
@@ -695,7 +692,7 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
|
|||||||
if (hostname_isequal(cache->name.sname, a->target) &&
|
if (hostname_isequal(cache->name.sname, a->target) &&
|
||||||
(lookup = whine_malloc(sizeof(struct crec))))
|
(lookup = whine_malloc(sizeof(struct crec))))
|
||||||
{
|
{
|
||||||
lookup->flags = F_FORWARD | F_IMMORTAL | F_CONFIG | F_HOSTS | F_CNAME;
|
lookup->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_HOSTS | F_CNAME;
|
||||||
lookup->name.namep = a->alias;
|
lookup->name.namep = a->alias;
|
||||||
lookup->addr.cname.cache = cache;
|
lookup->addr.cname.cache = cache;
|
||||||
lookup->addr.cname.uid = index;
|
lookup->addr.cname.uid = index;
|
||||||
@@ -832,7 +829,7 @@ static int read_hostsfile(char *filename, int index, int cache_size)
|
|||||||
if ((canon = canonicalise(token, &nomem)))
|
if ((canon = canonicalise(token, &nomem)))
|
||||||
{
|
{
|
||||||
/* If set, add a version of the name with a default domain appended */
|
/* If set, add a version of the name with a default domain appended */
|
||||||
if ((daemon->options & OPT_EXPAND) && domain_suffix && !fqdn &&
|
if (option_bool(OPT_EXPAND) && domain_suffix && !fqdn &&
|
||||||
(cache = whine_malloc(sizeof(struct crec) +
|
(cache = whine_malloc(sizeof(struct crec) +
|
||||||
strlen(canon)+2+strlen(domain_suffix)-SMALLDNAME)))
|
strlen(canon)+2+strlen(domain_suffix)-SMALLDNAME)))
|
||||||
{
|
{
|
||||||
@@ -896,107 +893,17 @@ void cache_reload(void)
|
|||||||
up = &cache->hash_next;
|
up = &cache->hash_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((daemon->options & OPT_NO_HOSTS) && !daemon->addn_hosts)
|
if (option_bool(OPT_NO_HOSTS) && !daemon->addn_hosts)
|
||||||
{
|
{
|
||||||
if (daemon->cachesize > 0)
|
if (daemon->cachesize > 0)
|
||||||
my_syslog(LOG_INFO, _("cleared cache"));
|
my_syslog(LOG_INFO, _("cleared cache"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(daemon->options & OPT_NO_HOSTS))
|
if (!option_bool(OPT_NO_HOSTS))
|
||||||
total_size = read_hostsfile(HOSTSFILE, 0, total_size);
|
total_size = read_hostsfile(HOSTSFILE, 0, total_size);
|
||||||
|
|
||||||
for (i = 0, ah = daemon->addn_hosts; ah; ah = ah->next)
|
daemon->addn_hosts = expand_filelist(daemon->addn_hosts);
|
||||||
{
|
|
||||||
if (i <= ah->index)
|
|
||||||
i = ah->index + 1;
|
|
||||||
|
|
||||||
if (ah->flags & AH_DIR)
|
|
||||||
ah->flags |= AH_INACTIVE;
|
|
||||||
else
|
|
||||||
ah->flags &= ~AH_INACTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
|
||||||
if (!(ah->flags & AH_INACTIVE))
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
if (stat(ah->fname, &buf) != -1 && S_ISDIR(buf.st_mode))
|
|
||||||
{
|
|
||||||
DIR *dir_stream;
|
|
||||||
struct dirent *ent;
|
|
||||||
|
|
||||||
/* don't read this as a file */
|
|
||||||
ah->flags |= AH_INACTIVE;
|
|
||||||
|
|
||||||
if (!(dir_stream = opendir(ah->fname)))
|
|
||||||
my_syslog(LOG_ERR, _("cannot access directory %s: %s"),
|
|
||||||
ah->fname, strerror(errno));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while ((ent = readdir(dir_stream)))
|
|
||||||
{
|
|
||||||
size_t lendir = strlen(ah->fname);
|
|
||||||
size_t lenfile = strlen(ent->d_name);
|
|
||||||
struct hostsfile *ah1;
|
|
||||||
char *path;
|
|
||||||
|
|
||||||
/* ignore emacs backups and dotfiles */
|
|
||||||
if (lenfile == 0 ||
|
|
||||||
ent->d_name[lenfile - 1] == '~' ||
|
|
||||||
(ent->d_name[0] == '#' && ent->d_name[lenfile - 1] == '#') ||
|
|
||||||
ent->d_name[0] == '.')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* see if we have an existing record.
|
|
||||||
dir is ah->fname
|
|
||||||
file is ent->d_name
|
|
||||||
path to match is ah1->fname */
|
|
||||||
|
|
||||||
for (ah1 = daemon->addn_hosts; ah1; ah1 = ah1->next)
|
|
||||||
{
|
|
||||||
if (lendir < strlen(ah1->fname) &&
|
|
||||||
strstr(ah1->fname, ah->fname) == ah1->fname &&
|
|
||||||
ah1->fname[lendir] == '/' &&
|
|
||||||
strcmp(ah1->fname + lendir + 1, ent->d_name) == 0)
|
|
||||||
{
|
|
||||||
ah1->flags &= ~AH_INACTIVE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* make new record */
|
|
||||||
if (!ah1)
|
|
||||||
{
|
|
||||||
if (!(ah1 = whine_malloc(sizeof(struct hostsfile))))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!(path = whine_malloc(lendir + lenfile + 2)))
|
|
||||||
{
|
|
||||||
free(ah1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(path, ah->fname);
|
|
||||||
strcat(path, "/");
|
|
||||||
strcat(path, ent->d_name);
|
|
||||||
ah1->fname = path;
|
|
||||||
ah1->index = i++;
|
|
||||||
ah1->flags = AH_DIR;
|
|
||||||
ah1->next = daemon->addn_hosts;
|
|
||||||
daemon->addn_hosts = ah1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* inactivate record if not regular file */
|
|
||||||
if ((ah1->flags & AH_DIR) && stat(ah1->fname, &buf) != -1 && !S_ISREG(buf.st_mode))
|
|
||||||
ah1->flags |= AH_INACTIVE;
|
|
||||||
|
|
||||||
}
|
|
||||||
closedir(dir_stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
||||||
if (!(ah->flags & AH_INACTIVE))
|
if (!(ah->flags & AH_INACTIVE))
|
||||||
total_size = read_hostsfile(ah->fname, ah->index, total_size);
|
total_size = read_hostsfile(ah->fname, ah->index, total_size);
|
||||||
@@ -1036,7 +943,7 @@ void cache_add_dhcp_entry(char *host_name,
|
|||||||
struct in_addr *host_address, time_t ttd)
|
struct in_addr *host_address, time_t ttd)
|
||||||
{
|
{
|
||||||
struct crec *crec = NULL, *aliasc;
|
struct crec *crec = NULL, *aliasc;
|
||||||
unsigned short flags = F_DHCP | F_FORWARD | F_IPV4 | F_REVERSE;
|
unsigned short flags = F_NAMEP | F_DHCP | F_FORWARD | F_IPV4 | F_REVERSE;
|
||||||
int in_hosts = 0;
|
int in_hosts = 0;
|
||||||
struct cname *a;
|
struct cname *a;
|
||||||
|
|
||||||
@@ -1045,19 +952,22 @@ void cache_add_dhcp_entry(char *host_name,
|
|||||||
/* check all addresses associated with name */
|
/* check all addresses associated with name */
|
||||||
if (crec->flags & F_HOSTS)
|
if (crec->flags & F_HOSTS)
|
||||||
{
|
{
|
||||||
if (crec->addr.addr.addr.addr4.s_addr != host_address->s_addr)
|
/* if in hosts, don't need DHCP record */
|
||||||
|
in_hosts = 1;
|
||||||
|
|
||||||
|
if (crec->flags & F_CNAME)
|
||||||
|
my_syslog(MS_DHCP | LOG_WARNING,
|
||||||
|
_("%s is a CNAME, not giving it to the DHCP lease of %s"),
|
||||||
|
host_name, inet_ntoa(*host_address));
|
||||||
|
else if (crec->addr.addr.addr.addr4.s_addr != host_address->s_addr)
|
||||||
{
|
{
|
||||||
strcpy(daemon->namebuff, inet_ntoa(crec->addr.addr.addr.addr4));
|
strcpy(daemon->namebuff, inet_ntoa(crec->addr.addr.addr.addr4));
|
||||||
my_syslog(LOG_WARNING,
|
my_syslog(MS_DHCP | LOG_WARNING,
|
||||||
_("not giving name %s to the DHCP lease of %s because "
|
_("not giving name %s to the DHCP lease of %s because "
|
||||||
"the name exists in %s with address %s"),
|
"the name exists in %s with address %s"),
|
||||||
host_name, inet_ntoa(*host_address),
|
host_name, inet_ntoa(*host_address),
|
||||||
record_source(crec->uid), daemon->namebuff);
|
record_source(crec->uid), daemon->namebuff);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
/* if in hosts, don't need DHCP record */
|
|
||||||
in_hosts = 1;
|
|
||||||
}
|
}
|
||||||
else if (!(crec->flags & F_DHCP))
|
else if (!(crec->flags & F_DHCP))
|
||||||
{
|
{
|
||||||
@@ -1106,7 +1016,7 @@ void cache_add_dhcp_entry(char *host_name,
|
|||||||
|
|
||||||
if (aliasc)
|
if (aliasc)
|
||||||
{
|
{
|
||||||
aliasc->flags = F_FORWARD | F_CONFIG | F_DHCP | F_CNAME;
|
aliasc->flags = F_FORWARD | F_NAMEP | F_DHCP | F_CNAME;
|
||||||
if (ttd == 0)
|
if (ttd == 0)
|
||||||
aliasc->flags |= F_IMMORTAL;
|
aliasc->flags |= F_IMMORTAL;
|
||||||
else
|
else
|
||||||
@@ -1140,12 +1050,15 @@ void dump_cache(time_t now)
|
|||||||
serv->flags &= ~SERV_COUNTED;
|
serv->flags &= ~SERV_COUNTED;
|
||||||
|
|
||||||
for (serv = daemon->servers; serv; serv = serv->next)
|
for (serv = daemon->servers; serv; serv = serv->next)
|
||||||
if (!(serv->flags & (SERV_NO_ADDR | SERV_LITERAL_ADDRESS | SERV_COUNTED)))
|
if (!(serv->flags &
|
||||||
|
(SERV_NO_ADDR | SERV_LITERAL_ADDRESS | SERV_COUNTED | SERV_USE_RESOLV | SERV_NO_REBIND)))
|
||||||
{
|
{
|
||||||
int port;
|
int port;
|
||||||
unsigned int queries = 0, failed_queries = 0;
|
unsigned int queries = 0, failed_queries = 0;
|
||||||
for (serv1 = serv; serv1; serv1 = serv1->next)
|
for (serv1 = serv; serv1; serv1 = serv1->next)
|
||||||
if (!(serv1->flags & (SERV_NO_ADDR | SERV_LITERAL_ADDRESS | SERV_COUNTED)) && sockaddr_isequal(&serv->addr, &serv1->addr))
|
if (!(serv1->flags &
|
||||||
|
(SERV_NO_ADDR | SERV_LITERAL_ADDRESS | SERV_COUNTED | SERV_USE_RESOLV | SERV_NO_REBIND)) &&
|
||||||
|
sockaddr_isequal(&serv->addr, &serv1->addr))
|
||||||
{
|
{
|
||||||
serv1->flags |= SERV_COUNTED;
|
serv1->flags |= SERV_COUNTED;
|
||||||
queries += serv1->queries;
|
queries += serv1->queries;
|
||||||
@@ -1155,11 +1068,11 @@ void dump_cache(time_t now)
|
|||||||
my_syslog(LOG_INFO, _("server %s#%d: queries sent %u, retried or failed %u"), addrbuff, port, queries, failed_queries);
|
my_syslog(LOG_INFO, _("server %s#%d: queries sent %u, retried or failed %u"), addrbuff, port, queries, failed_queries);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((daemon->options & (OPT_DEBUG | OPT_LOG)))
|
if (option_bool(OPT_DEBUG) || option_bool(OPT_LOG))
|
||||||
{
|
{
|
||||||
struct crec *cache ;
|
struct crec *cache ;
|
||||||
int i;
|
int i;
|
||||||
my_syslog(LOG_DEBUG, "Host Address Flags Expires");
|
my_syslog(LOG_INFO, "Host Address Flags Expires");
|
||||||
|
|
||||||
for (i=0; i<hash_size; i++)
|
for (i=0; i<hash_size; i++)
|
||||||
for (cache = hash_table[i]; cache; cache = cache->hash_next)
|
for (cache = hash_table[i]; cache; cache = cache->hash_next)
|
||||||
@@ -1205,7 +1118,7 @@ void dump_cache(time_t now)
|
|||||||
/* ctime includes trailing \n - eat it */
|
/* ctime includes trailing \n - eat it */
|
||||||
*(p-1) = 0;
|
*(p-1) = 0;
|
||||||
#endif
|
#endif
|
||||||
my_syslog(LOG_DEBUG, daemon->namebuff);
|
my_syslog(LOG_INFO, daemon->namebuff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1234,12 +1147,12 @@ void querystr(char *str, unsigned short type)
|
|||||||
sprintf(str,"query[%s]", typestr[i].name);
|
sprintf(str,"query[%s]", typestr[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_query(unsigned short flags, char *name, struct all_addr *addr, char *arg)
|
void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg)
|
||||||
{
|
{
|
||||||
char *source, *dest = addrbuff;
|
char *source, *dest = addrbuff;
|
||||||
char *verb = "is";
|
char *verb = "is";
|
||||||
|
|
||||||
if (!(daemon->options & OPT_LOG))
|
if (!option_bool(OPT_LOG))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (addr)
|
if (addr)
|
||||||
@@ -1280,13 +1193,9 @@ void log_query(unsigned short flags, char *name, struct all_addr *addr, char *ar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (flags & F_CNAME)
|
else if (flags & F_CNAME)
|
||||||
{
|
dest = "<CNAME>";
|
||||||
/* nasty abuse of NXDOMAIN and CNAME flags */
|
else if (flags & F_RRNAME)
|
||||||
if (flags & F_NXDOMAIN)
|
dest = arg;
|
||||||
dest = arg;
|
|
||||||
else
|
|
||||||
dest = "<CNAME>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & F_CONFIG)
|
if (flags & F_CONFIG)
|
||||||
source = "config";
|
source = "config";
|
||||||
@@ -1312,6 +1221,6 @@ void log_query(unsigned short flags, char *name, struct all_addr *addr, char *ar
|
|||||||
if (strlen(name) == 0)
|
if (strlen(name) == 0)
|
||||||
name = ".";
|
name = ".";
|
||||||
|
|
||||||
my_syslog(LOG_DEBUG, "%s %s %s %s", source, name, verb, dest);
|
my_syslog(LOG_INFO, "%s %s %s %s", source, name, verb, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
+10
-10
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,19 +14,19 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION "2.51"
|
#define VERSION "2.56"
|
||||||
|
|
||||||
#define FTABSIZ 150 /* max number of outstanding requests (default) */
|
#define FTABSIZ 150 /* max number of outstanding requests (default) */
|
||||||
#define MAX_PROCS 20 /* max no children for TCP requests */
|
#define MAX_PROCS 20 /* max no children for TCP requests */
|
||||||
#define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */
|
#define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */
|
||||||
#define EDNS_PKTSZ 1280 /* default max EDNS.0 UDP packet from RFC2671 */
|
#define EDNS_PKTSZ 4096 /* default max EDNS.0 UDP packet from RFC5625 */
|
||||||
#define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
|
#define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
|
||||||
#define FORWARD_TEST 50 /* try all servers every 50 queries */
|
#define FORWARD_TEST 50 /* try all servers every 50 queries */
|
||||||
#define FORWARD_TIME 10 /* or 10 seconds */
|
#define FORWARD_TIME 20 /* or 20 seconds */
|
||||||
#define RANDOM_SOCKS 64 /* max simultaneous random ports */
|
#define RANDOM_SOCKS 64 /* max simultaneous random ports */
|
||||||
#define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
|
#define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
|
||||||
#define CACHESIZ 150 /* default cache size */
|
#define CACHESIZ 150 /* default cache size */
|
||||||
#define MAXLEASES 150 /* maximum number of DHCP leases */
|
#define MAXLEASES 1000 /* maximum number of DHCP leases */
|
||||||
#define PING_WAIT 3 /* wait for ping address-in-use test */
|
#define PING_WAIT 3 /* wait for ping address-in-use test */
|
||||||
#define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */
|
#define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */
|
||||||
#define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
|
#define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
|
||||||
@@ -66,11 +66,13 @@
|
|||||||
#define DHCP_CLIENT_PORT 68
|
#define DHCP_CLIENT_PORT 68
|
||||||
#define DHCP_SERVER_ALTPORT 1067
|
#define DHCP_SERVER_ALTPORT 1067
|
||||||
#define DHCP_CLIENT_ALTPORT 1068
|
#define DHCP_CLIENT_ALTPORT 1068
|
||||||
|
#define PXE_PORT 4011
|
||||||
#define TFTP_PORT 69
|
#define TFTP_PORT 69
|
||||||
#define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
|
#define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
|
||||||
#define LOG_MAX 5 /* log-queue length */
|
#define LOG_MAX 5 /* log-queue length */
|
||||||
#define RANDFILE "/dev/urandom"
|
#define RANDFILE "/dev/urandom"
|
||||||
#define DAD_WAIT 20 /* retry binding IPv6 sockets for this long */
|
#define DAD_WAIT 20 /* retry binding IPv6 sockets for this long */
|
||||||
|
#define EDNS0_OPTION_MAC 5 /* dyndns.org temporary assignment */
|
||||||
|
|
||||||
/* DBUS interface specifics */
|
/* DBUS interface specifics */
|
||||||
#define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq"
|
#define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq"
|
||||||
@@ -229,20 +231,20 @@ NOTES:
|
|||||||
#elif defined(__FreeBSD__) || \
|
#elif defined(__FreeBSD__) || \
|
||||||
defined(__OpenBSD__) || \
|
defined(__OpenBSD__) || \
|
||||||
defined(__DragonFly__) || \
|
defined(__DragonFly__) || \
|
||||||
defined (__FreeBSD_kernel__)
|
defined(__FreeBSD_kernel__)
|
||||||
#define HAVE_BSD_NETWORK
|
#define HAVE_BSD_NETWORK
|
||||||
/* Later verions of FreeBSD have getopt_long() */
|
/* Later verions of FreeBSD have getopt_long() */
|
||||||
#if defined(optional_argument) && defined(required_argument)
|
#if defined(optional_argument) && defined(required_argument)
|
||||||
# define HAVE_GETOPT_LONG
|
# define HAVE_GETOPT_LONG
|
||||||
#endif
|
#endif
|
||||||
#if !defined (__FreeBSD_kernel__)
|
#if !defined(__FreeBSD_kernel__)
|
||||||
# define HAVE_ARC4RANDOM
|
# define HAVE_ARC4RANDOM
|
||||||
#endif
|
#endif
|
||||||
#define HAVE_SOCKADDR_SA_LEN
|
#define HAVE_SOCKADDR_SA_LEN
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define HAVE_BSD_NETWORK
|
#define HAVE_BSD_NETWORK
|
||||||
#undef HAVE_GETOPT_LONG
|
#define HAVE_GETOPT_LONG
|
||||||
#define HAVE_ARC4RANDOM
|
#define HAVE_ARC4RANDOM
|
||||||
#define HAVE_SOCKADDR_SA_LEN
|
#define HAVE_SOCKADDR_SA_LEN
|
||||||
/* Define before sys/socket.h is included so we get socklen_t */
|
/* Define before sys/socket.h is included so we get socklen_t */
|
||||||
@@ -259,8 +261,6 @@ NOTES:
|
|||||||
#define HAVE_GETOPT_LONG
|
#define HAVE_GETOPT_LONG
|
||||||
#undef HAVE_ARC4RANDOM
|
#undef HAVE_ARC4RANDOM
|
||||||
#undef HAVE_SOCKADDR_SA_LEN
|
#undef HAVE_SOCKADDR_SA_LEN
|
||||||
#define _XPG4_2
|
|
||||||
#define __EXTENSIONS__
|
|
||||||
#define ETHER_ADDR_LEN 6
|
#define ETHER_ADDR_LEN 6
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -390,6 +390,7 @@ void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
|
void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
|
||||||
{
|
{
|
||||||
DBusConnection *connection = (DBusConnection *)daemon->dbus;
|
DBusConnection *connection = (DBusConnection *)daemon->dbus;
|
||||||
@@ -432,5 +433,6 @@ void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
|
|||||||
|
|
||||||
dbus_message_unref(message);
|
dbus_message_unref(message);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+149
-57
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -27,7 +27,7 @@ struct iface_param {
|
|||||||
static int complete_context(struct in_addr local, int if_index,
|
static int complete_context(struct in_addr local, int if_index,
|
||||||
struct in_addr netmask, struct in_addr broadcast, void *vparam);
|
struct in_addr netmask, struct in_addr broadcast, void *vparam);
|
||||||
|
|
||||||
void dhcp_init(void)
|
static int make_fd(int port)
|
||||||
{
|
{
|
||||||
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
struct sockaddr_in saddr;
|
struct sockaddr_in saddr;
|
||||||
@@ -54,7 +54,7 @@ void dhcp_init(void)
|
|||||||
/* When bind-interfaces is set, there might be more than one dnmsasq
|
/* When bind-interfaces is set, there might be more than one dnmsasq
|
||||||
instance binding port 67. That's OK if they serve different networks.
|
instance binding port 67. That's OK if they serve different networks.
|
||||||
Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD. */
|
Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD. */
|
||||||
if (daemon->options & OPT_NOWILD)
|
if (option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt));
|
int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt));
|
||||||
@@ -67,7 +67,7 @@ void dhcp_init(void)
|
|||||||
|
|
||||||
memset(&saddr, 0, sizeof(saddr));
|
memset(&saddr, 0, sizeof(saddr));
|
||||||
saddr.sin_family = AF_INET;
|
saddr.sin_family = AF_INET;
|
||||||
saddr.sin_port = htons(daemon->dhcp_server_port);
|
saddr.sin_port = htons(port);
|
||||||
saddr.sin_addr.s_addr = INADDR_ANY;
|
saddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||||
saddr.sin_len = sizeof(struct sockaddr_in);
|
saddr.sin_len = sizeof(struct sockaddr_in);
|
||||||
@@ -76,14 +76,27 @@ void dhcp_init(void)
|
|||||||
if (bind(fd, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)))
|
if (bind(fd, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)))
|
||||||
die(_("failed to bind DHCP server socket: %s"), NULL, EC_BADNET);
|
die(_("failed to bind DHCP server socket: %s"), NULL, EC_BADNET);
|
||||||
|
|
||||||
daemon->dhcpfd = fd;
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dhcp_init(void)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_BSD_NETWORK)
|
||||||
|
int oneopt = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
daemon->dhcpfd = make_fd(daemon->dhcp_server_port);
|
||||||
|
if (daemon->enable_pxe)
|
||||||
|
daemon->pxefd = make_fd(PXE_PORT);
|
||||||
|
else
|
||||||
|
daemon->pxefd = -1;
|
||||||
|
|
||||||
#if defined(HAVE_BSD_NETWORK)
|
#if defined(HAVE_BSD_NETWORK)
|
||||||
/* When we're not using capabilities, we need to do this here before
|
/* When we're not using capabilities, we need to do this here before
|
||||||
we drop root. Also, set buffer size small, to avoid wasting
|
we drop root. Also, set buffer size small, to avoid wasting
|
||||||
kernel buffers */
|
kernel buffers */
|
||||||
|
|
||||||
if (daemon->options & OPT_NO_PING)
|
if (option_bool(OPT_NO_PING))
|
||||||
daemon->dhcp_icmp_fd = -1;
|
daemon->dhcp_icmp_fd = -1;
|
||||||
else if ((daemon->dhcp_icmp_fd = make_icmp_sock()) == -1 ||
|
else if ((daemon->dhcp_icmp_fd = make_icmp_sock()) == -1 ||
|
||||||
setsockopt(daemon->dhcp_icmp_fd, SOL_SOCKET, SO_RCVBUF, &oneopt, sizeof(oneopt)) == -1 )
|
setsockopt(daemon->dhcp_icmp_fd, SOL_SOCKET, SO_RCVBUF, &oneopt, sizeof(oneopt)) == -1 )
|
||||||
@@ -99,8 +112,9 @@ void dhcp_init(void)
|
|||||||
daemon->dhcp_packet.iov_base = safe_malloc(daemon->dhcp_packet.iov_len);
|
daemon->dhcp_packet.iov_base = safe_malloc(daemon->dhcp_packet.iov_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dhcp_packet(time_t now)
|
void dhcp_packet(time_t now, int pxe_fd)
|
||||||
{
|
{
|
||||||
|
int fd = pxe_fd ? daemon->pxefd : daemon->dhcpfd;
|
||||||
struct dhcp_packet *mess;
|
struct dhcp_packet *mess;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
@@ -113,7 +127,10 @@ void dhcp_packet(time_t now)
|
|||||||
int iface_index = 0, unicast_dest = 0, is_inform = 0;
|
int iface_index = 0, unicast_dest = 0, is_inform = 0;
|
||||||
struct in_addr iface_addr, *addrp = NULL;
|
struct in_addr iface_addr, *addrp = NULL;
|
||||||
struct iface_param parm;
|
struct iface_param parm;
|
||||||
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
|
struct arpreq arp_req;
|
||||||
|
#endif
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct cmsghdr align; /* this ensures alignment */
|
struct cmsghdr align; /* this ensures alignment */
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
@@ -135,7 +152,7 @@ void dhcp_packet(time_t now)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
msg.msg_flags = 0;
|
msg.msg_flags = 0;
|
||||||
while ((sz = recvmsg(daemon->dhcpfd, &msg, MSG_PEEK | MSG_TRUNC)) == -1 && errno == EINTR);
|
while ((sz = recvmsg(fd, &msg, MSG_PEEK | MSG_TRUNC)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
if (sz == -1)
|
if (sz == -1)
|
||||||
return;
|
return;
|
||||||
@@ -165,7 +182,7 @@ void dhcp_packet(time_t now)
|
|||||||
msg.msg_name = &dest;
|
msg.msg_name = &dest;
|
||||||
msg.msg_namelen = sizeof(dest);
|
msg.msg_namelen = sizeof(dest);
|
||||||
|
|
||||||
while ((sz = recvmsg(daemon->dhcpfd, &msg, 0)) == -1 && errno == EINTR);
|
while ((sz = recvmsg(fd, &msg, 0)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
if ((msg.msg_flags & MSG_TRUNC) || sz < (ssize_t)(sizeof(*mess) - sizeof(mess->options)))
|
if ((msg.msg_flags & MSG_TRUNC) || sz < (ssize_t)(sizeof(*mess) - sizeof(mess->options)))
|
||||||
return;
|
return;
|
||||||
@@ -175,8 +192,13 @@ void dhcp_packet(time_t now)
|
|||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
|
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
|
||||||
{
|
{
|
||||||
iface_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
|
union {
|
||||||
if (((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_addr.s_addr != INADDR_BROADCAST)
|
unsigned char *c;
|
||||||
|
struct in_pktinfo *p;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
iface_index = p.p->ipi_ifindex;
|
||||||
|
if (p.p->ipi_addr.s_addr != INADDR_BROADCAST)
|
||||||
unicast_dest = 1;
|
unicast_dest = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,20 +206,37 @@ void dhcp_packet(time_t now)
|
|||||||
if (msg.msg_controllen >= sizeof(struct cmsghdr))
|
if (msg.msg_controllen >= sizeof(struct cmsghdr))
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
iface_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
{
|
||||||
|
union {
|
||||||
|
unsigned char *c;
|
||||||
|
struct sockaddr_dl *s;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
iface_index = p.s->sdl_index;
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
if (msg.msg_controllen >= sizeof(struct cmsghdr))
|
if (msg.msg_controllen >= sizeof(struct cmsghdr))
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
iface_index = *((unsigned int *)CMSG_DATA(cmptr));
|
{
|
||||||
|
union {
|
||||||
|
unsigned char *c;
|
||||||
|
unsigned int *i;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
iface_index = *(p.i);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!indextoname(daemon->dhcpfd, iface_index, ifr.ifr_name))
|
if (!indextoname(daemon->dhcpfd, iface_index, ifr.ifr_name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
|
/* ARP fiddling uses original interface even if we pretend to use a different one. */
|
||||||
|
strncpy(arp_req.arp_dev, ifr.ifr_name, 16);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MSG_BCAST
|
#ifdef MSG_BCAST
|
||||||
/* OpenBSD tells us when a packet was broadcast */
|
/* OpenBSD tells us when a packet was broadcast */
|
||||||
if (!(msg.msg_flags & MSG_BCAST))
|
if (!(msg.msg_flags & MSG_BCAST))
|
||||||
@@ -217,18 +256,14 @@ void dhcp_packet(time_t now)
|
|||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* interface may have been changed by alias in iface_check */
|
/* weird libvirt-inspired access control */
|
||||||
if (!addrp)
|
for (context = daemon->dhcp; context; context = context->next)
|
||||||
{
|
if (!context->interface || strcmp(context->interface, ifr.ifr_name) == 0)
|
||||||
if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) == -1)
|
break;
|
||||||
{
|
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
|
if (!context)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else
|
|
||||||
iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* unlinked contexts are marked by context->current == context */
|
/* unlinked contexts are marked by context->current == context */
|
||||||
for (context = daemon->dhcp; context; context = context->next)
|
for (context = daemon->dhcp; context; context = context->next)
|
||||||
@@ -239,11 +274,32 @@ void dhcp_packet(time_t now)
|
|||||||
parm.current = NULL;
|
parm.current = NULL;
|
||||||
parm.ind = iface_index;
|
parm.ind = iface_index;
|
||||||
|
|
||||||
if (!iface_enumerate(&parm, complete_context, NULL))
|
/* interface may have been changed by alias in iface_check, make sure it gets priority in case
|
||||||
|
there is more than one address on the interface in the same subnet */
|
||||||
|
if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) == -1)
|
||||||
|
{
|
||||||
|
my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
|
||||||
|
if (ioctl(daemon->dhcpfd, SIOCGIFNETMASK, &ifr) != -1)
|
||||||
|
{
|
||||||
|
struct in_addr netmask = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
|
||||||
|
if (ioctl(daemon->dhcpfd, SIOCGIFBRDADDR, &ifr) != -1)
|
||||||
|
{
|
||||||
|
struct in_addr broadcast = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
|
||||||
|
complete_context(iface_addr, iface_index, netmask, broadcast, &parm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!iface_enumerate(AF_INET, &parm, complete_context))
|
||||||
return;
|
return;
|
||||||
lease_prune(NULL, now); /* lose any expired leases */
|
lease_prune(NULL, now); /* lose any expired leases */
|
||||||
iov.iov_len = dhcp_reply(parm.current, ifr.ifr_name, iface_index, (size_t)sz,
|
iov.iov_len = dhcp_reply(parm.current, ifr.ifr_name, iface_index, (size_t)sz,
|
||||||
now, unicast_dest, &is_inform);
|
now, unicast_dest, &is_inform, pxe_fd);
|
||||||
lease_update_file(now);
|
lease_update_file(now);
|
||||||
lease_update_dns();
|
lease_update_dns();
|
||||||
|
|
||||||
@@ -264,7 +320,12 @@ void dhcp_packet(time_t now)
|
|||||||
dest.sin_len = sizeof(struct sockaddr_in);
|
dest.sin_len = sizeof(struct sockaddr_in);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mess->giaddr.s_addr)
|
if (pxe_fd)
|
||||||
|
{
|
||||||
|
if (mess->ciaddr.s_addr != 0)
|
||||||
|
dest.sin_addr = mess->ciaddr;
|
||||||
|
}
|
||||||
|
else if (mess->giaddr.s_addr)
|
||||||
{
|
{
|
||||||
/* Send to BOOTP relay */
|
/* Send to BOOTP relay */
|
||||||
dest.sin_port = htons(daemon->dhcp_server_port);
|
dest.sin_port = htons(daemon->dhcp_server_port);
|
||||||
@@ -305,15 +366,14 @@ void dhcp_packet(time_t now)
|
|||||||
{
|
{
|
||||||
/* unicast to unconfigured client. Inject mac address direct into ARP cache.
|
/* unicast to unconfigured client. Inject mac address direct into ARP cache.
|
||||||
struct sockaddr limits size to 14 bytes. */
|
struct sockaddr limits size to 14 bytes. */
|
||||||
struct arpreq req;
|
|
||||||
dest.sin_addr = mess->yiaddr;
|
dest.sin_addr = mess->yiaddr;
|
||||||
dest.sin_port = htons(daemon->dhcp_client_port);
|
dest.sin_port = htons(daemon->dhcp_client_port);
|
||||||
*((struct sockaddr_in *)&req.arp_pa) = dest;
|
memcpy(&arp_req.arp_pa, &dest, sizeof(struct sockaddr_in));
|
||||||
req.arp_ha.sa_family = mess->htype;
|
arp_req.arp_ha.sa_family = mess->htype;
|
||||||
memcpy(req.arp_ha.sa_data, mess->chaddr, mess->hlen);
|
memcpy(arp_req.arp_ha.sa_data, mess->chaddr, mess->hlen);
|
||||||
strncpy(req.arp_dev, ifr.ifr_name, 16);
|
/* interface name already copied in */
|
||||||
req.arp_flags = ATF_COM;
|
arp_req.arp_flags = ATF_COM;
|
||||||
ioctl(daemon->dhcpfd, SIOCSARP, &req);
|
ioctl(daemon->dhcpfd, SIOCSARP, &arp_req);
|
||||||
}
|
}
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
else if ((ntohs(mess->flags) & 0x8000) || mess->hlen != ETHER_ADDR_LEN || mess->htype != ARPHRD_ETHER)
|
else if ((ntohs(mess->flags) & 0x8000) || mess->hlen != ETHER_ADDR_LEN || mess->htype != ARPHRD_ETHER)
|
||||||
@@ -348,10 +408,10 @@ void dhcp_packet(time_t now)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
#ifdef HAVE_SOLARIS_NETWORK
|
||||||
setsockopt(daemon->dhcpfd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index));
|
setsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while(sendmsg(daemon->dhcpfd, &msg, 0) == -1 && retry_send());
|
while(sendmsg(fd, &msg, 0) == -1 && retry_send());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is a complex routine: it gets called with each (address,netmask,broadcast) triple
|
/* This is a complex routine: it gets called with each (address,netmask,broadcast) triple
|
||||||
@@ -472,13 +532,15 @@ struct dhcp_context *narrow_context(struct dhcp_context *context,
|
|||||||
if (!(tmp = address_available(context, taddr, netids)))
|
if (!(tmp = address_available(context, taddr, netids)))
|
||||||
{
|
{
|
||||||
for (tmp = context; tmp; tmp = tmp->current)
|
for (tmp = context; tmp; tmp = tmp->current)
|
||||||
if (is_same_net(taddr, tmp->start, tmp->netmask) &&
|
if (match_netid(tmp->filter, netids, 1) &&
|
||||||
|
is_same_net(taddr, tmp->start, tmp->netmask) &&
|
||||||
(tmp->flags & CONTEXT_STATIC))
|
(tmp->flags & CONTEXT_STATIC))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
for (tmp = context; tmp; tmp = tmp->current)
|
for (tmp = context; tmp; tmp = tmp->current)
|
||||||
if (is_same_net(taddr, tmp->start, tmp->netmask))
|
if (match_netid(tmp->filter, netids, 1) &&
|
||||||
|
is_same_net(taddr, tmp->start, tmp->netmask))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +573,8 @@ int match_netid(struct dhcp_netid *check, struct dhcp_netid *pool, int tagnotnee
|
|||||||
|
|
||||||
for (; check; check = check->next)
|
for (; check; check = check->next)
|
||||||
{
|
{
|
||||||
if (check->net[0] != '#')
|
/* '#' for not is for backwards compat. */
|
||||||
|
if (check->net[0] != '!' && check->net[0] != '#')
|
||||||
{
|
{
|
||||||
for (tmp1 = pool; tmp1; tmp1 = tmp1->next)
|
for (tmp1 = pool; tmp1; tmp1 = tmp1->next)
|
||||||
if (strcmp(check->net, tmp1->net) == 0)
|
if (strcmp(check->net, tmp1->net) == 0)
|
||||||
@@ -527,6 +590,22 @@ int match_netid(struct dhcp_netid *check, struct dhcp_netid *pool, int tagnotnee
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct dhcp_netid *run_tag_if(struct dhcp_netid *tags)
|
||||||
|
{
|
||||||
|
struct tag_if *exprs;
|
||||||
|
struct dhcp_netid_list *list;
|
||||||
|
|
||||||
|
for (exprs = daemon->tag_if; exprs; exprs = exprs->next)
|
||||||
|
if (match_netid(exprs->tag, tags, 1))
|
||||||
|
for (list = exprs->set; list; list = list->next)
|
||||||
|
{
|
||||||
|
list->list->next = tags;
|
||||||
|
tags = list->list;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
int address_allocate(struct dhcp_context *context,
|
int address_allocate(struct dhcp_context *context,
|
||||||
struct in_addr *addrp, unsigned char *hwaddr, int hw_len,
|
struct in_addr *addrp, unsigned char *hwaddr, int hw_len,
|
||||||
struct dhcp_netid *netids, time_t now)
|
struct dhcp_netid *netids, time_t now)
|
||||||
@@ -540,9 +619,10 @@ int address_allocate(struct dhcp_context *context,
|
|||||||
int i, pass;
|
int i, pass;
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
/* hash hwaddr */
|
/* hash hwaddr: use the SDBM hashing algorithm. Seems to give good
|
||||||
|
dispersal even with similarly-valued "strings". */
|
||||||
for (j = 0, i = 0; i < hw_len; i++)
|
for (j = 0, i = 0; i < hw_len; i++)
|
||||||
j += hwaddr[i] + (hwaddr[i] << 8) + (hwaddr[i] << 16);
|
j += hwaddr[i] + (j << 6) + (j << 16) - j;
|
||||||
|
|
||||||
for (pass = 0; pass <= 1; pass++)
|
for (pass = 0; pass <= 1; pass++)
|
||||||
for (c = context; c; c = c->current)
|
for (c = context; c; c = c->current)
|
||||||
@@ -580,7 +660,7 @@ int address_allocate(struct dhcp_context *context,
|
|||||||
|
|
||||||
*addrp = addr;
|
*addrp = addr;
|
||||||
|
|
||||||
if (daemon->options & OPT_NO_PING)
|
if (option_bool(OPT_NO_PING))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* check if we failed to ping addr sometime in the last
|
/* check if we failed to ping addr sometime in the last
|
||||||
@@ -837,6 +917,7 @@ void dhcp_read_ethers(void)
|
|||||||
config->flags = CONFIG_FROM_ETHERS;
|
config->flags = CONFIG_FROM_ETHERS;
|
||||||
config->hwaddr = NULL;
|
config->hwaddr = NULL;
|
||||||
config->domain = NULL;
|
config->domain = NULL;
|
||||||
|
config->netid = NULL;
|
||||||
config->next = daemon->dhcp_conf;
|
config->next = daemon->dhcp_conf;
|
||||||
daemon->dhcp_conf = config;
|
daemon->dhcp_conf = config;
|
||||||
}
|
}
|
||||||
@@ -958,29 +1039,40 @@ void dhcp_update_configs(struct dhcp_config *configs)
|
|||||||
/* If we've not found a hostname any other way, try and see if there's one in /etc/hosts
|
/* If we've not found a hostname any other way, try and see if there's one in /etc/hosts
|
||||||
for this address. If it has a domain part, that must match the set domain and
|
for this address. If it has a domain part, that must match the set domain and
|
||||||
it gets stripped. The set of legal domain names is bigger than the set of legal hostnames
|
it gets stripped. The set of legal domain names is bigger than the set of legal hostnames
|
||||||
so check here that the domain name is legal as a hostname. */
|
so check here that the domain name is legal as a hostname.
|
||||||
|
NOTE: we're only allowed to overwrite daemon->dhcp_buff if we succeed. */
|
||||||
char *host_from_dns(struct in_addr addr)
|
char *host_from_dns(struct in_addr addr)
|
||||||
{
|
{
|
||||||
struct crec *lookup;
|
struct crec *lookup;
|
||||||
char *hostname = NULL;
|
|
||||||
char *d1, *d2;
|
|
||||||
|
|
||||||
if (daemon->port == 0)
|
if (daemon->port == 0)
|
||||||
return NULL; /* DNS disabled. */
|
return NULL; /* DNS disabled. */
|
||||||
|
|
||||||
lookup = cache_find_by_addr(NULL, (struct all_addr *)&addr, 0, F_IPV4);
|
lookup = cache_find_by_addr(NULL, (struct all_addr *)&addr, 0, F_IPV4);
|
||||||
|
|
||||||
if (lookup && (lookup->flags & F_HOSTS))
|
if (lookup && (lookup->flags & F_HOSTS))
|
||||||
{
|
{
|
||||||
hostname = daemon->dhcp_buff;
|
char *dot, *hostname = cache_get_name(lookup);
|
||||||
strncpy(hostname, cache_get_name(lookup), 256);
|
dot = strchr(hostname, '.');
|
||||||
hostname[255] = 0;
|
|
||||||
d1 = strip_hostname(hostname);
|
if (dot && strlen(dot+1) != 0)
|
||||||
d2 = get_domain(addr);
|
{
|
||||||
if (!legal_hostname(hostname) || (d1 && (!d2 || !hostname_isequal(d1, d2))))
|
char *d2 = get_domain(addr);
|
||||||
hostname = NULL;
|
if (!d2 || !hostname_isequal(dot+1, d2))
|
||||||
|
return NULL; /* wrong domain */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!legal_hostname(hostname))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
strncpy(daemon->dhcp_buff, hostname, 256);
|
||||||
|
daemon->dhcp_buff[255] = 0;
|
||||||
|
strip_hostname(daemon->dhcp_buff);
|
||||||
|
|
||||||
|
return daemon->dhcp_buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hostname;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return domain or NULL if none. */
|
/* return domain or NULL if none. */
|
||||||
|
|||||||
+86
-56
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -63,7 +63,6 @@ static void check_dns_listeners(fd_set *set, time_t now);
|
|||||||
static void sig_handler(int sig);
|
static void sig_handler(int sig);
|
||||||
static void async_event(int pipe, time_t now);
|
static void async_event(int pipe, time_t now);
|
||||||
static void fatal_event(struct event_desc *ev);
|
static void fatal_event(struct event_desc *ev);
|
||||||
static void poll_resolv(void);
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -134,15 +133,15 @@ int main (int argc, char **argv)
|
|||||||
#elif !(defined(IP_RECVDSTADDR) && \
|
#elif !(defined(IP_RECVDSTADDR) && \
|
||||||
defined(IP_RECVIF) && \
|
defined(IP_RECVIF) && \
|
||||||
defined(IP_SENDSRCADDR))
|
defined(IP_SENDSRCADDR))
|
||||||
if (!(daemon->options & OPT_NOWILD))
|
if (!option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
bind_fallback = 1;
|
bind_fallback = 1;
|
||||||
daemon->options |= OPT_NOWILD;
|
set_option_bool(OPT_NOWILD);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_TFTP
|
#ifndef HAVE_TFTP
|
||||||
if (daemon->options & OPT_TFTP)
|
if (daemon->tftp_unlimited || daemon->tftp_interfaces)
|
||||||
die(_("TFTP server not available: set HAVE_TFTP in src/config.h"), NULL, EC_BADCONF);
|
die(_("TFTP server not available: set HAVE_TFTP in src/config.h"), NULL, EC_BADCONF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -169,7 +168,7 @@ int main (int argc, char **argv)
|
|||||||
if (!enumerate_interfaces())
|
if (!enumerate_interfaces())
|
||||||
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
|
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
|
||||||
|
|
||||||
if (daemon->options & OPT_NOWILD)
|
if (option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
daemon->listeners = create_bound_listeners();
|
daemon->listeners = create_bound_listeners();
|
||||||
|
|
||||||
@@ -184,14 +183,13 @@ int main (int argc, char **argv)
|
|||||||
die(_("no interface with address %s"), daemon->namebuff, EC_BADNET);
|
die(_("no interface with address %s"), daemon->namebuff, EC_BADNET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((daemon->port != 0 || (daemon->options & OPT_TFTP)) &&
|
else
|
||||||
!(daemon->listeners = create_wildcard_listeners()))
|
daemon->listeners = create_wildcard_listeners();
|
||||||
die(_("failed to create listening socket: %s"), NULL, EC_BADNET);
|
|
||||||
|
|
||||||
if (daemon->port != 0)
|
if (daemon->port != 0)
|
||||||
cache_init();
|
cache_init();
|
||||||
|
|
||||||
if (daemon->options & OPT_DBUS)
|
if (option_bool(OPT_DBUS))
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
{
|
{
|
||||||
char *err;
|
char *err;
|
||||||
@@ -276,10 +274,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
err_pipe[1] = -1;
|
err_pipe[1] = -1;
|
||||||
|
|
||||||
if (!(daemon->options & OPT_DEBUG))
|
if (!option_bool(OPT_DEBUG))
|
||||||
{
|
{
|
||||||
int nullfd;
|
|
||||||
|
|
||||||
/* The following code "daemonizes" the process.
|
/* The following code "daemonizes" the process.
|
||||||
See Stevens section 12.4 */
|
See Stevens section 12.4 */
|
||||||
|
|
||||||
@@ -287,7 +283,7 @@ int main (int argc, char **argv)
|
|||||||
die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
|
die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
|
||||||
|
|
||||||
#ifndef NO_FORK
|
#ifndef NO_FORK
|
||||||
if (!(daemon->options & OPT_NO_FORK))
|
if (!option_bool(OPT_NO_FORK))
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
@@ -344,16 +340,19 @@ int main (int argc, char **argv)
|
|||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open stdout etc to /dev/null */
|
|
||||||
nullfd = open("/dev/null", O_RDWR);
|
|
||||||
dup2(nullfd, STDOUT_FILENO);
|
|
||||||
dup2(nullfd, STDERR_FILENO);
|
|
||||||
dup2(nullfd, STDIN_FILENO);
|
|
||||||
close(nullfd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_err = log_start(ent_pw, err_pipe[1]);
|
log_err = log_start(ent_pw, err_pipe[1]);
|
||||||
|
|
||||||
|
if (!option_bool(OPT_DEBUG))
|
||||||
|
{
|
||||||
|
/* open stdout etc to /dev/null */
|
||||||
|
int nullfd = open("/dev/null", O_RDWR);
|
||||||
|
dup2(nullfd, STDOUT_FILENO);
|
||||||
|
dup2(nullfd, STDERR_FILENO);
|
||||||
|
dup2(nullfd, STDIN_FILENO);
|
||||||
|
close(nullfd);
|
||||||
|
}
|
||||||
|
|
||||||
/* if we are to run scripts, we need to fork a helper before dropping root. */
|
/* if we are to run scripts, we need to fork a helper before dropping root. */
|
||||||
daemon->helperfd = -1;
|
daemon->helperfd = -1;
|
||||||
@@ -362,7 +361,7 @@ int main (int argc, char **argv)
|
|||||||
daemon->helperfd = create_helper(pipewrite, err_pipe[1], script_uid, script_gid, max_fd);
|
daemon->helperfd = create_helper(pipewrite, err_pipe[1], script_uid, script_gid, max_fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(daemon->options & OPT_DEBUG) && getuid() == 0)
|
if (!option_bool(OPT_DEBUG) && getuid() == 0)
|
||||||
{
|
{
|
||||||
int bad_capabilities = 0;
|
int bad_capabilities = 0;
|
||||||
gid_t dummy;
|
gid_t dummy;
|
||||||
@@ -440,7 +439,7 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
if (daemon->options & OPT_DEBUG)
|
if (option_bool(OPT_DEBUG))
|
||||||
prctl(PR_SET_DUMPABLE, 1);
|
prctl(PR_SET_DUMPABLE, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -454,7 +453,7 @@ int main (int argc, char **argv)
|
|||||||
my_syslog(LOG_INFO, _("compile time options: %s"), compile_opts);
|
my_syslog(LOG_INFO, _("compile time options: %s"), compile_opts);
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
if (daemon->options & OPT_DBUS)
|
if (option_bool(OPT_DBUS))
|
||||||
{
|
{
|
||||||
if (daemon->dbus)
|
if (daemon->dbus)
|
||||||
my_syslog(LOG_INFO, _("DBus support enabled: connected to system bus"));
|
my_syslog(LOG_INFO, _("DBus support enabled: connected to system bus"));
|
||||||
@@ -470,12 +469,12 @@ int main (int argc, char **argv)
|
|||||||
if (bind_fallback)
|
if (bind_fallback)
|
||||||
my_syslog(LOG_WARNING, _("setting --bind-interfaces option because of OS limitations"));
|
my_syslog(LOG_WARNING, _("setting --bind-interfaces option because of OS limitations"));
|
||||||
|
|
||||||
if (!(daemon->options & OPT_NOWILD))
|
if (!option_bool(OPT_NOWILD))
|
||||||
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
||||||
if (if_tmp->name && !if_tmp->used)
|
if (if_tmp->name && !if_tmp->used)
|
||||||
my_syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name);
|
my_syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name);
|
||||||
|
|
||||||
if (daemon->port != 0 && (daemon->options & OPT_NO_RESOLV))
|
if (daemon->port != 0 && option_bool(OPT_NO_RESOLV))
|
||||||
{
|
{
|
||||||
if (daemon->resolv_files && !daemon->resolv_files->is_default)
|
if (daemon->resolv_files && !daemon->resolv_files->is_default)
|
||||||
my_syslog(LOG_WARNING, _("warning: ignoring resolv-file flag because no-resolv is set"));
|
my_syslog(LOG_WARNING, _("warning: ignoring resolv-file flag because no-resolv is set"));
|
||||||
@@ -508,7 +507,7 @@ int main (int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_TFTP
|
#ifdef HAVE_TFTP
|
||||||
if (daemon->options & OPT_TFTP)
|
if (daemon->tftp_unlimited || daemon->tftp_interfaces)
|
||||||
{
|
{
|
||||||
#ifdef FD_SETSIZE
|
#ifdef FD_SETSIZE
|
||||||
if (FD_SETSIZE < (unsigned)max_fd)
|
if (FD_SETSIZE < (unsigned)max_fd)
|
||||||
@@ -518,7 +517,7 @@ int main (int argc, char **argv)
|
|||||||
my_syslog(MS_TFTP | LOG_INFO, "TFTP %s%s %s",
|
my_syslog(MS_TFTP | LOG_INFO, "TFTP %s%s %s",
|
||||||
daemon->tftp_prefix ? _("root is ") : _("enabled"),
|
daemon->tftp_prefix ? _("root is ") : _("enabled"),
|
||||||
daemon->tftp_prefix ? daemon->tftp_prefix: "",
|
daemon->tftp_prefix ? daemon->tftp_prefix: "",
|
||||||
daemon->options & OPT_TFTP_SECURE ? _("secure mode") : "");
|
option_bool(OPT_TFTP_SECURE) ? _("secure mode") : "");
|
||||||
|
|
||||||
/* This is a guess, it assumes that for small limits,
|
/* This is a guess, it assumes that for small limits,
|
||||||
disjoint files might be served, but for large limits,
|
disjoint files might be served, but for large limits,
|
||||||
@@ -580,7 +579,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
/* Whilst polling for the dbus, or doing a tftp transfer, wake every quarter second */
|
/* Whilst polling for the dbus, or doing a tftp transfer, wake every quarter second */
|
||||||
if (daemon->tftp_trans ||
|
if (daemon->tftp_trans ||
|
||||||
((daemon->options & OPT_DBUS) && !daemon->dbus))
|
(option_bool(OPT_DBUS) && !daemon->dbus))
|
||||||
{
|
{
|
||||||
t.tv_sec = 0;
|
t.tv_sec = 0;
|
||||||
t.tv_usec = 250000;
|
t.tv_usec = 250000;
|
||||||
@@ -596,6 +595,11 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
FD_SET(daemon->dhcpfd, &rset);
|
FD_SET(daemon->dhcpfd, &rset);
|
||||||
bump_maxfd(daemon->dhcpfd, &maxfd);
|
bump_maxfd(daemon->dhcpfd, &maxfd);
|
||||||
|
if (daemon->pxefd != -1)
|
||||||
|
{
|
||||||
|
FD_SET(daemon->pxefd, &rset);
|
||||||
|
bump_maxfd(daemon->pxefd, &maxfd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -636,29 +640,30 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
check_log_writer(&wset);
|
check_log_writer(&wset);
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
|
if (FD_ISSET(daemon->netlinkfd, &rset))
|
||||||
|
netlink_multicast();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check for changes to resolv files once per second max. */
|
/* Check for changes to resolv files once per second max. */
|
||||||
/* Don't go silent for long periods if the clock goes backwards. */
|
/* Don't go silent for long periods if the clock goes backwards. */
|
||||||
if (daemon->last_resolv == 0 ||
|
if (daemon->last_resolv == 0 ||
|
||||||
difftime(now, daemon->last_resolv) > 1.0 ||
|
difftime(now, daemon->last_resolv) > 1.0 ||
|
||||||
difftime(now, daemon->last_resolv) < -1.0)
|
difftime(now, daemon->last_resolv) < -1.0)
|
||||||
{
|
{
|
||||||
daemon->last_resolv = now;
|
/* poll_resolv doesn't need to reload first time through, since
|
||||||
|
that's queued anyway. */
|
||||||
|
|
||||||
if (daemon->port != 0 && !(daemon->options & OPT_NO_POLL))
|
poll_resolv(0, daemon->last_resolv != 0, now);
|
||||||
poll_resolv();
|
daemon->last_resolv = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(piperead, &rset))
|
if (FD_ISSET(piperead, &rset))
|
||||||
async_event(piperead, now);
|
async_event(piperead, now);
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
|
||||||
if (FD_ISSET(daemon->netlinkfd, &rset))
|
|
||||||
netlink_multicast();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
/* if we didn't create a DBus connection, retry now. */
|
/* if we didn't create a DBus connection, retry now. */
|
||||||
if ((daemon->options & OPT_DBUS) && !daemon->dbus)
|
if (option_bool(OPT_DBUS) && !daemon->dbus)
|
||||||
{
|
{
|
||||||
char *err;
|
char *err;
|
||||||
if ((err = dbus_init()))
|
if ((err = dbus_init()))
|
||||||
@@ -676,8 +681,13 @@ int main (int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp && FD_ISSET(daemon->dhcpfd, &rset))
|
if (daemon->dhcp)
|
||||||
dhcp_packet(now);
|
{
|
||||||
|
if (FD_ISSET(daemon->dhcpfd, &rset))
|
||||||
|
dhcp_packet(now, 0);
|
||||||
|
if (daemon->pxefd != -1 && FD_ISSET(daemon->pxefd, &rset))
|
||||||
|
dhcp_packet(now, 1);
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef HAVE_SCRIPT
|
# ifdef HAVE_SCRIPT
|
||||||
if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset))
|
if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset))
|
||||||
@@ -790,7 +800,7 @@ static void async_event(int pipe, time_t now)
|
|||||||
{
|
{
|
||||||
case EVENT_RELOAD:
|
case EVENT_RELOAD:
|
||||||
clear_cache_and_reload(now);
|
clear_cache_and_reload(now);
|
||||||
if (daemon->port != 0 && daemon->resolv_files && (daemon->options & OPT_NO_POLL))
|
if (daemon->port != 0 && daemon->resolv_files && option_bool(OPT_NO_POLL))
|
||||||
{
|
{
|
||||||
reload_servers(daemon->resolv_files->name);
|
reload_servers(daemon->resolv_files->name);
|
||||||
check_servers();
|
check_servers();
|
||||||
@@ -888,7 +898,7 @@ static void async_event(int pipe, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void poll_resolv()
|
void poll_resolv(int force, int do_reload, time_t now)
|
||||||
{
|
{
|
||||||
struct resolvc *res, *latest;
|
struct resolvc *res, *latest;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
@@ -896,19 +906,37 @@ static void poll_resolv()
|
|||||||
/* There may be more than one possible file.
|
/* There may be more than one possible file.
|
||||||
Go through and find the one which changed _last_.
|
Go through and find the one which changed _last_.
|
||||||
Warn of any which can't be read. */
|
Warn of any which can't be read. */
|
||||||
|
|
||||||
|
if (daemon->port == 0 || option_bool(OPT_NO_POLL))
|
||||||
|
return;
|
||||||
|
|
||||||
for (latest = NULL, res = daemon->resolv_files; res; res = res->next)
|
for (latest = NULL, res = daemon->resolv_files; res; res = res->next)
|
||||||
if (stat(res->name, &statbuf) == -1)
|
if (stat(res->name, &statbuf) == -1)
|
||||||
{
|
{
|
||||||
|
if (force)
|
||||||
|
{
|
||||||
|
res->mtime = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!res->logged)
|
if (!res->logged)
|
||||||
my_syslog(LOG_WARNING, _("failed to access %s: %s"), res->name, strerror(errno));
|
my_syslog(LOG_WARNING, _("failed to access %s: %s"), res->name, strerror(errno));
|
||||||
res->logged = 1;
|
res->logged = 1;
|
||||||
|
|
||||||
|
if (res->mtime != 0)
|
||||||
|
{
|
||||||
|
/* existing file evaporated, force selection of the latest
|
||||||
|
file even if its mtime hasn't changed since we last looked */
|
||||||
|
poll_resolv(1, do_reload, now);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res->logged = 0;
|
res->logged = 0;
|
||||||
if (statbuf.st_mtime != res->mtime)
|
if (force || (statbuf.st_mtime != res->mtime))
|
||||||
{
|
{
|
||||||
res->mtime = statbuf.st_mtime;
|
res->mtime = statbuf.st_mtime;
|
||||||
if (difftime(statbuf.st_mtime, last_change) > 0.0)
|
if (difftime(statbuf.st_mtime, last_change) > 0.0)
|
||||||
{
|
{
|
||||||
last_change = statbuf.st_mtime;
|
last_change = statbuf.st_mtime;
|
||||||
@@ -925,8 +953,8 @@ static void poll_resolv()
|
|||||||
my_syslog(LOG_INFO, _("reading %s"), latest->name);
|
my_syslog(LOG_INFO, _("reading %s"), latest->name);
|
||||||
warned = 0;
|
warned = 0;
|
||||||
check_servers();
|
check_servers();
|
||||||
if (daemon->options & OPT_RELOAD)
|
if (option_bool(OPT_RELOAD) && do_reload)
|
||||||
cache_reload();
|
clear_cache_and_reload(now);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -948,7 +976,7 @@ void clear_cache_and_reload(time_t now)
|
|||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp)
|
if (daemon->dhcp)
|
||||||
{
|
{
|
||||||
if (daemon->options & OPT_ETHERS)
|
if (option_bool(OPT_ETHERS))
|
||||||
dhcp_read_ethers();
|
dhcp_read_ethers();
|
||||||
reread_dhcp();
|
reread_dhcp();
|
||||||
dhcp_update_configs(daemon->dhcp_conf);
|
dhcp_update_configs(daemon->dhcp_conf);
|
||||||
@@ -1065,7 +1093,7 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
if (confd == -1)
|
if (confd == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (daemon->options & OPT_NOWILD)
|
if (option_bool(OPT_NOWILD))
|
||||||
iface = listener->iface;
|
iface = listener->iface;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1091,7 +1119,7 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
close(confd);
|
close(confd);
|
||||||
}
|
}
|
||||||
#ifndef NO_FORK
|
#ifndef NO_FORK
|
||||||
else if (!(daemon->options & OPT_DEBUG) && (p = fork()) != 0)
|
else if (!option_bool(OPT_DEBUG) && (p = fork()) != 0)
|
||||||
{
|
{
|
||||||
if (p != -1)
|
if (p != -1)
|
||||||
{
|
{
|
||||||
@@ -1115,11 +1143,13 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
|
|
||||||
dst_addr_4.s_addr = 0;
|
dst_addr_4.s_addr = 0;
|
||||||
|
|
||||||
/* Arrange for SIGALARM after CHILD_LIFETIME seconds to
|
#ifndef NO_FORK
|
||||||
terminate the process. */
|
/* Arrange for SIGALARM after CHILD_LIFETIME seconds to
|
||||||
if (!(daemon->options & OPT_DEBUG))
|
terminate the process. */
|
||||||
|
if (!option_bool(OPT_DEBUG))
|
||||||
alarm(CHILD_LIFETIME);
|
alarm(CHILD_LIFETIME);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* start with no upstream connections. */
|
/* start with no upstream connections. */
|
||||||
for (s = daemon->servers; s; s = s->next)
|
for (s = daemon->servers; s; s = s->next)
|
||||||
s->tcpfd = -1;
|
s->tcpfd = -1;
|
||||||
@@ -1148,7 +1178,7 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
close(s->tcpfd);
|
close(s->tcpfd);
|
||||||
}
|
}
|
||||||
#ifndef NO_FORK
|
#ifndef NO_FORK
|
||||||
if (!(daemon->options & OPT_DEBUG))
|
if (!option_bool(OPT_DEBUG))
|
||||||
{
|
{
|
||||||
flush_log();
|
flush_log();
|
||||||
_exit(0);
|
_exit(0);
|
||||||
|
|||||||
+146
-76
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define COPYRIGHT "Copyright (C) 2000-2009 Simon Kelley"
|
#define COPYRIGHT "Copyright (c) 2000-2011 Simon Kelley"
|
||||||
|
|
||||||
#ifndef NO_LARGEFILE
|
#ifndef NO_LARGEFILE
|
||||||
/* Ensure we can use files >2GB (log files may grow this big) */
|
/* Ensure we can use files >2GB (log files may grow this big) */
|
||||||
@@ -22,12 +22,18 @@
|
|||||||
# define _FILE_OFFSET_BITS 64
|
# define _FILE_OFFSET_BITS 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get linux C library versions. */
|
/* Get linux C library versions and define _GNU_SOURCE for kFreeBSD. */
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || defined(__GLIBC__)
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
# include <features.h>
|
# include <features.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Need these defined early */
|
||||||
|
#if defined(__sun) || defined(__sun__)
|
||||||
|
# define _XPG4_2
|
||||||
|
# define __EXTENSIONS__
|
||||||
|
#endif
|
||||||
|
|
||||||
/* get these before config.h for IPv6 stuff... */
|
/* get these before config.h for IPv6 stuff... */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -58,7 +64,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#if defined(HAVE_SOLARIS_NETWORK)
|
#if defined(HAVE_SOLARIS_NETWORK)
|
||||||
#include <sys/sockio.h>
|
# include <sys/sockio.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
@@ -66,6 +72,10 @@
|
|||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#if defined(HAVE_SOLARIS_NETWORK) && !defined(ifr_mtu)
|
||||||
|
/* Some solaris net/if./h omit this. */
|
||||||
|
# define ifr_mtu ifr_ifru.ifru_metric
|
||||||
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -153,38 +163,44 @@ struct event_desc {
|
|||||||
*/
|
*/
|
||||||
#define DNSMASQ_PACKETSZ PACKETSZ+MAXDNAME+RRFIXEDSZ
|
#define DNSMASQ_PACKETSZ PACKETSZ+MAXDNAME+RRFIXEDSZ
|
||||||
|
|
||||||
#define OPT_BOGUSPRIV (1u<<0)
|
/* Trust the compiler dead-code elimator.... */
|
||||||
#define OPT_FILTER (1u<<1)
|
#define option_bool(x) (((x) < 32) ? daemon->options & (1u << (x)) : daemon->options2 & (1u << ((x) - 32)))
|
||||||
#define OPT_LOG (1u<<2)
|
|
||||||
#define OPT_SELFMX (1u<<3)
|
#define OPT_BOGUSPRIV 0
|
||||||
#define OPT_NO_HOSTS (1u<<4)
|
#define OPT_FILTER 1
|
||||||
#define OPT_NO_POLL (1u<<5)
|
#define OPT_LOG 2
|
||||||
#define OPT_DEBUG (1u<<6)
|
#define OPT_SELFMX 3
|
||||||
#define OPT_ORDER (1u<<7)
|
#define OPT_NO_HOSTS 4
|
||||||
#define OPT_NO_RESOLV (1u<<8)
|
#define OPT_NO_POLL 5
|
||||||
#define OPT_EXPAND (1u<<9)
|
#define OPT_DEBUG 6
|
||||||
#define OPT_LOCALMX (1u<<10)
|
#define OPT_ORDER 7
|
||||||
#define OPT_NO_NEG (1u<<11)
|
#define OPT_NO_RESOLV 8
|
||||||
#define OPT_NODOTS_LOCAL (1u<<12)
|
#define OPT_EXPAND 9
|
||||||
#define OPT_NOWILD (1u<<13)
|
#define OPT_LOCALMX 10
|
||||||
#define OPT_ETHERS (1u<<14)
|
#define OPT_NO_NEG 11
|
||||||
#define OPT_RESOLV_DOMAIN (1u<<15)
|
#define OPT_NODOTS_LOCAL 12
|
||||||
#define OPT_NO_FORK (1u<<16)
|
#define OPT_NOWILD 13
|
||||||
#define OPT_AUTHORITATIVE (1u<<17)
|
#define OPT_ETHERS 14
|
||||||
#define OPT_LOCALISE (1u<<18)
|
#define OPT_RESOLV_DOMAIN 15
|
||||||
#define OPT_DBUS (1u<<19)
|
#define OPT_NO_FORK 16
|
||||||
#define OPT_DHCP_FQDN (1u<<20)
|
#define OPT_AUTHORITATIVE 17
|
||||||
#define OPT_NO_PING (1u<<21)
|
#define OPT_LOCALISE 18
|
||||||
#define OPT_LEASE_RO (1u<<22)
|
#define OPT_DBUS 19
|
||||||
#define OPT_ALL_SERVERS (1u<<23)
|
#define OPT_DHCP_FQDN 20
|
||||||
#define OPT_RELOAD (1u<<24)
|
#define OPT_NO_PING 21
|
||||||
#define OPT_TFTP (1u<<25)
|
#define OPT_LEASE_RO 22
|
||||||
#define OPT_TFTP_SECURE (1u<<26)
|
#define OPT_ALL_SERVERS 23
|
||||||
#define OPT_TFTP_NOBLOCK (1u<<27)
|
#define OPT_RELOAD 24
|
||||||
#define OPT_LOG_OPTS (1u<<28)
|
#define OPT_LOCAL_REBIND 25
|
||||||
#define OPT_TFTP_APREF (1u<<29)
|
#define OPT_TFTP_SECURE 26
|
||||||
#define OPT_NO_OVERRIDE (1u<<30)
|
#define OPT_TFTP_NOBLOCK 27
|
||||||
#define OPT_NO_REBIND (1u<<31)
|
#define OPT_LOG_OPTS 28
|
||||||
|
#define OPT_TFTP_APREF 29
|
||||||
|
#define OPT_NO_OVERRIDE 30
|
||||||
|
#define OPT_NO_REBIND 31
|
||||||
|
#define OPT_ADD_MAC 32
|
||||||
|
#define OPT_DNSSEC 33
|
||||||
|
#define OPT_LAST 34
|
||||||
|
|
||||||
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
||||||
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
||||||
@@ -225,7 +241,8 @@ struct naptr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct txt_record {
|
struct txt_record {
|
||||||
char *name, *txt;
|
char *name;
|
||||||
|
unsigned char *txt;
|
||||||
unsigned short class, len;
|
unsigned short class, len;
|
||||||
struct txt_record *next;
|
struct txt_record *next;
|
||||||
};
|
};
|
||||||
@@ -270,22 +287,28 @@ struct crec {
|
|||||||
} name;
|
} name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define F_IMMORTAL 1
|
#define F_IMMORTAL (1u<<0)
|
||||||
#define F_CONFIG 2
|
#define F_NAMEP (1u<<1)
|
||||||
#define F_REVERSE 4
|
#define F_REVERSE (1u<<2)
|
||||||
#define F_FORWARD 8
|
#define F_FORWARD (1u<<3)
|
||||||
#define F_DHCP 16
|
#define F_DHCP (1u<<4)
|
||||||
#define F_NEG 32
|
#define F_NEG (1u<<5)
|
||||||
#define F_HOSTS 64
|
#define F_HOSTS (1u<<6)
|
||||||
#define F_IPV4 128
|
#define F_IPV4 (1u<<7)
|
||||||
#define F_IPV6 256
|
#define F_IPV6 (1u<<8)
|
||||||
#define F_BIGNAME 512
|
#define F_BIGNAME (1u<<9)
|
||||||
#define F_UPSTREAM 1024
|
#define F_NXDOMAIN (1u<<10)
|
||||||
#define F_SERVER 2048
|
#define F_CNAME (1u<<11)
|
||||||
#define F_NXDOMAIN 4096
|
#define F_NOERR (1u<<12)
|
||||||
#define F_QUERY 8192
|
#define F_CONFIG (1u<<13)
|
||||||
#define F_CNAME 16384
|
/* below here are only valid as args to log_query: cache
|
||||||
#define F_NOERR 32768
|
entries are limited to 16 bits */
|
||||||
|
#define F_UPSTREAM (1u<<16)
|
||||||
|
#define F_RRNAME (1u<<17)
|
||||||
|
#define F_SERVER (1u<<18)
|
||||||
|
#define F_QUERY (1u<<19)
|
||||||
|
#define F_NSRR (1u<<20)
|
||||||
|
|
||||||
|
|
||||||
/* struct sockaddr is not large enough to hold any address,
|
/* struct sockaddr is not large enough to hold any address,
|
||||||
and specifically not big enough to hold an IPv6 address.
|
and specifically not big enough to hold an IPv6 address.
|
||||||
@@ -309,6 +332,8 @@ union mysockaddr {
|
|||||||
#define SERV_MARK 256 /* for mark-and-delete */
|
#define SERV_MARK 256 /* for mark-and-delete */
|
||||||
#define SERV_TYPE (SERV_HAS_DOMAIN | SERV_FOR_NODOTS)
|
#define SERV_TYPE (SERV_HAS_DOMAIN | SERV_FOR_NODOTS)
|
||||||
#define SERV_COUNTED 512 /* workspace for log code */
|
#define SERV_COUNTED 512 /* workspace for log code */
|
||||||
|
#define SERV_USE_RESOLV 1024 /* forward this domain in the normal way */
|
||||||
|
#define SERV_NO_REBIND 2048 /* inhibit dns-rebind protection */
|
||||||
|
|
||||||
struct serverfd {
|
struct serverfd {
|
||||||
int fd;
|
int fd;
|
||||||
@@ -335,7 +360,8 @@ struct server {
|
|||||||
struct irec {
|
struct irec {
|
||||||
union mysockaddr addr;
|
union mysockaddr addr;
|
||||||
struct in_addr netmask; /* only valid for IPv4 */
|
struct in_addr netmask; /* only valid for IPv4 */
|
||||||
int dhcp_ok, mtu;
|
int tftp_ok, mtu;
|
||||||
|
char *name;
|
||||||
struct irec *next;
|
struct irec *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -361,7 +387,7 @@ struct resolvc {
|
|||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* adn-hosts parms from command-line */
|
/* adn-hosts parms from command-line (also dhcp-hostsfile and dhcp-optsfile */
|
||||||
#define AH_DIR 1
|
#define AH_DIR 1
|
||||||
#define AH_INACTIVE 2
|
#define AH_INACTIVE 2
|
||||||
struct hostsfile {
|
struct hostsfile {
|
||||||
@@ -371,6 +397,9 @@ struct hostsfile {
|
|||||||
int index; /* matches to cache entries for logging */
|
int index; /* matches to cache entries for logging */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FREC_NOREBIND 1
|
||||||
|
#define FREC_CHECKING_DISABLED 2
|
||||||
|
|
||||||
struct frec {
|
struct frec {
|
||||||
union mysockaddr source;
|
union mysockaddr source;
|
||||||
struct all_addr dest;
|
struct all_addr dest;
|
||||||
@@ -381,7 +410,7 @@ struct frec {
|
|||||||
#endif
|
#endif
|
||||||
unsigned int iface;
|
unsigned int iface;
|
||||||
unsigned short orig_id, new_id;
|
unsigned short orig_id, new_id;
|
||||||
int fd, forwardall;
|
int fd, forwardall, flags;
|
||||||
unsigned int crc;
|
unsigned int crc;
|
||||||
time_t time;
|
time_t time;
|
||||||
struct frec *next;
|
struct frec *next;
|
||||||
@@ -411,8 +440,8 @@ struct dhcp_lease {
|
|||||||
int hwaddr_len, hwaddr_type;
|
int hwaddr_len, hwaddr_type;
|
||||||
unsigned char hwaddr[DHCP_CHADDR_MAX];
|
unsigned char hwaddr[DHCP_CHADDR_MAX];
|
||||||
struct in_addr addr, override, giaddr;
|
struct in_addr addr, override, giaddr;
|
||||||
unsigned char *vendorclass, *userclass, *supplied_hostname;
|
unsigned char *extradata;
|
||||||
unsigned int vendorclass_len, userclass_len, supplied_hostname_len;
|
unsigned int extradata_len, extradata_size;
|
||||||
int last_interface;
|
int last_interface;
|
||||||
struct dhcp_lease *next;
|
struct dhcp_lease *next;
|
||||||
};
|
};
|
||||||
@@ -427,6 +456,12 @@ struct dhcp_netid_list {
|
|||||||
struct dhcp_netid_list *next;
|
struct dhcp_netid_list *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct tag_if {
|
||||||
|
struct dhcp_netid_list *set;
|
||||||
|
struct dhcp_netid *tag;
|
||||||
|
struct tag_if *next;
|
||||||
|
};
|
||||||
|
|
||||||
struct hwaddr_config {
|
struct hwaddr_config {
|
||||||
int hwaddr_len, hwaddr_type;
|
int hwaddr_len, hwaddr_type;
|
||||||
unsigned char hwaddr[DHCP_CHADDR_MAX];
|
unsigned char hwaddr[DHCP_CHADDR_MAX];
|
||||||
@@ -439,7 +474,7 @@ struct dhcp_config {
|
|||||||
int clid_len; /* length of client identifier */
|
int clid_len; /* length of client identifier */
|
||||||
unsigned char *clid; /* clientid */
|
unsigned char *clid; /* clientid */
|
||||||
char *hostname, *domain;
|
char *hostname, *domain;
|
||||||
struct dhcp_netid netid;
|
struct dhcp_netid_list *netid;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
time_t decline_time;
|
time_t decline_time;
|
||||||
unsigned int lease_time;
|
unsigned int lease_time;
|
||||||
@@ -452,7 +487,6 @@ struct dhcp_config {
|
|||||||
#define CONFIG_TIME 8
|
#define CONFIG_TIME 8
|
||||||
#define CONFIG_NAME 16
|
#define CONFIG_NAME 16
|
||||||
#define CONFIG_ADDR 32
|
#define CONFIG_ADDR 32
|
||||||
#define CONFIG_NETID 64
|
|
||||||
#define CONFIG_NOCLID 128
|
#define CONFIG_NOCLID 128
|
||||||
#define CONFIG_FROM_ETHERS 256 /* entry created by /etc/ethers */
|
#define CONFIG_FROM_ETHERS 256 /* entry created by /etc/ethers */
|
||||||
#define CONFIG_ADDR_HOSTS 512 /* address added by from /etc/hosts */
|
#define CONFIG_ADDR_HOSTS 512 /* address added by from /etc/hosts */
|
||||||
@@ -482,6 +516,7 @@ struct dhcp_opt {
|
|||||||
#define DHOPT_VENDOR 256
|
#define DHOPT_VENDOR 256
|
||||||
#define DHOPT_HEX 512
|
#define DHOPT_HEX 512
|
||||||
#define DHOPT_VENDOR_MATCH 1024
|
#define DHOPT_VENDOR_MATCH 1024
|
||||||
|
#define DHOPT_RFC3925 2048
|
||||||
|
|
||||||
struct dhcp_boot {
|
struct dhcp_boot {
|
||||||
char *file, *sname;
|
char *file, *sname;
|
||||||
@@ -537,6 +572,7 @@ struct dhcp_context {
|
|||||||
struct in_addr local, router;
|
struct in_addr local, router;
|
||||||
struct in_addr start, end; /* range of available addresses */
|
struct in_addr start, end; /* range of available addresses */
|
||||||
int flags;
|
int flags;
|
||||||
|
char *interface;
|
||||||
struct dhcp_netid netid, *filter;
|
struct dhcp_netid netid, *filter;
|
||||||
struct dhcp_context *next, *current;
|
struct dhcp_context *next, *current;
|
||||||
};
|
};
|
||||||
@@ -581,18 +617,35 @@ struct tftp_transfer {
|
|||||||
int backoff;
|
int backoff;
|
||||||
unsigned int block, blocksize, expansion;
|
unsigned int block, blocksize, expansion;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
struct sockaddr_in peer;
|
union mysockaddr peer;
|
||||||
char opt_blocksize, opt_transize, netascii, carrylf;
|
char opt_blocksize, opt_transize, netascii, carrylf;
|
||||||
struct tftp_file *file;
|
struct tftp_file *file;
|
||||||
struct tftp_transfer *next;
|
struct tftp_transfer *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct addr_list {
|
||||||
|
struct in_addr addr;
|
||||||
|
struct addr_list *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct interface_list {
|
||||||
|
char *interface;
|
||||||
|
struct interface_list *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tftp_prefix {
|
||||||
|
char *interface;
|
||||||
|
char *prefix;
|
||||||
|
struct tftp_prefix *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
extern struct daemon {
|
extern struct daemon {
|
||||||
/* datastuctures representing the command-line and
|
/* datastuctures representing the command-line and
|
||||||
config file arguments. All set (including defaults)
|
config file arguments. All set (including defaults)
|
||||||
in option.c */
|
in option.c */
|
||||||
|
|
||||||
unsigned int options;
|
unsigned int options, options2;
|
||||||
struct resolvc default_resolv, *resolv_files;
|
struct resolvc default_resolv, *resolv_files;
|
||||||
time_t last_resolv;
|
time_t last_resolv;
|
||||||
struct mx_srv_record *mxnames;
|
struct mx_srv_record *mxnames;
|
||||||
@@ -617,7 +670,7 @@ extern struct daemon {
|
|||||||
int max_logs; /* queue limit */
|
int max_logs; /* queue limit */
|
||||||
int cachesize, ftabsize;
|
int cachesize, ftabsize;
|
||||||
int port, query_port, min_port;
|
int port, query_port, min_port;
|
||||||
unsigned long local_ttl, neg_ttl;
|
unsigned long local_ttl, neg_ttl, max_ttl;
|
||||||
struct hostsfile *addn_hosts;
|
struct hostsfile *addn_hosts;
|
||||||
struct dhcp_context *dhcp;
|
struct dhcp_context *dhcp;
|
||||||
struct dhcp_config *dhcp_conf;
|
struct dhcp_config *dhcp_conf;
|
||||||
@@ -626,9 +679,13 @@ extern struct daemon {
|
|||||||
struct dhcp_mac *dhcp_macs;
|
struct dhcp_mac *dhcp_macs;
|
||||||
struct dhcp_boot *boot_config;
|
struct dhcp_boot *boot_config;
|
||||||
struct pxe_service *pxe_services;
|
struct pxe_service *pxe_services;
|
||||||
|
struct tag_if *tag_if;
|
||||||
|
struct addr_list *override_relays;
|
||||||
|
int override;
|
||||||
int enable_pxe;
|
int enable_pxe;
|
||||||
struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *force_broadcast, *bootp_dynamic;
|
struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *dhcp_gen_names;
|
||||||
char *dhcp_hosts_file, *dhcp_opts_file;
|
struct dhcp_netid_list *force_broadcast, *bootp_dynamic;
|
||||||
|
struct hostsfile *dhcp_hosts_file, *dhcp_opts_file;
|
||||||
int dhcp_max, tftp_max;
|
int dhcp_max, tftp_max;
|
||||||
int dhcp_server_port, dhcp_client_port;
|
int dhcp_server_port, dhcp_client_port;
|
||||||
int start_tftp_port, end_tftp_port;
|
int start_tftp_port, end_tftp_port;
|
||||||
@@ -636,6 +693,9 @@ extern struct daemon {
|
|||||||
struct doctor *doctors;
|
struct doctor *doctors;
|
||||||
unsigned short edns_pktsz;
|
unsigned short edns_pktsz;
|
||||||
char *tftp_prefix;
|
char *tftp_prefix;
|
||||||
|
struct tftp_prefix *if_prefix; /* per-interface TFTP prefixes */
|
||||||
|
struct interface_list *tftp_interfaces; /* interfaces for limited TFTP service */
|
||||||
|
int tftp_unlimited;
|
||||||
|
|
||||||
/* globally used stuff for DNS */
|
/* globally used stuff for DNS */
|
||||||
char *packet; /* packet buffer */
|
char *packet; /* packet buffer */
|
||||||
@@ -654,16 +714,17 @@ extern struct daemon {
|
|||||||
struct randfd *rfd_save; /* " " */
|
struct randfd *rfd_save; /* " " */
|
||||||
pid_t tcp_pids[MAX_PROCS];
|
pid_t tcp_pids[MAX_PROCS];
|
||||||
struct randfd randomsocks[RANDOM_SOCKS];
|
struct randfd randomsocks[RANDOM_SOCKS];
|
||||||
|
int v6pktinfo;
|
||||||
|
|
||||||
/* DHCP state */
|
/* DHCP state */
|
||||||
int dhcpfd, helperfd;
|
int dhcpfd, helperfd, pxefd;
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
int netlinkfd;
|
int netlinkfd;
|
||||||
#elif defined(HAVE_BSD_NETWORK)
|
#elif defined(HAVE_BSD_NETWORK)
|
||||||
int dhcp_raw_fd, dhcp_icmp_fd;
|
int dhcp_raw_fd, dhcp_icmp_fd;
|
||||||
#endif
|
#endif
|
||||||
struct iovec dhcp_packet;
|
struct iovec dhcp_packet;
|
||||||
char *dhcp_buff, *dhcp_buff2;
|
char *dhcp_buff, *dhcp_buff2, *dhcp_buff3;
|
||||||
struct ping_result *ping_results;
|
struct ping_result *ping_results;
|
||||||
FILE *lease_stream;
|
FILE *lease_stream;
|
||||||
struct dhcp_bridge *bridges;
|
struct dhcp_bridge *bridges;
|
||||||
@@ -682,7 +743,7 @@ extern struct daemon {
|
|||||||
|
|
||||||
/* cache.c */
|
/* cache.c */
|
||||||
void cache_init(void);
|
void cache_init(void);
|
||||||
void log_query(unsigned short flags, char *name, struct all_addr *addr, char *arg);
|
void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg);
|
||||||
char *record_source(int index);
|
char *record_source(int index);
|
||||||
void querystr(char *str, unsigned short type);
|
void querystr(char *str, unsigned short type);
|
||||||
struct crec *cache_find_by_addr(struct crec *crecp,
|
struct crec *cache_find_by_addr(struct crec *crecp,
|
||||||
@@ -702,12 +763,13 @@ char *cache_get_name(struct crec *crecp);
|
|||||||
char *get_domain(struct in_addr addr);
|
char *get_domain(struct in_addr addr);
|
||||||
|
|
||||||
/* rfc1035.c */
|
/* rfc1035.c */
|
||||||
unsigned short extract_request(HEADER *header, size_t qlen,
|
unsigned int extract_request(HEADER *header, size_t qlen,
|
||||||
char *name, unsigned short *typep);
|
char *name, unsigned short *typep);
|
||||||
size_t setup_reply(HEADER *header, size_t qlen,
|
size_t setup_reply(HEADER *header, size_t qlen,
|
||||||
struct all_addr *addrp, unsigned short flags,
|
struct all_addr *addrp, unsigned int flags,
|
||||||
unsigned long local_ttl);
|
unsigned long local_ttl);
|
||||||
int extract_addresses(HEADER *header, size_t qlen, char *namebuff, time_t now);
|
int extract_addresses(HEADER *header, size_t qlen, char *namebuff,
|
||||||
|
time_t now, int is_sign, int checkrebind, int checking_disabled);
|
||||||
size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
||||||
struct in_addr local_addr, struct in_addr local_netmask, time_t now);
|
struct in_addr local_addr, struct in_addr local_netmask, time_t now);
|
||||||
int check_for_bogus_wildcard(HEADER *header, size_t qlen, char *name,
|
int check_for_bogus_wildcard(HEADER *header, size_t qlen, char *name,
|
||||||
@@ -718,6 +780,7 @@ int check_for_local_domain(char *name, time_t now);
|
|||||||
unsigned int questions_crc(HEADER *header, size_t plen, char *buff);
|
unsigned int questions_crc(HEADER *header, size_t plen, char *buff);
|
||||||
size_t resize_packet(HEADER *header, size_t plen,
|
size_t resize_packet(HEADER *header, size_t plen,
|
||||||
unsigned char *pheader, size_t hlen);
|
unsigned char *pheader, size_t hlen);
|
||||||
|
size_t add_mac(HEADER *header, size_t plen, char *limit, union mysockaddr *l3);
|
||||||
|
|
||||||
/* util.c */
|
/* util.c */
|
||||||
void rand_init(void);
|
void rand_init(void);
|
||||||
@@ -758,6 +821,8 @@ void flush_log(void);
|
|||||||
void read_opts (int argc, char **argv, char *compile_opts);
|
void read_opts (int argc, char **argv, char *compile_opts);
|
||||||
char *option_string(unsigned char opt, int *is_ip, int *is_name);
|
char *option_string(unsigned char opt, int *is_ip, int *is_name);
|
||||||
void reread_dhcp(void);
|
void reread_dhcp(void);
|
||||||
|
void set_option_bool(unsigned int opt);
|
||||||
|
struct hostsfile *expand_filelist(struct hostsfile *list);
|
||||||
|
|
||||||
/* forward.c */
|
/* forward.c */
|
||||||
void reply_query(int fd, int family, time_t now);
|
void reply_query(int fd, int family, time_t now);
|
||||||
@@ -784,16 +849,18 @@ struct in_addr get_ifaddr(char *intr);
|
|||||||
/* dhcp.c */
|
/* dhcp.c */
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
void dhcp_init(void);
|
void dhcp_init(void);
|
||||||
void dhcp_packet(time_t now);
|
void dhcp_packet(time_t now, int pxe_fd);
|
||||||
struct dhcp_context *address_available(struct dhcp_context *context,
|
struct dhcp_context *address_available(struct dhcp_context *context,
|
||||||
struct in_addr addr,
|
struct in_addr addr,
|
||||||
struct dhcp_netid *netids);
|
struct dhcp_netid *netids);
|
||||||
struct dhcp_context *narrow_context(struct dhcp_context *context,
|
struct dhcp_context *narrow_context(struct dhcp_context *context,
|
||||||
struct in_addr taddr,
|
struct in_addr taddr,
|
||||||
struct dhcp_netid *netids);
|
struct dhcp_netid *netids);
|
||||||
int match_netid(struct dhcp_netid *check, struct dhcp_netid *pool, int negonly);int address_allocate(struct dhcp_context *context,
|
int match_netid(struct dhcp_netid *check, struct dhcp_netid *pool, int negonly);
|
||||||
|
int address_allocate(struct dhcp_context *context,
|
||||||
struct in_addr *addrp, unsigned char *hwaddr, int hw_len,
|
struct in_addr *addrp, unsigned char *hwaddr, int hw_len,
|
||||||
struct dhcp_netid *netids, time_t now);
|
struct dhcp_netid *netids, time_t now);
|
||||||
|
struct dhcp_netid *run_tag_if(struct dhcp_netid *input);
|
||||||
int config_has_mac(struct dhcp_config *config, unsigned char *hwaddr, int len, int type);
|
int config_has_mac(struct dhcp_config *config, unsigned char *hwaddr, int len, int type);
|
||||||
struct dhcp_config *find_config(struct dhcp_config *configs,
|
struct dhcp_config *find_config(struct dhcp_config *configs,
|
||||||
struct dhcp_context *context,
|
struct dhcp_context *context,
|
||||||
@@ -832,7 +899,7 @@ void rerun_scripts(void);
|
|||||||
/* rfc2131.c */
|
/* rfc2131.c */
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
||||||
size_t sz, time_t now, int unicast_dest, int *is_inform);
|
size_t sz, time_t now, int unicast_dest, int *is_inform, int pxe_fd);
|
||||||
unsigned char *extended_hwaddr(int hwtype, int hwlen, unsigned char *hwaddr,
|
unsigned char *extended_hwaddr(int hwtype, int hwlen, unsigned char *hwaddr,
|
||||||
int clid_len, unsigned char *clid, int *len_out);
|
int clid_len, unsigned char *clid, int *len_out);
|
||||||
#endif
|
#endif
|
||||||
@@ -844,6 +911,7 @@ int icmp_ping(struct in_addr addr);
|
|||||||
#endif
|
#endif
|
||||||
void send_event(int fd, int event, int data);
|
void send_event(int fd, int event, int data);
|
||||||
void clear_cache_and_reload(time_t now);
|
void clear_cache_and_reload(time_t now);
|
||||||
|
void poll_resolv(int force, int do_reload, time_t now);
|
||||||
|
|
||||||
/* netlink.c */
|
/* netlink.c */
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
@@ -859,14 +927,16 @@ void send_via_bpf(struct dhcp_packet *mess, size_t len,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpf.c or netlink.c */
|
/* bpf.c or netlink.c */
|
||||||
int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)());
|
int iface_enumerate(int family, void *parm, int (callback)());
|
||||||
|
|
||||||
/* dbus.c */
|
/* dbus.c */
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
char *dbus_init(void);
|
char *dbus_init(void);
|
||||||
void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset);
|
void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset);
|
||||||
void set_dbus_listeners(int *maxfdp, fd_set *rset, fd_set *wset, fd_set *eset);
|
void set_dbus_listeners(int *maxfdp, fd_set *rset, fd_set *wset, fd_set *eset);
|
||||||
|
# ifdef HAVE_DHCP
|
||||||
void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname);
|
void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* helper.c */
|
/* helper.c */
|
||||||
|
|||||||
+196
-107
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,7 +20,7 @@ static struct frec *lookup_frec(unsigned short id, unsigned int crc);
|
|||||||
static struct frec *lookup_frec_by_sender(unsigned short id,
|
static struct frec *lookup_frec_by_sender(unsigned short id,
|
||||||
union mysockaddr *addr,
|
union mysockaddr *addr,
|
||||||
unsigned int crc);
|
unsigned int crc);
|
||||||
static unsigned short get_id(int force, unsigned short force_id, unsigned int crc);
|
static unsigned short get_id(unsigned int crc);
|
||||||
static void free_frec(struct frec *f);
|
static void free_frec(struct frec *f);
|
||||||
static struct randfd *allocate_rfd(int family);
|
static struct randfd *allocate_rfd(int family);
|
||||||
|
|
||||||
@@ -65,15 +65,15 @@ static void send_from(int fd, int nowild, char *packet, size_t len,
|
|||||||
if (to->sa.sa_family == AF_INET)
|
if (to->sa.sa_family == AF_INET)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
struct in_pktinfo *pkt = (struct in_pktinfo *)CMSG_DATA(cmptr);
|
struct in_pktinfo p;
|
||||||
pkt->ipi_ifindex = 0;
|
p.ipi_ifindex = 0;
|
||||||
pkt->ipi_spec_dst = source->addr.addr4;
|
p.ipi_spec_dst = source->addr.addr4;
|
||||||
|
memcpy(CMSG_DATA(cmptr), &p, sizeof(p));
|
||||||
msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
|
msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
|
||||||
cmptr->cmsg_level = SOL_IP;
|
cmptr->cmsg_level = SOL_IP;
|
||||||
cmptr->cmsg_type = IP_PKTINFO;
|
cmptr->cmsg_type = IP_PKTINFO;
|
||||||
#elif defined(IP_SENDSRCADDR)
|
#elif defined(IP_SENDSRCADDR)
|
||||||
struct in_addr *a = (struct in_addr *)CMSG_DATA(cmptr);
|
memcpy(CMSG_DATA(cmptr), &(source->addr.addr4), sizeof(source->addr.addr4));
|
||||||
*a = source->addr.addr4;
|
|
||||||
msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
|
msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
|
||||||
cmptr->cmsg_level = IPPROTO_IP;
|
cmptr->cmsg_level = IPPROTO_IP;
|
||||||
cmptr->cmsg_type = IP_SENDSRCADDR;
|
cmptr->cmsg_type = IP_SENDSRCADDR;
|
||||||
@@ -82,11 +82,12 @@ static void send_from(int fd, int nowild, char *packet, size_t len,
|
|||||||
else
|
else
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
{
|
{
|
||||||
struct in6_pktinfo *pkt = (struct in6_pktinfo *)CMSG_DATA(cmptr);
|
struct in6_pktinfo p;
|
||||||
pkt->ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
|
p.ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
|
||||||
pkt->ipi6_addr = source->addr.addr6;
|
p.ipi6_addr = source->addr.addr6;
|
||||||
|
memcpy(CMSG_DATA(cmptr), &p, sizeof(p));
|
||||||
msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
|
msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
|
||||||
cmptr->cmsg_type = IPV6_PKTINFO;
|
cmptr->cmsg_type = daemon->v6pktinfo;
|
||||||
cmptr->cmsg_level = IPV6_LEVEL;
|
cmptr->cmsg_level = IPV6_LEVEL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -110,8 +111,8 @@ static void send_from(int fd, int nowild, char *packet, size_t len,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned short search_servers(time_t now, struct all_addr **addrpp,
|
static unsigned int search_servers(time_t now, struct all_addr **addrpp,
|
||||||
unsigned short qtype, char *qdomain, int *type, char **domain)
|
unsigned int qtype, char *qdomain, int *type, char **domain, int *norebind)
|
||||||
|
|
||||||
{
|
{
|
||||||
/* If the query ends in the domain in one of our servers, set
|
/* If the query ends in the domain in one of our servers, set
|
||||||
@@ -121,13 +122,13 @@ static unsigned short search_servers(time_t now, struct all_addr **addrpp,
|
|||||||
unsigned int namelen = strlen(qdomain);
|
unsigned int namelen = strlen(qdomain);
|
||||||
unsigned int matchlen = 0;
|
unsigned int matchlen = 0;
|
||||||
struct server *serv;
|
struct server *serv;
|
||||||
unsigned short flags = 0;
|
unsigned int flags = 0;
|
||||||
|
|
||||||
for (serv = daemon->servers; serv; serv=serv->next)
|
for (serv = daemon->servers; serv; serv=serv->next)
|
||||||
/* domain matches take priority over NODOTS matches */
|
/* domain matches take priority over NODOTS matches */
|
||||||
if ((serv->flags & SERV_FOR_NODOTS) && *type != SERV_HAS_DOMAIN && !strchr(qdomain, '.') && namelen != 0)
|
if ((serv->flags & SERV_FOR_NODOTS) && *type != SERV_HAS_DOMAIN && !strchr(qdomain, '.') && namelen != 0)
|
||||||
{
|
{
|
||||||
unsigned short sflag = serv->addr.sa.sa_family == AF_INET ? F_IPV4 : F_IPV6;
|
unsigned int sflag = serv->addr.sa.sa_family == AF_INET ? F_IPV4 : F_IPV6;
|
||||||
*type = SERV_FOR_NODOTS;
|
*type = SERV_FOR_NODOTS;
|
||||||
if (serv->flags & SERV_NO_ADDR)
|
if (serv->flags & SERV_NO_ADDR)
|
||||||
flags = F_NXDOMAIN;
|
flags = F_NXDOMAIN;
|
||||||
@@ -153,38 +154,64 @@ static unsigned short search_servers(time_t now, struct all_addr **addrpp,
|
|||||||
char *matchstart = qdomain + namelen - domainlen;
|
char *matchstart = qdomain + namelen - domainlen;
|
||||||
if (namelen >= domainlen &&
|
if (namelen >= domainlen &&
|
||||||
hostname_isequal(matchstart, serv->domain) &&
|
hostname_isequal(matchstart, serv->domain) &&
|
||||||
domainlen >= matchlen &&
|
(domainlen == 0 || namelen == domainlen || *(matchstart-1) == '.' ))
|
||||||
(domainlen == 0 || namelen == domainlen || *(serv->domain) == '.' || *(matchstart-1) == '.' ))
|
|
||||||
{
|
{
|
||||||
unsigned short sflag = serv->addr.sa.sa_family == AF_INET ? F_IPV4 : F_IPV6;
|
if (serv->flags & SERV_NO_REBIND)
|
||||||
*type = SERV_HAS_DOMAIN;
|
*norebind = 1;
|
||||||
*domain = serv->domain;
|
else
|
||||||
matchlen = domainlen;
|
|
||||||
if (serv->flags & SERV_NO_ADDR)
|
|
||||||
flags = F_NXDOMAIN;
|
|
||||||
else if (serv->flags & SERV_LITERAL_ADDRESS)
|
|
||||||
{
|
{
|
||||||
if (sflag & qtype)
|
unsigned int sflag = serv->addr.sa.sa_family == AF_INET ? F_IPV4 : F_IPV6;
|
||||||
|
/* implement priority rules for --address and --server for same domain.
|
||||||
|
--address wins if the address is for the correct AF
|
||||||
|
--server wins otherwise. */
|
||||||
|
if (domainlen != 0 && domainlen == matchlen)
|
||||||
{
|
{
|
||||||
flags = sflag;
|
if ((serv->flags & SERV_LITERAL_ADDRESS))
|
||||||
if (serv->addr.sa.sa_family == AF_INET)
|
{
|
||||||
*addrpp = (struct all_addr *)&serv->addr.in.sin_addr;
|
if (!(sflag & qtype) && flags == 0)
|
||||||
#ifdef HAVE_IPV6
|
continue;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*addrpp = (struct all_addr *)&serv->addr.in6.sin6_addr;
|
{
|
||||||
#endif
|
if (flags & (F_IPV4 | F_IPV6))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!flags || (flags & F_NXDOMAIN))
|
|
||||||
flags = F_NOERR;
|
if (domainlen >= matchlen)
|
||||||
|
{
|
||||||
|
*type = serv->flags & (SERV_HAS_DOMAIN | SERV_USE_RESOLV | SERV_NO_REBIND);
|
||||||
|
*domain = serv->domain;
|
||||||
|
matchlen = domainlen;
|
||||||
|
if (serv->flags & SERV_NO_ADDR)
|
||||||
|
flags = F_NXDOMAIN;
|
||||||
|
else if (serv->flags & SERV_LITERAL_ADDRESS)
|
||||||
|
{
|
||||||
|
if (sflag & qtype)
|
||||||
|
{
|
||||||
|
flags = sflag;
|
||||||
|
if (serv->addr.sa.sa_family == AF_INET)
|
||||||
|
*addrpp = (struct all_addr *)&serv->addr.in.sin_addr;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else
|
||||||
|
*addrpp = (struct all_addr *)&serv->addr.in6.sin6_addr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (!flags || (flags & F_NXDOMAIN))
|
||||||
|
flags = F_NOERR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
flags = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags == 0 && !(qtype & F_BIGNAME) &&
|
if (flags == 0 && !(qtype & F_NSRR) &&
|
||||||
(daemon->options & OPT_NODOTS_LOCAL) && !strchr(qdomain, '.') && namelen != 0)
|
option_bool(OPT_NODOTS_LOCAL) && !strchr(qdomain, '.') && namelen != 0)
|
||||||
/* don't forward simple names, make exception for NS queries and empty name. */
|
/* don't forward simple names, make exception for NS queries and empty name. */
|
||||||
flags = F_NXDOMAIN;
|
flags = F_NXDOMAIN;
|
||||||
|
|
||||||
if (flags == F_NXDOMAIN && check_for_local_domain(qdomain, now))
|
if (flags == F_NXDOMAIN && check_for_local_domain(qdomain, now))
|
||||||
flags = F_NOERR;
|
flags = F_NOERR;
|
||||||
|
|
||||||
@@ -197,7 +224,11 @@ static unsigned short search_servers(time_t now, struct all_addr **addrpp,
|
|||||||
|
|
||||||
log_query(logflags | flags | F_CONFIG | F_FORWARD, qdomain, *addrpp, NULL);
|
log_query(logflags | flags | F_CONFIG | F_FORWARD, qdomain, *addrpp, NULL);
|
||||||
}
|
}
|
||||||
|
else if ((*type) & SERV_USE_RESOLV)
|
||||||
|
{
|
||||||
|
*type = 0; /* use normal servers for this domain */
|
||||||
|
*domain = NULL;
|
||||||
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,13 +237,16 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
HEADER *header, size_t plen, time_t now, struct frec *forward)
|
HEADER *header, size_t plen, time_t now, struct frec *forward)
|
||||||
{
|
{
|
||||||
char *domain = NULL;
|
char *domain = NULL;
|
||||||
int type = 0;
|
int type = 0, norebind = 0;
|
||||||
struct all_addr *addrp = NULL;
|
struct all_addr *addrp = NULL;
|
||||||
unsigned int crc = questions_crc(header, plen, daemon->namebuff);
|
unsigned int crc = questions_crc(header, plen, daemon->namebuff);
|
||||||
unsigned short flags = 0;
|
unsigned int flags = 0;
|
||||||
unsigned short gotname = extract_request(header, plen, daemon->namebuff, NULL);
|
unsigned int gotname = extract_request(header, plen, daemon->namebuff, NULL);
|
||||||
struct server *start = NULL;
|
struct server *start = NULL;
|
||||||
|
|
||||||
|
/* RFC 4035: sect 4.6 para 2 */
|
||||||
|
header->ad = 0;
|
||||||
|
|
||||||
/* may be no servers available. */
|
/* may be no servers available. */
|
||||||
if (!daemon->servers)
|
if (!daemon->servers)
|
||||||
forward = NULL;
|
forward = NULL;
|
||||||
@@ -221,7 +255,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
/* retry on existing query, send to all available servers */
|
/* retry on existing query, send to all available servers */
|
||||||
domain = forward->sentto->domain;
|
domain = forward->sentto->domain;
|
||||||
forward->sentto->failed_queries++;
|
forward->sentto->failed_queries++;
|
||||||
if (!(daemon->options & OPT_ORDER))
|
if (!option_bool(OPT_ORDER))
|
||||||
{
|
{
|
||||||
forward->forwardall = 1;
|
forward->forwardall = 1;
|
||||||
daemon->last_server = NULL;
|
daemon->last_server = NULL;
|
||||||
@@ -234,7 +268,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gotname)
|
if (gotname)
|
||||||
flags = search_servers(now, &addrp, gotname, daemon->namebuff, &type, &domain);
|
flags = search_servers(now, &addrp, gotname, daemon->namebuff, &type, &domain, &norebind);
|
||||||
|
|
||||||
if (!flags && !(forward = get_new_frec(now, NULL)))
|
if (!flags && !(forward = get_new_frec(now, NULL)))
|
||||||
/* table full - server failure. */
|
/* table full - server failure. */
|
||||||
@@ -242,34 +276,45 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
|
|
||||||
if (forward)
|
if (forward)
|
||||||
{
|
{
|
||||||
/* force unchanging id for signed packets */
|
|
||||||
int is_sign;
|
|
||||||
find_pseudoheader(header, plen, NULL, NULL, &is_sign);
|
|
||||||
|
|
||||||
forward->source = *udpaddr;
|
forward->source = *udpaddr;
|
||||||
forward->dest = *dst_addr;
|
forward->dest = *dst_addr;
|
||||||
forward->iface = dst_iface;
|
forward->iface = dst_iface;
|
||||||
forward->orig_id = ntohs(header->id);
|
forward->orig_id = ntohs(header->id);
|
||||||
forward->new_id = get_id(is_sign, forward->orig_id, crc);
|
forward->new_id = get_id(crc);
|
||||||
forward->fd = udpfd;
|
forward->fd = udpfd;
|
||||||
forward->crc = crc;
|
forward->crc = crc;
|
||||||
forward->forwardall = 0;
|
forward->forwardall = 0;
|
||||||
header->id = htons(forward->new_id);
|
if (norebind)
|
||||||
|
forward->flags |= FREC_NOREBIND;
|
||||||
|
if (header->cd)
|
||||||
|
forward->flags |= FREC_CHECKING_DISABLED;
|
||||||
|
|
||||||
/* In strict_order mode, or when using domain specific servers
|
header->id = htons(forward->new_id);
|
||||||
always try servers in the order specified in resolv.conf,
|
|
||||||
|
/* In strict_order mode, always try servers in the order
|
||||||
|
specified in resolv.conf, if a domain is given
|
||||||
|
always try all the available servers,
|
||||||
otherwise, use the one last known to work. */
|
otherwise, use the one last known to work. */
|
||||||
|
|
||||||
if (type != 0 || (daemon->options & OPT_ORDER))
|
if (type == 0)
|
||||||
start = daemon->servers;
|
{
|
||||||
else if (!(start = daemon->last_server) ||
|
if (option_bool(OPT_ORDER))
|
||||||
daemon->forwardcount++ > FORWARD_TEST ||
|
start = daemon->servers;
|
||||||
difftime(now, daemon->forwardtime) > FORWARD_TIME)
|
else if (!(start = daemon->last_server) ||
|
||||||
|
daemon->forwardcount++ > FORWARD_TEST ||
|
||||||
|
difftime(now, daemon->forwardtime) > FORWARD_TIME)
|
||||||
|
{
|
||||||
|
start = daemon->servers;
|
||||||
|
forward->forwardall = 1;
|
||||||
|
daemon->forwardcount = 0;
|
||||||
|
daemon->forwardtime = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
start = daemon->servers;
|
start = daemon->servers;
|
||||||
forward->forwardall = 1;
|
if (!option_bool(OPT_ORDER))
|
||||||
daemon->forwardcount = 0;
|
forward->forwardall = 1;
|
||||||
daemon->forwardtime = now;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,7 +327,10 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
{
|
{
|
||||||
struct server *firstsentto = start;
|
struct server *firstsentto = start;
|
||||||
int forwarded = 0;
|
int forwarded = 0;
|
||||||
|
|
||||||
|
if (udpaddr && option_bool(OPT_ADD_MAC))
|
||||||
|
plen = add_mac(header, plen, ((char *) header) + PACKETSZ, udpaddr);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/* only send to servers dealing with our domain.
|
/* only send to servers dealing with our domain.
|
||||||
@@ -371,14 +419,14 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
if (udpfd != -1)
|
if (udpfd != -1)
|
||||||
{
|
{
|
||||||
plen = setup_reply(header, plen, addrp, flags, daemon->local_ttl);
|
plen = setup_reply(header, plen, addrp, flags, daemon->local_ttl);
|
||||||
send_from(udpfd, daemon->options & OPT_NOWILD, (char *)header, plen, udpaddr, dst_addr, dst_iface);
|
send_from(udpfd, option_bool(OPT_NOWILD), (char *)header, plen, udpaddr, dst_addr, dst_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t process_reply(HEADER *header, time_t now,
|
static size_t process_reply(HEADER *header, time_t now,
|
||||||
struct server *server, size_t n)
|
struct server *server, size_t n, int check_rebind, int checking_disabled)
|
||||||
{
|
{
|
||||||
unsigned char *pheader, *sizep;
|
unsigned char *pheader, *sizep;
|
||||||
int munged = 0, is_sign;
|
int munged = 0, is_sign;
|
||||||
@@ -398,6 +446,10 @@ static size_t process_reply(HEADER *header, time_t now,
|
|||||||
PUTSHORT(daemon->edns_pktsz, psave);
|
PUTSHORT(daemon->edns_pktsz, psave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* RFC 4035 sect 4.6 para 3 */
|
||||||
|
if (!is_sign && !option_bool(OPT_DNSSEC))
|
||||||
|
header->ad = 0;
|
||||||
|
|
||||||
if (header->opcode != QUERY || (header->rcode != NOERROR && header->rcode != NXDOMAIN))
|
if (header->opcode != QUERY || (header->rcode != NOERROR && header->rcode != NXDOMAIN))
|
||||||
return n;
|
return n;
|
||||||
|
|
||||||
@@ -407,7 +459,7 @@ static size_t process_reply(HEADER *header, time_t now,
|
|||||||
{
|
{
|
||||||
prettyprint_addr(&server->addr, daemon->namebuff);
|
prettyprint_addr(&server->addr, daemon->namebuff);
|
||||||
my_syslog(LOG_WARNING, _("nameserver %s refused to do a recursive query"), daemon->namebuff);
|
my_syslog(LOG_WARNING, _("nameserver %s refused to do a recursive query"), daemon->namebuff);
|
||||||
if (!(daemon->options & OPT_LOG))
|
if (!option_bool(OPT_LOG))
|
||||||
server->flags |= SERV_WARNED_RECURSIVE;
|
server->flags |= SERV_WARNED_RECURSIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,9 +484,9 @@ static size_t process_reply(HEADER *header, time_t now,
|
|||||||
header->rcode = NOERROR;
|
header->rcode = NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extract_addresses(header, n, daemon->namebuff, now))
|
if (extract_addresses(header, n, daemon->namebuff, now, is_sign, check_rebind, checking_disabled))
|
||||||
{
|
{
|
||||||
my_syslog(LOG_WARNING, _("possible DNS-rebind attack detected"));
|
my_syslog(LOG_WARNING, _("possible DNS-rebind attack detected: %s"), daemon->namebuff);
|
||||||
munged = 1;
|
munged = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,7 +546,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
server = forward->sentto;
|
server = forward->sentto;
|
||||||
|
|
||||||
if ((header->rcode == SERVFAIL || header->rcode == REFUSED) &&
|
if ((header->rcode == SERVFAIL || header->rcode == REFUSED) &&
|
||||||
!(daemon->options & OPT_ORDER) &&
|
!option_bool(OPT_ORDER) &&
|
||||||
forward->forwardall == 0)
|
forward->forwardall == 0)
|
||||||
/* for broken servers, attempt to send to another one. */
|
/* for broken servers, attempt to send to another one. */
|
||||||
{
|
{
|
||||||
@@ -536,7 +588,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(daemon->options & OPT_ALL_SERVERS))
|
if (!option_bool(OPT_ALL_SERVERS))
|
||||||
daemon->last_server = server;
|
daemon->last_server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,11 +599,16 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
if (forward->forwardall == 0 || --forward->forwardall == 1 ||
|
if (forward->forwardall == 0 || --forward->forwardall == 1 ||
|
||||||
(header->rcode != REFUSED && header->rcode != SERVFAIL))
|
(header->rcode != REFUSED && header->rcode != SERVFAIL))
|
||||||
{
|
{
|
||||||
if ((nn = process_reply(header, now, server, (size_t)n)))
|
int check_rebind = !(forward->flags & FREC_NOREBIND);
|
||||||
|
|
||||||
|
if (!option_bool(OPT_NO_REBIND))
|
||||||
|
check_rebind = 0;
|
||||||
|
|
||||||
|
if ((nn = process_reply(header, now, server, (size_t)n, check_rebind, forward->flags & FREC_CHECKING_DISABLED)))
|
||||||
{
|
{
|
||||||
header->id = htons(forward->orig_id);
|
header->id = htons(forward->orig_id);
|
||||||
header->ra = 1; /* recursion if available */
|
header->ra = 1; /* recursion if available */
|
||||||
send_from(forward->fd, daemon->options & OPT_NOWILD, daemon->packet, nn,
|
send_from(forward->fd, option_bool(OPT_NOWILD), daemon->packet, nn,
|
||||||
&forward->source, &forward->dest, forward->iface);
|
&forward->source, &forward->dest, forward->iface);
|
||||||
}
|
}
|
||||||
free_frec(forward); /* cancel */
|
free_frec(forward); /* cancel */
|
||||||
@@ -591,7 +648,7 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
/* packet buffer overwritten */
|
/* packet buffer overwritten */
|
||||||
daemon->srv_save = NULL;
|
daemon->srv_save = NULL;
|
||||||
|
|
||||||
if (listen->family == AF_INET && (daemon->options & OPT_NOWILD))
|
if (listen->family == AF_INET && option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
dst_addr_4 = listen->iface->addr.in.sin_addr;
|
dst_addr_4 = listen->iface->addr.in.sin_addr;
|
||||||
netmask = listen->iface->netmask;
|
netmask = listen->iface->netmask;
|
||||||
@@ -626,8 +683,8 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
if (listen->family == AF_INET6)
|
if (listen->family == AF_INET6)
|
||||||
source_addr.in6.sin6_flowinfo = 0;
|
source_addr.in6.sin6_flowinfo = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(daemon->options & OPT_NOWILD))
|
if (!option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|
||||||
@@ -639,21 +696,37 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
|
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
|
||||||
{
|
{
|
||||||
dst_addr_4 = dst_addr.addr.addr4 = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_spec_dst;
|
union {
|
||||||
if_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
|
unsigned char *c;
|
||||||
|
struct in_pktinfo *p;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
dst_addr_4 = dst_addr.addr.addr4 = p.p->ipi_spec_dst;
|
||||||
|
if_index = p.p->ipi_ifindex;
|
||||||
}
|
}
|
||||||
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
||||||
if (listen->family == AF_INET)
|
if (listen->family == AF_INET)
|
||||||
{
|
{
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
{
|
||||||
dst_addr_4 = dst_addr.addr.addr4 = *((struct in_addr *)CMSG_DATA(cmptr));
|
union {
|
||||||
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
unsigned char *c;
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
unsigned int *i;
|
||||||
if_index = *((unsigned int *)CMSG_DATA(cmptr));
|
struct in_addr *a;
|
||||||
#else
|
#ifndef HAVE_SOLARIS_NETWORK
|
||||||
if_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
struct sockaddr_dl *s;
|
||||||
#endif
|
#endif
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
||||||
|
dst_addr_4 = dst_addr.addr.addr4 = *(p.a);
|
||||||
|
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
|
#ifdef HAVE_SOLARIS_NETWORK
|
||||||
|
if_index = *(p.i);
|
||||||
|
#else
|
||||||
|
if_index = p.s->sdl_index;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -661,10 +734,16 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
if (listen->family == AF_INET6)
|
if (listen->family == AF_INET6)
|
||||||
{
|
{
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == IPV6_LEVEL && cmptr->cmsg_type == IPV6_PKTINFO)
|
if (cmptr->cmsg_level == IPV6_LEVEL && cmptr->cmsg_type == daemon->v6pktinfo)
|
||||||
{
|
{
|
||||||
dst_addr.addr.addr6 = ((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_addr;
|
union {
|
||||||
if_index =((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_ifindex;
|
unsigned char *c;
|
||||||
|
struct in6_pktinfo *p;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
|
||||||
|
dst_addr.addr.addr6 = p.p->ipi6_addr;
|
||||||
|
if_index = p.p->ipi6_ifindex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -676,7 +755,7 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (listen->family == AF_INET &&
|
if (listen->family == AF_INET &&
|
||||||
(daemon->options & OPT_LOCALISE) &&
|
option_bool(OPT_LOCALISE) &&
|
||||||
ioctl(listen->fd, SIOCGIFNETMASK, &ifr) == -1)
|
ioctl(listen->fd, SIOCGIFNETMASK, &ifr) == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -703,7 +782,7 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
dst_addr_4, netmask, now);
|
dst_addr_4, netmask, now);
|
||||||
if (m >= 1)
|
if (m >= 1)
|
||||||
{
|
{
|
||||||
send_from(listen->fd, daemon->options & OPT_NOWILD, (char *)header,
|
send_from(listen->fd, option_bool(OPT_NOWILD), (char *)header,
|
||||||
m, &source_addr, &dst_addr, if_index);
|
m, &source_addr, &dst_addr, if_index);
|
||||||
daemon->local_answer++;
|
daemon->local_answer++;
|
||||||
}
|
}
|
||||||
@@ -721,7 +800,9 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
unsigned char *tcp_request(int confd, time_t now,
|
unsigned char *tcp_request(int confd, time_t now,
|
||||||
struct in_addr local_addr, struct in_addr netmask)
|
struct in_addr local_addr, struct in_addr netmask)
|
||||||
{
|
{
|
||||||
int size = 0;
|
size_t size = 0;
|
||||||
|
int norebind = 0;
|
||||||
|
int checking_disabled;
|
||||||
size_t m;
|
size_t m;
|
||||||
unsigned short qtype, gotname;
|
unsigned short qtype, gotname;
|
||||||
unsigned char c1, c2;
|
unsigned char c1, c2;
|
||||||
@@ -742,6 +823,12 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
header = (HEADER *)packet;
|
header = (HEADER *)packet;
|
||||||
|
|
||||||
|
/* save state of "cd" flag in query */
|
||||||
|
checking_disabled = header->cd;
|
||||||
|
|
||||||
|
/* RFC 4035: sect 4.6 para 2 */
|
||||||
|
header->ad = 0;
|
||||||
|
|
||||||
if ((gotname = extract_request(header, (unsigned int)size, daemon->namebuff, &qtype)))
|
if ((gotname = extract_request(header, (unsigned int)size, daemon->namebuff, &qtype)))
|
||||||
{
|
{
|
||||||
@@ -774,15 +861,24 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
|
|
||||||
if (m == 0)
|
if (m == 0)
|
||||||
{
|
{
|
||||||
unsigned short flags = 0;
|
unsigned int flags = 0;
|
||||||
struct all_addr *addrp = NULL;
|
struct all_addr *addrp = NULL;
|
||||||
int type = 0;
|
int type = 0;
|
||||||
char *domain = NULL;
|
char *domain = NULL;
|
||||||
|
|
||||||
|
if (option_bool(OPT_ADD_MAC))
|
||||||
|
{
|
||||||
|
union mysockaddr peer_addr;
|
||||||
|
socklen_t peer_len = sizeof(union mysockaddr);
|
||||||
|
|
||||||
|
if (getpeername(confd, (struct sockaddr *)&peer_addr, &peer_len) != -1)
|
||||||
|
size = add_mac(header, size, ((char *) header) + 65536, &peer_addr);
|
||||||
|
}
|
||||||
|
|
||||||
if (gotname)
|
if (gotname)
|
||||||
flags = search_servers(now, &addrp, gotname, daemon->namebuff, &type, &domain);
|
flags = search_servers(now, &addrp, gotname, daemon->namebuff, &type, &domain, &norebind);
|
||||||
|
|
||||||
if (type != 0 || (daemon->options & OPT_ORDER) || !daemon->last_server)
|
if (type != 0 || option_bool(OPT_ORDER) || !daemon->last_server)
|
||||||
last_server = daemon->servers;
|
last_server = daemon->servers;
|
||||||
else
|
else
|
||||||
last_server = daemon->last_server;
|
last_server = daemon->last_server;
|
||||||
@@ -796,7 +892,7 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
Note that this code subtley ensures that consecutive queries on this connection
|
Note that this code subtley ensures that consecutive queries on this connection
|
||||||
which can go to the same server, do so. */
|
which can go to the same server, do so. */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (!firstsendto)
|
if (!firstsendto)
|
||||||
firstsendto = last_server;
|
firstsendto = last_server;
|
||||||
else
|
else
|
||||||
@@ -861,7 +957,8 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
someone might be attempting to insert bogus values into the cache by
|
someone might be attempting to insert bogus values into the cache by
|
||||||
sending replies containing questions and bogus answers. */
|
sending replies containing questions and bogus answers. */
|
||||||
if (crc == questions_crc(header, (unsigned int)m, daemon->namebuff))
|
if (crc == questions_crc(header, (unsigned int)m, daemon->namebuff))
|
||||||
m = process_reply(header, now, last_server, (unsigned int)m);
|
m = process_reply(header, now, last_server, (unsigned int)m,
|
||||||
|
option_bool(OPT_NO_REBIND) && !norebind, checking_disabled);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -893,6 +990,7 @@ static struct frec *allocate_frec(time_t now)
|
|||||||
f->time = now;
|
f->time = now;
|
||||||
f->sentto = NULL;
|
f->sentto = NULL;
|
||||||
f->rfd4 = NULL;
|
f->rfd4 = NULL;
|
||||||
|
f->flags = 0;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
f->rfd6 = NULL;
|
f->rfd6 = NULL;
|
||||||
#endif
|
#endif
|
||||||
@@ -945,6 +1043,7 @@ static void free_frec(struct frec *f)
|
|||||||
|
|
||||||
f->rfd4 = NULL;
|
f->rfd4 = NULL;
|
||||||
f->sentto = NULL;
|
f->sentto = NULL;
|
||||||
|
f->flags = 0;
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (f->rfd6 && --(f->rfd6->refcount) == 0)
|
if (f->rfd6 && --(f->rfd6->refcount) == 0)
|
||||||
@@ -1066,22 +1165,12 @@ void server_gone(struct server *server)
|
|||||||
daemon->srv_save = NULL;
|
daemon->srv_save = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return unique random ids.
|
/* return unique random ids. */
|
||||||
For signed packets we can't change the ID without breaking the
|
static unsigned short get_id(unsigned int crc)
|
||||||
signing, so we keep the same one. In this case force is set, and this
|
|
||||||
routine degenerates into killing any conflicting forward record. */
|
|
||||||
static unsigned short get_id(int force, unsigned short force_id, unsigned int crc)
|
|
||||||
{
|
{
|
||||||
unsigned short ret = 0;
|
unsigned short ret = 0;
|
||||||
|
|
||||||
if (force)
|
do
|
||||||
{
|
|
||||||
struct frec *f = lookup_frec(force_id, crc);
|
|
||||||
if (f)
|
|
||||||
free_frec(f); /* free */
|
|
||||||
ret = force_id;
|
|
||||||
}
|
|
||||||
else do
|
|
||||||
ret = rand16();
|
ret = rand16();
|
||||||
while (lookup_frec(ret, crc));
|
while (lookup_frec(ret, crc));
|
||||||
|
|
||||||
|
|||||||
+78
-96
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -31,11 +31,12 @@
|
|||||||
#if defined(HAVE_DHCP) && defined(HAVE_SCRIPT)
|
#if defined(HAVE_DHCP) && defined(HAVE_SCRIPT)
|
||||||
|
|
||||||
static void my_setenv(const char *name, const char *value, int *error);
|
static void my_setenv(const char *name, const char *value, int *error);
|
||||||
|
static unsigned char *grab_extradata(unsigned char *buf, unsigned char *end, char *env, int *err);
|
||||||
|
|
||||||
struct script_data
|
struct script_data
|
||||||
{
|
{
|
||||||
unsigned char action, hwaddr_len, hwaddr_type;
|
unsigned char action, hwaddr_len, hwaddr_type;
|
||||||
unsigned char clid_len, hostname_len, uclass_len, vclass_len, shost_len;
|
unsigned char clid_len, hostname_len, ed_len;
|
||||||
struct in_addr addr, giaddr;
|
struct in_addr addr, giaddr;
|
||||||
unsigned int remaining_time;
|
unsigned int remaining_time;
|
||||||
#ifdef HAVE_BROKEN_RTC
|
#ifdef HAVE_BROKEN_RTC
|
||||||
@@ -78,14 +79,14 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
sigaction(SIGTERM, &sigact, NULL);
|
sigaction(SIGTERM, &sigact, NULL);
|
||||||
sigaction(SIGALRM, &sigact, NULL);
|
sigaction(SIGALRM, &sigact, NULL);
|
||||||
|
|
||||||
if (!(daemon->options & OPT_DEBUG) && uid != 0)
|
if (!option_bool(OPT_DEBUG) && uid != 0)
|
||||||
{
|
{
|
||||||
gid_t dummy;
|
gid_t dummy;
|
||||||
if (setgroups(0, &dummy) == -1 ||
|
if (setgroups(0, &dummy) == -1 ||
|
||||||
setgid(gid) == -1 ||
|
setgid(gid) == -1 ||
|
||||||
setuid(uid) == -1)
|
setuid(uid) == -1)
|
||||||
{
|
{
|
||||||
if (daemon->options & OPT_NO_FORK)
|
if (option_bool(OPT_NO_FORK))
|
||||||
/* send error to daemon process if no-fork */
|
/* send error to daemon process if no-fork */
|
||||||
send_event(event_fd, EVENT_HUSER_ERR, errno);
|
send_event(event_fd, EVENT_HUSER_ERR, errno);
|
||||||
else
|
else
|
||||||
@@ -112,6 +113,7 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
struct script_data data;
|
struct script_data data;
|
||||||
char *p, *action_str, *hostname = NULL;
|
char *p, *action_str, *hostname = NULL;
|
||||||
unsigned char *buf = (unsigned char *)daemon->namebuff;
|
unsigned char *buf = (unsigned char *)daemon->namebuff;
|
||||||
|
unsigned char *end, *alloc_buff = NULL;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
/* we read zero bytes when pipe closed: this is our signal to exit */
|
/* we read zero bytes when pipe closed: this is our signal to exit */
|
||||||
@@ -138,8 +140,8 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
p += sprintf(p, ":");
|
p += sprintf(p, ":");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and CLID into packet */
|
/* and CLID into packet, avoid overwrite from bad data */
|
||||||
if (!read_write(pipefd[0], buf, data.clid_len, 1))
|
if ((data.clid_len > daemon->packet_buff_sz) || !read_write(pipefd[0], buf, data.clid_len, 1))
|
||||||
continue;
|
continue;
|
||||||
for (p = daemon->packet, i = 0; i < data.clid_len; i++)
|
for (p = daemon->packet, i = 0; i < data.clid_len; i++)
|
||||||
{
|
{
|
||||||
@@ -150,18 +152,25 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
|
|
||||||
/* and expiry or length into dhcp_buff2 */
|
/* and expiry or length into dhcp_buff2 */
|
||||||
#ifdef HAVE_BROKEN_RTC
|
#ifdef HAVE_BROKEN_RTC
|
||||||
sprintf(daemon->dhcp_buff2, "%u ", data.length);
|
sprintf(daemon->dhcp_buff2, "%u", data.length);
|
||||||
#else
|
#else
|
||||||
sprintf(daemon->dhcp_buff2, "%lu ", (unsigned long)data.expires);
|
sprintf(daemon->dhcp_buff2, "%lu", (unsigned long)data.expires);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* supplied data may just exceed normal buffer (unlikely) */
|
||||||
|
if ((data.hostname_len + data.ed_len) > daemon->packet_buff_sz &&
|
||||||
|
!(alloc_buff = buf = malloc(data.hostname_len + data.ed_len)))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!read_write(pipefd[0], buf,
|
if (!read_write(pipefd[0], buf,
|
||||||
data.hostname_len + data.uclass_len + data.vclass_len + data.shost_len, 1))
|
data.hostname_len + data.ed_len, 1))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* possible fork errors are all temporary resource problems */
|
/* possible fork errors are all temporary resource problems */
|
||||||
while ((pid = fork()) == -1 && (errno == EAGAIN || errno == ENOMEM))
|
while ((pid = fork()) == -1 && (errno == EAGAIN || errno == ENOMEM))
|
||||||
sleep(2);
|
sleep(2);
|
||||||
|
|
||||||
|
free(alloc_buff);
|
||||||
|
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
continue;
|
continue;
|
||||||
@@ -204,51 +213,6 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
my_setenv("DNSMASQ_LEASE_EXPIRES", daemon->dhcp_buff2, &err);
|
my_setenv("DNSMASQ_LEASE_EXPIRES", daemon->dhcp_buff2, &err);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (data.vclass_len != 0)
|
|
||||||
{
|
|
||||||
buf[data.vclass_len - 1] = 0; /* don't trust zero-term */
|
|
||||||
/* cannot have = chars in env - truncate if found . */
|
|
||||||
if ((p = strchr((char *)buf, '=')))
|
|
||||||
*p = 0;
|
|
||||||
my_setenv("DNSMASQ_VENDOR_CLASS", (char *)buf, &err);
|
|
||||||
buf += data.vclass_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.uclass_len != 0)
|
|
||||||
{
|
|
||||||
unsigned char *end = buf + data.uclass_len;
|
|
||||||
buf[data.uclass_len - 1] = 0; /* don't trust zero-term */
|
|
||||||
|
|
||||||
for (i = 0; buf < end;)
|
|
||||||
{
|
|
||||||
size_t len = strlen((char *)buf) + 1;
|
|
||||||
if ((p = strchr((char *)buf, '=')))
|
|
||||||
*p = 0;
|
|
||||||
if (strlen((char *)buf) != 0)
|
|
||||||
{
|
|
||||||
sprintf(daemon->dhcp_buff2, "DNSMASQ_USER_CLASS%i", i++);
|
|
||||||
my_setenv(daemon->dhcp_buff2, (char *)buf, &err);
|
|
||||||
}
|
|
||||||
buf += len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.shost_len != 0)
|
|
||||||
{
|
|
||||||
buf[data.shost_len - 1] = 0; /* don't trust zero-term */
|
|
||||||
/* cannot have = chars in env - truncate if found . */
|
|
||||||
if ((p = strchr((char *)buf, '=')))
|
|
||||||
*p = 0;
|
|
||||||
my_setenv("DNSMASQ_SUPPLIED_HOSTNAME", (char *)buf, &err);
|
|
||||||
buf += data.shost_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.giaddr.s_addr != 0)
|
|
||||||
my_setenv("DNSMASQ_RELAY_ADDRESS", inet_ntoa(data.giaddr), &err);
|
|
||||||
|
|
||||||
sprintf(daemon->dhcp_buff2, "%u ", data.remaining_time);
|
|
||||||
my_setenv("DNSMASQ_TIME_REMAINING", daemon->dhcp_buff2, &err);
|
|
||||||
|
|
||||||
if (data.hostname_len != 0)
|
if (data.hostname_len != 0)
|
||||||
{
|
{
|
||||||
char *dot;
|
char *dot;
|
||||||
@@ -260,9 +224,33 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
{
|
{
|
||||||
my_setenv("DNSMASQ_DOMAIN", dot+1, &err);
|
my_setenv("DNSMASQ_DOMAIN", dot+1, &err);
|
||||||
*dot = 0;
|
*dot = 0;
|
||||||
}
|
}
|
||||||
|
buf += data.hostname_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
end = buf + data.ed_len;
|
||||||
|
buf = grab_extradata(buf, end, "DNSMASQ_VENDOR_CLASS", &err);
|
||||||
|
buf = grab_extradata(buf, end, "DNSMASQ_SUPPLIED_HOSTNAME", &err);
|
||||||
|
buf = grab_extradata(buf, end, "DNSMASQ_CPEWAN_OUI", &err);
|
||||||
|
buf = grab_extradata(buf, end, "DNSMASQ_CPEWAN_SERIAL", &err);
|
||||||
|
buf = grab_extradata(buf, end, "DNSMASQ_CPEWAN_CLASS", &err);
|
||||||
|
buf = grab_extradata(buf, end, "DNSMASQ_TAGS", &err);
|
||||||
|
|
||||||
|
for (i = 0; buf; i++)
|
||||||
|
{
|
||||||
|
sprintf(daemon->dhcp_buff2, "DNSMASQ_USER_CLASS%i", i);
|
||||||
|
buf = grab_extradata(buf, end, daemon->dhcp_buff2, &err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.giaddr.s_addr != 0)
|
||||||
|
my_setenv("DNSMASQ_RELAY_ADDRESS", inet_ntoa(data.giaddr), &err);
|
||||||
|
|
||||||
|
if (data.action != ACTION_DEL)
|
||||||
|
{
|
||||||
|
sprintf(daemon->dhcp_buff2, "%u", data.remaining_time);
|
||||||
|
my_setenv("DNSMASQ_TIME_REMAINING", daemon->dhcp_buff2, &err);
|
||||||
|
}
|
||||||
|
|
||||||
if (data.action == ACTION_OLD_HOSTNAME && hostname)
|
if (data.action == ACTION_OLD_HOSTNAME && hostname)
|
||||||
{
|
{
|
||||||
my_setenv("DNSMASQ_OLD_HOSTNAME", hostname, &err);
|
my_setenv("DNSMASQ_OLD_HOSTNAME", hostname, &err);
|
||||||
@@ -294,30 +282,48 @@ static void my_setenv(const char *name, const char *value, int *error)
|
|||||||
*error = errno;
|
*error = errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned char *grab_extradata(unsigned char *buf, unsigned char *end, char *env, int *err)
|
||||||
|
{
|
||||||
|
unsigned char *next;
|
||||||
|
|
||||||
|
if (!buf || (buf == end))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (next = buf; *next != 0; next++)
|
||||||
|
if (next == end)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (next != buf)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
/* No "=" in value */
|
||||||
|
if ((p = strchr((char *)buf, '=')))
|
||||||
|
*p = 0;
|
||||||
|
my_setenv(env, (char *)buf, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return next + 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* pack up lease data into a buffer */
|
/* pack up lease data into a buffer */
|
||||||
void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t now)
|
void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t now)
|
||||||
{
|
{
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
size_t size;
|
size_t size;
|
||||||
unsigned int hostname_len = 0, clid_len = 0, vclass_len = 0;
|
unsigned int hostname_len = 0, clid_len = 0, ed_len = 0;
|
||||||
unsigned int uclass_len = 0, shost_len = 0;
|
|
||||||
|
|
||||||
/* no script */
|
/* no script */
|
||||||
if (daemon->helperfd == -1)
|
if (daemon->helperfd == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (lease->vendorclass)
|
if (lease->extradata)
|
||||||
vclass_len = lease->vendorclass_len;
|
ed_len = lease->extradata_len;
|
||||||
if (lease->userclass)
|
|
||||||
uclass_len = lease->userclass_len;
|
|
||||||
if (lease->supplied_hostname)
|
|
||||||
shost_len = lease->supplied_hostname_len;
|
|
||||||
if (lease->clid)
|
if (lease->clid)
|
||||||
clid_len = lease->clid_len;
|
clid_len = lease->clid_len;
|
||||||
if (hostname)
|
if (hostname)
|
||||||
hostname_len = strlen(hostname) + 1;
|
hostname_len = strlen(hostname) + 1;
|
||||||
|
|
||||||
size = sizeof(struct script_data) + clid_len + vclass_len + uclass_len + shost_len + hostname_len;
|
size = sizeof(struct script_data) + clid_len + ed_len + hostname_len;
|
||||||
|
|
||||||
if (size > buf_size)
|
if (size > buf_size)
|
||||||
{
|
{
|
||||||
@@ -339,26 +345,13 @@ void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t n
|
|||||||
buf->hwaddr_len = lease->hwaddr_len;
|
buf->hwaddr_len = lease->hwaddr_len;
|
||||||
buf->hwaddr_type = lease->hwaddr_type;
|
buf->hwaddr_type = lease->hwaddr_type;
|
||||||
buf->clid_len = clid_len;
|
buf->clid_len = clid_len;
|
||||||
buf->vclass_len = vclass_len;
|
buf->ed_len = ed_len;
|
||||||
buf->uclass_len = uclass_len;
|
|
||||||
buf->shost_len = shost_len;
|
|
||||||
buf->hostname_len = hostname_len;
|
buf->hostname_len = hostname_len;
|
||||||
buf->addr = lease->addr;
|
buf->addr = lease->addr;
|
||||||
buf->giaddr = lease->giaddr;
|
buf->giaddr = lease->giaddr;
|
||||||
memcpy(buf->hwaddr, lease->hwaddr, lease->hwaddr_len);
|
memcpy(buf->hwaddr, lease->hwaddr, lease->hwaddr_len);
|
||||||
buf->interface[0] = 0;
|
if (!indextoname(daemon->dhcpfd, lease->last_interface, buf->interface))
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
buf->interface[0] = 0;
|
||||||
if (lease->last_interface != 0)
|
|
||||||
{
|
|
||||||
struct ifreq ifr;
|
|
||||||
ifr.ifr_ifindex = lease->last_interface;
|
|
||||||
if (ioctl(daemon->dhcpfd, SIOCGIFNAME, &ifr) != -1)
|
|
||||||
strncpy(buf->interface, ifr.ifr_name, IF_NAMESIZE);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (lease->last_interface != 0)
|
|
||||||
if_indextoname(lease->last_interface, buf->interface);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_BROKEN_RTC
|
#ifdef HAVE_BROKEN_RTC
|
||||||
buf->length = lease->length;
|
buf->length = lease->length;
|
||||||
@@ -373,27 +366,16 @@ void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t n
|
|||||||
memcpy(p, lease->clid, clid_len);
|
memcpy(p, lease->clid, clid_len);
|
||||||
p += clid_len;
|
p += clid_len;
|
||||||
}
|
}
|
||||||
if (vclass_len != 0)
|
|
||||||
{
|
|
||||||
memcpy(p, lease->vendorclass, vclass_len);
|
|
||||||
p += vclass_len;
|
|
||||||
}
|
|
||||||
if (uclass_len != 0)
|
|
||||||
{
|
|
||||||
memcpy(p, lease->userclass, uclass_len);
|
|
||||||
p += uclass_len;
|
|
||||||
}
|
|
||||||
if (shost_len != 0)
|
|
||||||
{
|
|
||||||
memcpy(p, lease->supplied_hostname, shost_len);
|
|
||||||
p += shost_len;
|
|
||||||
}
|
|
||||||
if (hostname_len != 0)
|
if (hostname_len != 0)
|
||||||
{
|
{
|
||||||
memcpy(p, hostname, hostname_len);
|
memcpy(p, hostname, hostname_len);
|
||||||
p += hostname_len;
|
p += hostname_len;
|
||||||
}
|
}
|
||||||
|
if (ed_len != 0)
|
||||||
|
{
|
||||||
|
memcpy(p, lease->extradata, ed_len);
|
||||||
|
p += ed_len;
|
||||||
|
}
|
||||||
bytes_in_buf = p - (unsigned char *)buf;
|
bytes_in_buf = p - (unsigned char *)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-20
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -29,14 +29,15 @@ void lease_init(time_t now)
|
|||||||
int clid_len, hw_len, hw_type;
|
int clid_len, hw_len, hw_type;
|
||||||
FILE *leasestream;
|
FILE *leasestream;
|
||||||
|
|
||||||
/* These two each hold a DHCP option max size 255
|
/* These each hold a DHCP option max size 255
|
||||||
and get a terminating zero added */
|
and get a terminating zero added */
|
||||||
daemon->dhcp_buff = safe_malloc(256);
|
daemon->dhcp_buff = safe_malloc(256);
|
||||||
daemon->dhcp_buff2 = safe_malloc(256);
|
daemon->dhcp_buff2 = safe_malloc(256);
|
||||||
|
daemon->dhcp_buff3 = safe_malloc(256);
|
||||||
|
|
||||||
leases_left = daemon->dhcp_max;
|
leases_left = daemon->dhcp_max;
|
||||||
|
|
||||||
if (daemon->options & OPT_LEASE_RO)
|
if (option_bool(OPT_LEASE_RO))
|
||||||
{
|
{
|
||||||
/* run "<lease_change_script> init" once to get the
|
/* run "<lease_change_script> init" once to get the
|
||||||
initial state of the database. If leasefile-ro is
|
initial state of the database. If leasefile-ro is
|
||||||
@@ -253,7 +254,7 @@ void lease_update_dns(void)
|
|||||||
if (lease->fqdn)
|
if (lease->fqdn)
|
||||||
cache_add_dhcp_entry(lease->fqdn, &lease->addr, lease->expires);
|
cache_add_dhcp_entry(lease->fqdn, &lease->addr, lease->expires);
|
||||||
|
|
||||||
if (!(daemon->options & OPT_DHCP_FQDN) && lease->hostname)
|
if (!option_bool(OPT_DHCP_FQDN) && lease->hostname)
|
||||||
cache_add_dhcp_entry(lease->hostname, &lease->addr, lease->expires);
|
cache_add_dhcp_entry(lease->hostname, &lease->addr, lease->expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +470,7 @@ void lease_set_hostname(struct dhcp_lease *lease, char *name, int auth)
|
|||||||
/* Depending on mode, we check either unqualified name or FQDN. */
|
/* Depending on mode, we check either unqualified name or FQDN. */
|
||||||
for (lease_tmp = leases; lease_tmp; lease_tmp = lease_tmp->next)
|
for (lease_tmp = leases; lease_tmp; lease_tmp = lease_tmp->next)
|
||||||
{
|
{
|
||||||
if (daemon->options & OPT_DHCP_FQDN)
|
if (option_bool(OPT_DHCP_FQDN))
|
||||||
{
|
{
|
||||||
if (!new_fqdn || !lease_tmp->fqdn || !hostname_isequal(lease_tmp->fqdn, new_fqdn) )
|
if (!new_fqdn || !lease_tmp->fqdn || !hostname_isequal(lease_tmp->fqdn, new_fqdn) )
|
||||||
continue;
|
continue;
|
||||||
@@ -533,7 +534,7 @@ int do_script_run(time_t now)
|
|||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
/* If we're going to be sending DBus signals, but the connection is not yet up,
|
/* If we're going to be sending DBus signals, but the connection is not yet up,
|
||||||
delay everything until it is. */
|
delay everything until it is. */
|
||||||
if ((daemon->options & OPT_DBUS) && !daemon->dbus)
|
if (option_bool(OPT_DBUS) && !daemon->dbus)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -564,9 +565,7 @@ int do_script_run(time_t now)
|
|||||||
|
|
||||||
free(lease->old_hostname);
|
free(lease->old_hostname);
|
||||||
free(lease->clid);
|
free(lease->clid);
|
||||||
free(lease->vendorclass);
|
free(lease->extradata);
|
||||||
free(lease->userclass);
|
|
||||||
free(lease->supplied_hostname);
|
|
||||||
free(lease);
|
free(lease);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -587,7 +586,7 @@ int do_script_run(time_t now)
|
|||||||
|
|
||||||
for (lease = leases; lease; lease = lease->next)
|
for (lease = leases; lease; lease = lease->next)
|
||||||
if (lease->new || lease->changed ||
|
if (lease->new || lease->changed ||
|
||||||
(lease->aux_changed && (daemon->options & OPT_LEASE_RO)))
|
(lease->aux_changed && option_bool(OPT_LEASE_RO)))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SCRIPT
|
#ifdef HAVE_SCRIPT
|
||||||
queue_script(lease->new ? ACTION_ADD : ACTION_OLD, lease,
|
queue_script(lease->new ? ACTION_ADD : ACTION_OLD, lease,
|
||||||
@@ -599,16 +598,10 @@ int do_script_run(time_t now)
|
|||||||
#endif
|
#endif
|
||||||
lease->new = lease->changed = lease->aux_changed = 0;
|
lease->new = lease->changed = lease->aux_changed = 0;
|
||||||
|
|
||||||
/* these are used for the "add" call, then junked, since they're not in the database */
|
/* this is used for the "add" call, then junked, since they're not in the database */
|
||||||
free(lease->vendorclass);
|
free(lease->extradata);
|
||||||
lease->vendorclass = NULL;
|
lease->extradata = NULL;
|
||||||
|
|
||||||
free(lease->userclass);
|
|
||||||
lease->userclass = NULL;
|
|
||||||
|
|
||||||
free(lease->supplied_hostname);
|
|
||||||
lease->supplied_hostname = NULL;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -30,7 +30,8 @@
|
|||||||
|
|
||||||
/* defaults in case we die() before we log_start() */
|
/* defaults in case we die() before we log_start() */
|
||||||
static int log_fac = LOG_DAEMON;
|
static int log_fac = LOG_DAEMON;
|
||||||
static int log_stderr = 0;
|
static int log_stderr = 0;
|
||||||
|
static int echo_stderr = 0;
|
||||||
static int log_fd = -1;
|
static int log_fd = -1;
|
||||||
static int log_to_file = 0;
|
static int log_to_file = 0;
|
||||||
static int entries_alloced = 0;
|
static int entries_alloced = 0;
|
||||||
@@ -54,12 +55,12 @@ int log_start(struct passwd *ent_pw, int errfd)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
log_stderr = !!(daemon->options & OPT_DEBUG);
|
echo_stderr = option_bool(OPT_DEBUG);
|
||||||
|
|
||||||
if (daemon->log_fac != -1)
|
if (daemon->log_fac != -1)
|
||||||
log_fac = daemon->log_fac;
|
log_fac = daemon->log_fac;
|
||||||
#ifdef LOG_LOCAL0
|
#ifdef LOG_LOCAL0
|
||||||
else if (daemon->options & OPT_DEBUG)
|
else if (option_bool(OPT_DEBUG))
|
||||||
log_fac = LOG_LOCAL0;
|
log_fac = LOG_LOCAL0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -67,6 +68,12 @@ int log_start(struct passwd *ent_pw, int errfd)
|
|||||||
{
|
{
|
||||||
log_to_file = 1;
|
log_to_file = 1;
|
||||||
daemon->max_logs = 0;
|
daemon->max_logs = 0;
|
||||||
|
if (strcmp(daemon->log_file, "-") == 0)
|
||||||
|
{
|
||||||
|
log_stderr = 1;
|
||||||
|
echo_stderr = 0;
|
||||||
|
log_fd = dup(STDERR_FILENO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max_logs = daemon->max_logs;
|
max_logs = daemon->max_logs;
|
||||||
@@ -90,7 +97,7 @@ int log_start(struct passwd *ent_pw, int errfd)
|
|||||||
change the ownership here so that the file is always owned by
|
change the ownership here so that the file is always owned by
|
||||||
the dnsmasq user. Then logrotate can just copy the owner.
|
the dnsmasq user. Then logrotate can just copy the owner.
|
||||||
Failure of the chown call is OK, (for instance when started as non-root) */
|
Failure of the chown call is OK, (for instance when started as non-root) */
|
||||||
if (log_to_file && ent_pw && ent_pw->pw_uid != 0 &&
|
if (log_to_file && !log_stderr && ent_pw && ent_pw->pw_uid != 0 &&
|
||||||
fchown(log_fd, ent_pw->pw_uid, -1) != 0)
|
fchown(log_fd, ent_pw->pw_uid, -1) != 0)
|
||||||
ret = errno;
|
ret = errno;
|
||||||
|
|
||||||
@@ -99,37 +106,34 @@ int log_start(struct passwd *ent_pw, int errfd)
|
|||||||
|
|
||||||
int log_reopen(char *log_file)
|
int log_reopen(char *log_file)
|
||||||
{
|
{
|
||||||
if (log_fd != -1)
|
if (!log_stderr)
|
||||||
close(log_fd);
|
{
|
||||||
|
if (log_fd != -1)
|
||||||
/* NOTE: umask is set to 022 by the time this gets called */
|
close(log_fd);
|
||||||
|
|
||||||
if (log_file)
|
/* NOTE: umask is set to 022 by the time this gets called */
|
||||||
{
|
|
||||||
log_fd = open(log_file, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP);
|
if (log_file)
|
||||||
return log_fd != -1;
|
log_fd = open(log_file, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP);
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
#ifdef HAVE_SOLARIS_NETWORK
|
||||||
/* Solaris logging is "different", /dev/log is not unix-domain socket.
|
/* Solaris logging is "different", /dev/log is not unix-domain socket.
|
||||||
Just leave log_fd == -1 and use the vsyslog call for everything.... */
|
Just leave log_fd == -1 and use the vsyslog call for everything.... */
|
||||||
# define _PATH_LOG "" /* dummy */
|
# define _PATH_LOG "" /* dummy */
|
||||||
log_fd = -1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
{
|
int flags;
|
||||||
int flags;
|
log_fd = socket(AF_UNIX, connection_type, 0);
|
||||||
log_fd = socket(AF_UNIX, connection_type, 0);
|
|
||||||
|
/* if max_logs is zero, leave the socket blocking */
|
||||||
if (log_fd == -1)
|
if (log_fd != -1 && max_logs != 0 && (flags = fcntl(log_fd, F_GETFL)) != -1)
|
||||||
return 0;
|
fcntl(log_fd, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
|
||||||
/* if max_logs is zero, leave the socket blocking */
|
|
||||||
if (max_logs != 0 && (flags = fcntl(log_fd, F_GETFL)) != -1)
|
|
||||||
fcntl(log_fd, F_SETFL, flags | O_NONBLOCK);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
return 1;
|
}
|
||||||
|
|
||||||
|
return log_fd != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_entry(void)
|
static void free_entry(void)
|
||||||
@@ -267,9 +271,14 @@ void my_syslog(int priority, const char *format, ...)
|
|||||||
else if ((LOG_FACMASK & priority) == MS_DHCP)
|
else if ((LOG_FACMASK & priority) == MS_DHCP)
|
||||||
func = "-dhcp";
|
func = "-dhcp";
|
||||||
|
|
||||||
|
#ifdef LOG_PRI
|
||||||
priority = LOG_PRI(priority);
|
priority = LOG_PRI(priority);
|
||||||
|
#else
|
||||||
if (log_stderr)
|
/* Solaris doesn't have LOG_PRI */
|
||||||
|
priority &= LOG_PRIMASK;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (echo_stderr)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "dnsmasq%s: ", func);
|
fprintf(stderr, "dnsmasq%s: ", func);
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
@@ -318,7 +327,11 @@ void my_syslog(int priority, const char *format, ...)
|
|||||||
if (!log_to_file)
|
if (!log_to_file)
|
||||||
p += sprintf(p, "<%d>", priority | log_fac);
|
p += sprintf(p, "<%d>", priority | log_fac);
|
||||||
|
|
||||||
p += sprintf(p, "%.15s dnsmasq%s[%d]: ", ctime(&time_now) + 4, func, (int)pid);
|
/* Omit timestamp for default daemontools situation */
|
||||||
|
if (!log_stderr || !option_bool(OPT_NO_FORK))
|
||||||
|
p += sprintf(p, "%.15s ", ctime(&time_now) + 4);
|
||||||
|
|
||||||
|
p += sprintf(p, "dnsmasq%s[%d]: ", func, (int)pid);
|
||||||
|
|
||||||
len = p - entry->payload;
|
len = p - entry->payload;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
@@ -389,14 +402,20 @@ void check_log_writer(fd_set *set)
|
|||||||
|
|
||||||
void flush_log(void)
|
void flush_log(void)
|
||||||
{
|
{
|
||||||
/* block until queue empty */
|
/* write until queue empty, but don't loop forever if there's
|
||||||
if (log_fd != -1)
|
no connection to the syslog in existance */
|
||||||
|
while (log_fd != -1)
|
||||||
{
|
{
|
||||||
int flags;
|
struct timespec waiter;
|
||||||
if ((flags = fcntl(log_fd, F_GETFL)) != -1)
|
|
||||||
fcntl(log_fd, F_SETFL, flags & ~O_NONBLOCK);
|
|
||||||
log_write();
|
log_write();
|
||||||
close(log_fd);
|
if (!entries || !connection_good)
|
||||||
|
{
|
||||||
|
close(log_fd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
waiter.tv_sec = 0;
|
||||||
|
waiter.tv_nsec = 1000000; /* 1 ms */
|
||||||
|
nanosleep(&waiter, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,11 +426,13 @@ void die(char *message, char *arg1, int exit_code)
|
|||||||
if (!arg1)
|
if (!arg1)
|
||||||
arg1 = errmess;
|
arg1 = errmess;
|
||||||
|
|
||||||
log_stderr = 1; /* print as well as log when we die.... */
|
if (!log_stderr)
|
||||||
fputc('\n', stderr); /* prettyfy startup-script message */
|
{
|
||||||
|
echo_stderr = 1; /* print as well as log when we die.... */
|
||||||
|
fputc('\n', stderr); /* prettyfy startup-script message */
|
||||||
|
}
|
||||||
my_syslog(LOG_CRIT, message, arg1, errmess);
|
my_syslog(LOG_CRIT, message, arg1, errmess);
|
||||||
|
echo_stderr = 0;
|
||||||
log_stderr = 0;
|
|
||||||
my_syslog(LOG_CRIT, _("FAILED to start up"));
|
my_syslog(LOG_CRIT, _("FAILED to start up"));
|
||||||
flush_log();
|
flush_log();
|
||||||
|
|
||||||
|
|||||||
+70
-47
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -30,6 +30,10 @@
|
|||||||
# include <linux/if_addr.h>
|
# include <linux/if_addr.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NDA_RTA
|
||||||
|
# define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct iovec iov;
|
static struct iovec iov;
|
||||||
static u32 netlink_pid;
|
static u32 netlink_pid;
|
||||||
|
|
||||||
@@ -122,13 +126,14 @@ static ssize_t netlink_recv(void)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|
||||||
|
/* family = AF_UNSPEC finds ARP table entries. */
|
||||||
|
int iface_enumerate(int family, void *parm, int (*callback)())
|
||||||
{
|
{
|
||||||
struct sockaddr_nl addr;
|
struct sockaddr_nl addr;
|
||||||
struct nlmsghdr *h;
|
struct nlmsghdr *h;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
static unsigned int seq = 0;
|
static unsigned int seq = 0;
|
||||||
int family = AF_INET;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr nlh;
|
struct nlmsghdr nlh;
|
||||||
@@ -142,7 +147,7 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|||||||
|
|
||||||
again:
|
again:
|
||||||
req.nlh.nlmsg_len = sizeof(req);
|
req.nlh.nlmsg_len = sizeof(req);
|
||||||
req.nlh.nlmsg_type = RTM_GETADDR;
|
req.nlh.nlmsg_type = family == AF_UNSPEC ? RTM_GETNEIGH : RTM_GETADDR;
|
||||||
req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST | NLM_F_ACK;
|
req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST | NLM_F_ACK;
|
||||||
req.nlh.nlmsg_pid = 0;
|
req.nlh.nlmsg_pid = 0;
|
||||||
req.nlh.nlmsg_seq = ++seq;
|
req.nlh.nlmsg_seq = ++seq;
|
||||||
@@ -173,66 +178,84 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|||||||
else if (h->nlmsg_type == NLMSG_ERROR)
|
else if (h->nlmsg_type == NLMSG_ERROR)
|
||||||
nl_err(h);
|
nl_err(h);
|
||||||
else if (h->nlmsg_type == NLMSG_DONE)
|
else if (h->nlmsg_type == NLMSG_DONE)
|
||||||
{
|
return 1;
|
||||||
#ifdef HAVE_IPV6
|
else if (h->nlmsg_type == RTM_NEWADDR && family != AF_UNSPEC)
|
||||||
if (family == AF_INET && ipv6_callback)
|
|
||||||
{
|
|
||||||
family = AF_INET6;
|
|
||||||
goto again;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (h->nlmsg_type == RTM_NEWADDR)
|
|
||||||
{
|
{
|
||||||
struct ifaddrmsg *ifa = NLMSG_DATA(h);
|
struct ifaddrmsg *ifa = NLMSG_DATA(h);
|
||||||
struct rtattr *rta = IFA_RTA(ifa);
|
struct rtattr *rta = IFA_RTA(ifa);
|
||||||
unsigned int len1 = h->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa));
|
unsigned int len1 = h->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa));
|
||||||
|
|
||||||
if (ifa->ifa_family == AF_INET)
|
if (ifa->ifa_family == family)
|
||||||
{
|
{
|
||||||
struct in_addr netmask, addr, broadcast;
|
if (ifa->ifa_family == AF_INET)
|
||||||
|
|
||||||
netmask.s_addr = htonl(0xffffffff << (32 - ifa->ifa_prefixlen));
|
|
||||||
addr.s_addr = 0;
|
|
||||||
broadcast.s_addr = 0;
|
|
||||||
|
|
||||||
while (RTA_OK(rta, len1))
|
|
||||||
{
|
{
|
||||||
if (rta->rta_type == IFA_LOCAL)
|
struct in_addr netmask, addr, broadcast;
|
||||||
addr = *((struct in_addr *)(rta+1));
|
|
||||||
else if (rta->rta_type == IFA_BROADCAST)
|
|
||||||
broadcast = *((struct in_addr *)(rta+1));
|
|
||||||
|
|
||||||
rta = RTA_NEXT(rta, len1);
|
netmask.s_addr = htonl(0xffffffff << (32 - ifa->ifa_prefixlen));
|
||||||
|
addr.s_addr = 0;
|
||||||
|
broadcast.s_addr = 0;
|
||||||
|
|
||||||
|
while (RTA_OK(rta, len1))
|
||||||
|
{
|
||||||
|
if (rta->rta_type == IFA_LOCAL)
|
||||||
|
addr = *((struct in_addr *)(rta+1));
|
||||||
|
else if (rta->rta_type == IFA_BROADCAST)
|
||||||
|
broadcast = *((struct in_addr *)(rta+1));
|
||||||
|
|
||||||
|
rta = RTA_NEXT(rta, len1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr.s_addr)
|
||||||
|
if (!((*callback)(addr, ifa->ifa_index, netmask, broadcast, parm)))
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr.s_addr && ipv4_callback)
|
|
||||||
if (!((*ipv4_callback)(addr, ifa->ifa_index, netmask, broadcast, parm)))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
else if (ifa->ifa_family == AF_INET6)
|
else if (ifa->ifa_family == AF_INET6)
|
||||||
{
|
|
||||||
struct in6_addr *addrp = NULL;
|
|
||||||
while (RTA_OK(rta, len1))
|
|
||||||
{
|
{
|
||||||
if (rta->rta_type == IFA_ADDRESS)
|
struct in6_addr *addrp = NULL;
|
||||||
addrp = ((struct in6_addr *)(rta+1));
|
while (RTA_OK(rta, len1))
|
||||||
|
{
|
||||||
|
if (rta->rta_type == IFA_ADDRESS)
|
||||||
|
addrp = ((struct in6_addr *)(rta+1));
|
||||||
|
|
||||||
|
rta = RTA_NEXT(rta, len1);
|
||||||
|
}
|
||||||
|
|
||||||
rta = RTA_NEXT(rta, len1);
|
if (addrp)
|
||||||
|
if (!((*callback)(addrp, ifa->ifa_index, ifa->ifa_index, parm)))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (h->nlmsg_type == RTM_NEWNEIGH && family == AF_UNSPEC)
|
||||||
|
{
|
||||||
|
struct ndmsg *neigh = NLMSG_DATA(h);
|
||||||
|
struct rtattr *rta = NDA_RTA(neigh);
|
||||||
|
unsigned int len1 = h->nlmsg_len - NLMSG_LENGTH(sizeof(*neigh));
|
||||||
|
size_t maclen = 0;
|
||||||
|
char *inaddr = NULL, *mac = NULL;
|
||||||
|
|
||||||
|
while (RTA_OK(rta, len1))
|
||||||
|
{
|
||||||
|
if (rta->rta_type == NDA_DST)
|
||||||
|
inaddr = (char *)(rta+1);
|
||||||
|
else if (rta->rta_type == NDA_LLADDR)
|
||||||
|
{
|
||||||
|
maclen = rta->rta_len - sizeof(struct rtattr);
|
||||||
|
mac = (char *)(rta+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addrp && ipv6_callback)
|
rta = RTA_NEXT(rta, len1);
|
||||||
if (!((*ipv6_callback)(addrp, ifa->ifa_index, ifa->ifa_index, parm)))
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
if (inaddr && mac)
|
||||||
|
if (!((*callback)(neigh->ndm_family, inaddr, mac, maclen, parm)))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void netlink_multicast(void)
|
void netlink_multicast(void)
|
||||||
{
|
{
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
@@ -282,7 +305,7 @@ static void nl_routechange(struct nlmsghdr *h)
|
|||||||
|
|
||||||
/* Force re-reading resolv file right now, for luck. */
|
/* Force re-reading resolv file right now, for luck. */
|
||||||
daemon->last_resolv = 0;
|
daemon->last_resolv = 0;
|
||||||
|
|
||||||
if (daemon->srv_save)
|
if (daemon->srv_save)
|
||||||
{
|
{
|
||||||
if (daemon->srv_save->sfd)
|
if (daemon->srv_save->sfd)
|
||||||
|
|||||||
+348
-249
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -34,6 +34,67 @@ int indextoname(int fd, int index, char *name)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
|
|
||||||
|
#include <zone.h>
|
||||||
|
#include <alloca.h>
|
||||||
|
#ifndef LIFC_UNDER_IPMP
|
||||||
|
# define LIFC_UNDER_IPMP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int indextoname(int fd, int index, char *name)
|
||||||
|
{
|
||||||
|
int64_t lifc_flags;
|
||||||
|
struct lifnum lifn;
|
||||||
|
int numifs, bufsize, i;
|
||||||
|
struct lifconf lifc;
|
||||||
|
struct lifreq *lifrp;
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (getzoneid() == GLOBAL_ZONEID)
|
||||||
|
{
|
||||||
|
if (!if_indextoname(index, name))
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lifc_flags = LIFC_NOXMIT | LIFC_TEMPORARY | LIFC_ALLZONES | LIFC_UNDER_IPMP;
|
||||||
|
lifn.lifn_family = AF_UNSPEC;
|
||||||
|
lifn.lifn_flags = lifc_flags;
|
||||||
|
if (ioctl(fd, SIOCGLIFNUM, &lifn) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
numifs = lifn.lifn_count;
|
||||||
|
bufsize = numifs * sizeof(struct lifreq);
|
||||||
|
|
||||||
|
lifc.lifc_family = AF_UNSPEC;
|
||||||
|
lifc.lifc_flags = lifc_flags;
|
||||||
|
lifc.lifc_len = bufsize;
|
||||||
|
lifc.lifc_buf = alloca(bufsize);
|
||||||
|
|
||||||
|
if (ioctl(fd, SIOCGLIFCONF, &lifc) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
lifrp = lifc.lifc_req;
|
||||||
|
for (i = lifc.lifc_len / sizeof(struct lifreq); i; i--, lifrp++)
|
||||||
|
{
|
||||||
|
struct lifreq lifr;
|
||||||
|
strncpy(lifr.lifr_name, lifrp->lifr_name, IF_NAMESIZE);
|
||||||
|
if (ioctl(fd, SIOCGLIFINDEX, &lifr) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (lifr.lifr_index == index) {
|
||||||
|
strncpy(name, lifr.lifr_name, IF_NAMESIZE);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int indextoname(int fd, int index, char *name)
|
int indextoname(int fd, int index, char *name)
|
||||||
@@ -53,7 +114,44 @@ int iface_check(int family, struct all_addr *addr, char *name, int *indexp)
|
|||||||
|
|
||||||
/* Note: have to check all and not bail out early, so that we set the
|
/* Note: have to check all and not bail out early, so that we set the
|
||||||
"used" flags. */
|
"used" flags. */
|
||||||
|
|
||||||
|
if (daemon->if_names || (addr && daemon->if_addrs))
|
||||||
|
{
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
struct dhcp_context *range;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
for (range = daemon->dhcp; range; range = range->next)
|
||||||
|
if (range->interface && strcmp(range->interface, name) == 0)
|
||||||
|
ret = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (tmp = daemon->if_names; tmp; tmp = tmp->next)
|
||||||
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
|
ret = tmp->used = 1;
|
||||||
|
|
||||||
|
for (tmp = daemon->if_addrs; tmp; tmp = tmp->next)
|
||||||
|
if (addr && tmp->addr.sa.sa_family == family)
|
||||||
|
{
|
||||||
|
if (family == AF_INET &&
|
||||||
|
tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
|
||||||
|
ret = tmp->used = 1;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else if (family == AF_INET6 &&
|
||||||
|
IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr,
|
||||||
|
&addr->addr.addr6))
|
||||||
|
ret = tmp->used = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tmp = daemon->if_except; tmp; tmp = tmp->next)
|
||||||
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
if (indexp)
|
if (indexp)
|
||||||
{
|
{
|
||||||
/* One form of bridging on BSD has the property that packets
|
/* One form of bridging on BSD has the property that packets
|
||||||
@@ -85,33 +183,6 @@ int iface_check(int family, struct all_addr *addr, char *name, int *indexp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (daemon->if_names || (addr && daemon->if_addrs))
|
|
||||||
{
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
for (tmp = daemon->if_names; tmp; tmp = tmp->next)
|
|
||||||
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
|
||||||
ret = tmp->used = 1;
|
|
||||||
|
|
||||||
for (tmp = daemon->if_addrs; tmp; tmp = tmp->next)
|
|
||||||
if (addr && tmp->addr.sa.sa_family == family)
|
|
||||||
{
|
|
||||||
if (family == AF_INET &&
|
|
||||||
tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
|
|
||||||
ret = tmp->used = 1;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
else if (family == AF_INET6 &&
|
|
||||||
IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr,
|
|
||||||
&addr->addr.addr6))
|
|
||||||
ret = tmp->used = 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (tmp = daemon->if_except; tmp; tmp = tmp->next)
|
|
||||||
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +192,12 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
struct irec *iface;
|
struct irec *iface;
|
||||||
int fd, mtu = 0, loopback;
|
int fd, mtu = 0, loopback;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int dhcp_ok = 1;
|
int tftp_ok = daemon->tftp_unlimited;
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
|
#endif
|
||||||
|
struct interface_list *ir = NULL;
|
||||||
|
|
||||||
/* check whether the interface IP has been added already
|
/* check whether the interface IP has been added already
|
||||||
we call this routine multiple times. */
|
we call this routine multiple times. */
|
||||||
for (iface = *irecp; iface; iface = iface->next)
|
for (iface = *irecp; iface; iface = iface->next)
|
||||||
@@ -173,27 +247,44 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr->sa.sa_family == AF_INET &&
|
#ifdef HAVE_TFTP
|
||||||
!iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name, NULL))
|
/* implement wierd TFTP service rules */
|
||||||
return 1;
|
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
||||||
|
if (strcmp(ir->interface, ifr.ifr_name) == 0)
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
{
|
||||||
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
tftp_ok = 1;
|
||||||
dhcp_ok = 0;
|
break;
|
||||||
|
}
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (addr->sa.sa_family == AF_INET6 &&
|
|
||||||
!iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name, NULL))
|
|
||||||
return 1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!ir)
|
||||||
|
{
|
||||||
|
if (addr->sa.sa_family == AF_INET &&
|
||||||
|
!iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name, NULL))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
|
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
||||||
|
tftp_ok = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (addr->sa.sa_family == AF_INET6 &&
|
||||||
|
!iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name, NULL))
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* add to list */
|
/* add to list */
|
||||||
if ((iface = whine_malloc(sizeof(struct irec))))
|
if ((iface = whine_malloc(sizeof(struct irec))))
|
||||||
{
|
{
|
||||||
iface->addr = *addr;
|
iface->addr = *addr;
|
||||||
iface->netmask = netmask;
|
iface->netmask = netmask;
|
||||||
iface->dhcp_ok = dhcp_ok;
|
iface->tftp_ok = tftp_ok;
|
||||||
iface->mtu = mtu;
|
iface->mtu = mtu;
|
||||||
|
if ((iface->name = whine_malloc(strlen(ifr.ifr_name)+1)))
|
||||||
|
strcpy(iface->name, ifr.ifr_name);
|
||||||
iface->next = *irecp;
|
iface->next = *irecp;
|
||||||
*irecp = iface;
|
*irecp = iface;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -245,10 +336,11 @@ static int iface_allowed_v4(struct in_addr local, int if_index,
|
|||||||
int enumerate_interfaces(void)
|
int enumerate_interfaces(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
return iface_enumerate(&daemon->interfaces, iface_allowed_v4, iface_allowed_v6);
|
if (!iface_enumerate(AF_INET6, &daemon->interfaces, iface_allowed_v6))
|
||||||
#else
|
return 0;
|
||||||
return iface_enumerate(&daemon->interfaces, iface_allowed_v4, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return iface_enumerate(AF_INET, &daemon->interfaces, iface_allowed_v4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set NONBLOCK bit on fd: See Stevens 16.6 */
|
/* set NONBLOCK bit on fd: See Stevens 16.6 */
|
||||||
@@ -263,214 +355,207 @@ int fix_fd(int fd)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_IPV6)
|
static int make_sock(union mysockaddr *addr, int type)
|
||||||
static int create_ipv6_listener(struct listener **link, int port)
|
|
||||||
{
|
{
|
||||||
union mysockaddr addr;
|
int family = addr->sa.sa_family;
|
||||||
int tcpfd, fd;
|
int fd, rc, opt = 1;
|
||||||
struct listener *l;
|
#ifdef HAVE_IPV6
|
||||||
int opt = 1;
|
static int dad_count = 0;
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
|
||||||
addr.in6.sin6_family = AF_INET6;
|
|
||||||
addr.in6.sin6_addr = in6addr_any;
|
|
||||||
addr.in6.sin6_port = htons(port);
|
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
|
||||||
addr.in6.sin6_len = sizeof(addr.in6);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ((fd = socket(family, type, 0)) == -1)
|
||||||
|
{
|
||||||
|
int port;
|
||||||
|
|
||||||
/* No error of the kernel doesn't support IPv6 */
|
/* No error if the kernel just doesn't support this IP flavour */
|
||||||
if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
|
if (errno == EPROTONOSUPPORT ||
|
||||||
return (errno == EPROTONOSUPPORT ||
|
errno == EAFNOSUPPORT ||
|
||||||
errno == EAFNOSUPPORT ||
|
errno == EINVAL)
|
||||||
errno == EINVAL);
|
return -1;
|
||||||
|
|
||||||
if ((tcpfd = socket(AF_INET6, SOCK_STREAM, 0)) == -1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
|
err:
|
||||||
setsockopt(tcpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
|
port = prettyprint_addr(addr, daemon->namebuff);
|
||||||
setsockopt(fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
|
if (!option_bool(OPT_NOWILD))
|
||||||
setsockopt(tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
|
sprintf(daemon->namebuff, "port %d", port);
|
||||||
!fix_fd(fd) ||
|
die(_("failed to create listening socket for %s: %s"),
|
||||||
!fix_fd(tcpfd) ||
|
daemon->namebuff, EC_BADNET);
|
||||||
#ifdef IPV6_RECVPKTINFO
|
}
|
||||||
setsockopt(fd, IPV6_LEVEL, IPV6_RECVPKTINFO, &opt, sizeof(opt)) == -1 ||
|
|
||||||
#else
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 || !fix_fd(fd))
|
||||||
setsockopt(fd, IPV6_LEVEL, IPV6_PKTINFO, &opt, sizeof(opt)) == -1 ||
|
goto err;
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (family == AF_INET6 && setsockopt(fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1)
|
||||||
|
goto err;
|
||||||
#endif
|
#endif
|
||||||
bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 ||
|
|
||||||
listen(tcpfd, 5) == -1 ||
|
|
||||||
bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
l = safe_malloc(sizeof(struct listener));
|
|
||||||
l->fd = fd;
|
|
||||||
l->tcpfd = tcpfd;
|
|
||||||
l->tftpfd = -1;
|
|
||||||
l->family = AF_INET6;
|
|
||||||
l->next = NULL;
|
|
||||||
*link = l;
|
|
||||||
|
|
||||||
return 1;
|
while (1)
|
||||||
|
{
|
||||||
|
if ((rc = bind(fd, (struct sockaddr *)addr, sa_len(addr))) != -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
/* An interface may have an IPv6 address which is still undergoing DAD.
|
||||||
|
If so, the bind will fail until the DAD completes, so we try over 20 seconds
|
||||||
|
before failing. */
|
||||||
|
if (family == AF_INET6 &&
|
||||||
|
(errno == ENODEV || errno == EADDRNOTAVAIL) &&
|
||||||
|
dad_count++ < DAD_WAIT)
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc == -1)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (type == SOCK_STREAM)
|
||||||
|
{
|
||||||
|
if (listen(fd, 5) == -1)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
else if (!option_bool(OPT_NOWILD))
|
||||||
|
{
|
||||||
|
if (family == AF_INET)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
|
if (setsockopt(fd, SOL_IP, IP_PKTINFO, &opt, sizeof(opt)) == -1)
|
||||||
|
goto err;
|
||||||
|
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
||||||
|
if (setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, &opt, sizeof(opt)) == -1 ||
|
||||||
|
setsockopt(fd, IPPROTO_IP, IP_RECVIF, &opt, sizeof(opt)) == -1)
|
||||||
|
goto err;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The API changed around Linux 2.6.14 but the old ABI is still supported:
|
||||||
|
handle all combinations of headers and kernel.
|
||||||
|
OpenWrt note that this fixes the problem addressed by your very broken patch. */
|
||||||
|
daemon->v6pktinfo = IPV6_PKTINFO;
|
||||||
|
|
||||||
|
# ifdef IPV6_RECVPKTINFO
|
||||||
|
# ifdef IPV6_2292PKTINFO
|
||||||
|
if (setsockopt(fd, IPV6_LEVEL, IPV6_RECVPKTINFO, &opt, sizeof(opt)) == -1)
|
||||||
|
{
|
||||||
|
if (errno == ENOPROTOOPT && setsockopt(fd, IPV6_LEVEL, IPV6_2292PKTINFO, &opt, sizeof(opt)) != -1)
|
||||||
|
daemon->v6pktinfo = IPV6_2292PKTINFO;
|
||||||
|
else
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
if (setsockopt(fd, IPV6_LEVEL, IPV6_RECVPKTINFO, &opt, sizeof(opt)) == -1)
|
||||||
|
goto err;
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
if (setsockopt(fd, IPV6_LEVEL, IPV6_PKTINFO, &opt, sizeof(opt)) == -1)
|
||||||
|
goto err;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct listener *create_listeners(union mysockaddr *addr, int do_tftp)
|
||||||
|
{
|
||||||
|
struct listener *l = NULL;
|
||||||
|
int fd = -1, tcpfd = -1, tftpfd = -1;
|
||||||
|
|
||||||
|
if (daemon->port != 0)
|
||||||
|
{
|
||||||
|
fd = make_sock(addr, SOCK_DGRAM);
|
||||||
|
tcpfd = make_sock(addr, SOCK_STREAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TFTP
|
||||||
|
if (do_tftp)
|
||||||
|
{
|
||||||
|
if (addr->sa.sa_family == AF_INET)
|
||||||
|
{
|
||||||
|
/* port must be restored to DNS port for TCP code */
|
||||||
|
short save = addr->in.sin_port;
|
||||||
|
addr->in.sin_port = htons(TFTP_PORT);
|
||||||
|
tftpfd = make_sock(addr, SOCK_DGRAM);
|
||||||
|
addr->in.sin_port = save;
|
||||||
|
}
|
||||||
|
# ifdef HAVE_IPV6
|
||||||
|
else
|
||||||
|
{
|
||||||
|
short save = addr->in6.sin6_port;
|
||||||
|
addr->in6.sin6_port = htons(TFTP_PORT);
|
||||||
|
tftpfd = make_sock(addr, SOCK_DGRAM);
|
||||||
|
addr->in6.sin6_port = save;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (fd != -1 || tcpfd != -1 || tftpfd != -1)
|
||||||
|
{
|
||||||
|
l = safe_malloc(sizeof(struct listener));
|
||||||
|
l->next = NULL;
|
||||||
|
l->family = addr->sa.sa_family;
|
||||||
|
l->fd = fd;
|
||||||
|
l->tcpfd = tcpfd;
|
||||||
|
l->tftpfd = tftpfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
struct listener *create_wildcard_listeners(void)
|
struct listener *create_wildcard_listeners(void)
|
||||||
{
|
{
|
||||||
union mysockaddr addr;
|
union mysockaddr addr;
|
||||||
int opt = 1;
|
struct listener *l;
|
||||||
struct listener *l, *l6 = NULL;
|
int tftp_enabled = daemon->tftp_unlimited || daemon->tftp_interfaces;
|
||||||
int tcpfd = -1, fd = -1, tftpfd = -1;
|
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||||
|
addr.in.sin_len = sizeof(addr.in);
|
||||||
|
#endif
|
||||||
addr.in.sin_family = AF_INET;
|
addr.in.sin_family = AF_INET;
|
||||||
addr.in.sin_addr.s_addr = INADDR_ANY;
|
addr.in.sin_addr.s_addr = INADDR_ANY;
|
||||||
addr.in.sin_port = htons(daemon->port);
|
addr.in.sin_port = htons(daemon->port);
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
|
||||||
addr.in.sin_len = sizeof(struct sockaddr_in);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (daemon->port != 0)
|
l = create_listeners(&addr, tftp_enabled);
|
||||||
{
|
|
||||||
|
|
||||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ||
|
|
||||||
(tcpfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (setsockopt(tcpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
|
|
||||||
bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 ||
|
|
||||||
listen(tcpfd, 5) == -1 ||
|
|
||||||
!fix_fd(tcpfd) ||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
!create_ipv6_listener(&l6, daemon->port) ||
|
memset(&addr, 0, sizeof(addr));
|
||||||
#endif
|
# ifdef HAVE_SOCKADDR_SA_LEN
|
||||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
|
addr.in6.sin6_len = sizeof(addr.in6);
|
||||||
!fix_fd(fd) ||
|
# endif
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
addr.in6.sin6_family = AF_INET6;
|
||||||
setsockopt(fd, SOL_IP, IP_PKTINFO, &opt, sizeof(opt)) == -1 ||
|
addr.in6.sin6_addr = in6addr_any;
|
||||||
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
addr.in6.sin6_port = htons(daemon->port);
|
||||||
setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, &opt, sizeof(opt)) == -1 ||
|
|
||||||
setsockopt(fd, IPPROTO_IP, IP_RECVIF, &opt, sizeof(opt)) == -1 ||
|
|
||||||
#endif
|
|
||||||
bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_TFTP
|
if (l)
|
||||||
if (daemon->options & OPT_TFTP)
|
l->next = create_listeners(&addr, tftp_enabled);
|
||||||
{
|
else
|
||||||
addr.in.sin_port = htons(TFTP_PORT);
|
l = create_listeners(&addr, tftp_enabled);
|
||||||
if ((tftpfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!fix_fd(tftpfd) ||
|
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
|
||||||
setsockopt(tftpfd, SOL_IP, IP_PKTINFO, &opt, sizeof(opt)) == -1 ||
|
|
||||||
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
|
||||||
setsockopt(tftpfd, IPPROTO_IP, IP_RECVDSTADDR, &opt, sizeof(opt)) == -1 ||
|
|
||||||
setsockopt(tftpfd, IPPROTO_IP, IP_RECVIF, &opt, sizeof(opt)) == -1 ||
|
|
||||||
#endif
|
|
||||||
bind(tftpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
l = safe_malloc(sizeof(struct listener));
|
|
||||||
l->family = AF_INET;
|
|
||||||
l->fd = fd;
|
|
||||||
l->tcpfd = tcpfd;
|
|
||||||
l->tftpfd = tftpfd;
|
|
||||||
l->next = l6;
|
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct listener *create_bound_listeners(void)
|
struct listener *create_bound_listeners(void)
|
||||||
{
|
{
|
||||||
struct listener *listeners = NULL;
|
struct listener *new, *listeners = NULL;
|
||||||
struct irec *iface;
|
struct irec *iface;
|
||||||
int rc, opt = 1;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
static int dad_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (iface = daemon->interfaces; iface; iface = iface->next)
|
for (iface = daemon->interfaces; iface; iface = iface->next)
|
||||||
{
|
if ((new = create_listeners(&iface->addr, iface->tftp_ok)))
|
||||||
struct listener *new = safe_malloc(sizeof(struct listener));
|
{
|
||||||
new->family = iface->addr.sa.sa_family;
|
new->iface = iface;
|
||||||
new->iface = iface;
|
new->next = listeners;
|
||||||
new->next = listeners;
|
listeners = new;
|
||||||
new->tftpfd = -1;
|
}
|
||||||
new->tcpfd = -1;
|
|
||||||
new->fd = -1;
|
|
||||||
listeners = new;
|
|
||||||
|
|
||||||
if (daemon->port != 0)
|
|
||||||
{
|
|
||||||
if ((new->tcpfd = socket(iface->addr.sa.sa_family, SOCK_STREAM, 0)) == -1 ||
|
|
||||||
(new->fd = socket(iface->addr.sa.sa_family, SOCK_DGRAM, 0)) == -1 ||
|
|
||||||
setsockopt(new->fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
|
|
||||||
setsockopt(new->tcpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
|
|
||||||
!fix_fd(new->tcpfd) ||
|
|
||||||
!fix_fd(new->fd))
|
|
||||||
die(_("failed to create listening socket: %s"), NULL, EC_BADNET);
|
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (iface->addr.sa.sa_family == AF_INET6)
|
|
||||||
{
|
|
||||||
if (setsockopt(new->fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
|
|
||||||
setsockopt(new->tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1)
|
|
||||||
die(_("failed to set IPV6 options on listening socket: %s"), NULL, EC_BADNET);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
if ((rc = bind(new->fd, &iface->addr.sa, sa_len(&iface->addr))) != -1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
/* An interface may have an IPv6 address which is still undergoing DAD.
|
|
||||||
If so, the bind will fail until the DAD completes, so we try over 20 seconds
|
|
||||||
before failing. */
|
|
||||||
if (iface->addr.sa.sa_family == AF_INET6 && (errno == ENODEV || errno == EADDRNOTAVAIL) &&
|
|
||||||
dad_count++ < DAD_WAIT)
|
|
||||||
{
|
|
||||||
sleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc == -1 || bind(new->tcpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
|
|
||||||
{
|
|
||||||
prettyprint_addr(&iface->addr, daemon->namebuff);
|
|
||||||
die(_("failed to bind listening socket for %s: %s"),
|
|
||||||
daemon->namebuff, EC_BADNET);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen(new->tcpfd, 5) == -1)
|
|
||||||
die(_("failed to listen on socket: %s"), NULL, EC_BADNET);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_TFTP
|
|
||||||
if ((daemon->options & OPT_TFTP) && iface->addr.sa.sa_family == AF_INET && iface->dhcp_ok)
|
|
||||||
{
|
|
||||||
short save = iface->addr.in.sin_port;
|
|
||||||
iface->addr.in.sin_port = htons(TFTP_PORT);
|
|
||||||
if ((new->tftpfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ||
|
|
||||||
setsockopt(new->tftpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
|
|
||||||
!fix_fd(new->tftpfd) ||
|
|
||||||
bind(new->tftpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
|
|
||||||
die(_("failed to create TFTP socket: %s"), NULL, EC_BADNET);
|
|
||||||
iface->addr.in.sin_port = save;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return listeners;
|
return listeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +638,7 @@ int local_bind(int fd, union mysockaddr *addr, char *intname, int is_tcp)
|
|||||||
|
|
||||||
#if defined(SO_BINDTODEVICE)
|
#if defined(SO_BINDTODEVICE)
|
||||||
if (intname[0] != 0 &&
|
if (intname[0] != 0 &&
|
||||||
setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, intname, strlen(intname)) == -1)
|
setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, intname, IF_NAMESIZE) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -647,12 +732,12 @@ void pre_allocate_sfds(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (srv = daemon->servers; srv; srv = srv->next)
|
for (srv = daemon->servers; srv; srv = srv->next)
|
||||||
if (!(srv->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR)) &&
|
if (!(srv->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND)) &&
|
||||||
!allocate_sfd(&srv->source_addr, srv->interface) &&
|
!allocate_sfd(&srv->source_addr, srv->interface) &&
|
||||||
errno != 0 &&
|
errno != 0 &&
|
||||||
(daemon->options & OPT_NOWILD))
|
option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
prettyprint_addr(&srv->addr, daemon->namebuff);
|
prettyprint_addr(&srv->source_addr, daemon->namebuff);
|
||||||
if (srv->interface[0] != 0)
|
if (srv->interface[0] != 0)
|
||||||
{
|
{
|
||||||
strcat(daemon->namebuff, " ");
|
strcat(daemon->namebuff, " ");
|
||||||
@@ -670,11 +755,15 @@ void check_servers(void)
|
|||||||
struct server *new, *tmp, *ret = NULL;
|
struct server *new, *tmp, *ret = NULL;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
|
||||||
|
/* interface may be new since startup */
|
||||||
|
if (!option_bool(OPT_NOWILD))
|
||||||
|
enumerate_interfaces();
|
||||||
|
|
||||||
for (new = daemon->servers; new; new = tmp)
|
for (new = daemon->servers; new; new = tmp)
|
||||||
{
|
{
|
||||||
tmp = new->next;
|
tmp = new->next;
|
||||||
|
|
||||||
if (!(new->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR)))
|
if (!(new->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND)))
|
||||||
{
|
{
|
||||||
port = prettyprint_addr(&new->addr, daemon->namebuff);
|
port = prettyprint_addr(&new->addr, daemon->namebuff);
|
||||||
|
|
||||||
@@ -713,25 +802,30 @@ void check_servers(void)
|
|||||||
new->next = ret;
|
new->next = ret;
|
||||||
ret = new;
|
ret = new;
|
||||||
|
|
||||||
if (new->flags & (SERV_HAS_DOMAIN | SERV_FOR_NODOTS))
|
if (!(new->flags & SERV_NO_REBIND))
|
||||||
{
|
{
|
||||||
char *s1, *s2;
|
if (new->flags & (SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_USE_RESOLV))
|
||||||
if (!(new->flags & SERV_HAS_DOMAIN))
|
{
|
||||||
s1 = _("unqualified"), s2 = _("names");
|
char *s1, *s2;
|
||||||
else if (strlen(new->domain) == 0)
|
if (!(new->flags & SERV_HAS_DOMAIN))
|
||||||
s1 = _("default"), s2 = "";
|
s1 = _("unqualified"), s2 = _("names");
|
||||||
|
else if (strlen(new->domain) == 0)
|
||||||
|
s1 = _("default"), s2 = "";
|
||||||
|
else
|
||||||
|
s1 = _("domain"), s2 = new->domain;
|
||||||
|
|
||||||
|
if (new->flags & SERV_NO_ADDR)
|
||||||
|
my_syslog(LOG_INFO, _("using local addresses only for %s %s"), s1, s2);
|
||||||
|
else if (new->flags & SERV_USE_RESOLV)
|
||||||
|
my_syslog(LOG_INFO, _("using standard nameservers for %s %s"), s1, s2);
|
||||||
|
else if (!(new->flags & SERV_LITERAL_ADDRESS))
|
||||||
|
my_syslog(LOG_INFO, _("using nameserver %s#%d for %s %s"), daemon->namebuff, port, s1, s2);
|
||||||
|
}
|
||||||
|
else if (new->interface[0] != 0)
|
||||||
|
my_syslog(LOG_INFO, _("using nameserver %s#%d(via %s)"), daemon->namebuff, port, new->interface);
|
||||||
else
|
else
|
||||||
s1 = _("domain"), s2 = new->domain;
|
my_syslog(LOG_INFO, _("using nameserver %s#%d"), daemon->namebuff, port);
|
||||||
|
|
||||||
if (new->flags & SERV_NO_ADDR)
|
|
||||||
my_syslog(LOG_INFO, _("using local addresses only for %s %s"), s1, s2);
|
|
||||||
else if (!(new->flags & SERV_LITERAL_ADDRESS))
|
|
||||||
my_syslog(LOG_INFO, _("using nameserver %s#%d for %s %s"), daemon->namebuff, port, s1, s2);
|
|
||||||
}
|
}
|
||||||
else if (new->interface[0] != 0)
|
|
||||||
my_syslog(LOG_INFO, _("using nameserver %s#%d(via %s)"), daemon->namebuff, port, new->interface);
|
|
||||||
else
|
|
||||||
my_syslog(LOG_INFO, _("using nameserver %s#%d"), daemon->namebuff, port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
daemon->servers = ret;
|
daemon->servers = ret;
|
||||||
@@ -858,16 +952,21 @@ struct in_addr get_ifaddr(char *intr)
|
|||||||
{
|
{
|
||||||
struct listener *l;
|
struct listener *l;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
struct sockaddr_in ret;
|
||||||
|
|
||||||
|
ret.sin_addr.s_addr = -1;
|
||||||
|
|
||||||
for (l = daemon->listeners; l && l->family != AF_INET; l = l->next);
|
for (l = daemon->listeners;
|
||||||
|
l && (l->family != AF_INET || l->fd == -1);
|
||||||
|
l = l->next);
|
||||||
|
|
||||||
strncpy(ifr.ifr_name, intr, IF_NAMESIZE);
|
strncpy(ifr.ifr_name, intr, IF_NAMESIZE);
|
||||||
ifr.ifr_addr.sa_family = AF_INET;
|
ifr.ifr_addr.sa_family = AF_INET;
|
||||||
|
|
||||||
if (!l || ioctl(l->fd, SIOCGIFADDR, &ifr) == -1)
|
if (l && ioctl(l->fd, SIOCGIFADDR, &ifr) != -1)
|
||||||
((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = -1;
|
memcpy(&ret, &ifr.ifr_addr, sizeof(ret));
|
||||||
|
|
||||||
return ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
|
return ret.sin_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+714
-299
File diff suppressed because it is too large.
Load diff
+256
-55
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -510,29 +510,148 @@ unsigned char *find_pseudoheader(HEADER *header, size_t plen, size_t *len, unsi
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct macparm {
|
||||||
|
unsigned char *limit;
|
||||||
|
HEADER *header;
|
||||||
|
size_t plen;
|
||||||
|
union mysockaddr *l3;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int filter_mac(int family, char *addrp, char *mac, size_t maclen, void *parmv)
|
||||||
|
{
|
||||||
|
struct macparm *parm = parmv;
|
||||||
|
int match = 0;
|
||||||
|
unsigned short rdlen;
|
||||||
|
HEADER *header = parm->header;
|
||||||
|
unsigned char *lenp, *datap, *p;
|
||||||
|
|
||||||
|
if (family == parm->l3->sa.sa_family)
|
||||||
|
{
|
||||||
|
if (family == AF_INET && memcmp (&parm->l3->in.sin_addr, addrp, INADDRSZ) == 0)
|
||||||
|
match = 1;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else
|
||||||
|
if (family == AF_INET6 && memcmp (&parm->l3->in6.sin6_addr, addrp, IN6ADDRSZ) == 0)
|
||||||
|
match = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!match)
|
||||||
|
return 1; /* continue */
|
||||||
|
|
||||||
|
if (ntohs(header->arcount) == 0)
|
||||||
|
{
|
||||||
|
/* We are adding the pseudoheader */
|
||||||
|
if (!(p = skip_questions(header, parm->plen)) ||
|
||||||
|
!(p = skip_section(p,
|
||||||
|
ntohs(header->ancount) + ntohs(header->nscount),
|
||||||
|
header, parm->plen)))
|
||||||
|
return 0;
|
||||||
|
*p++ = 0; /* empty name */
|
||||||
|
PUTSHORT(T_OPT, p);
|
||||||
|
PUTSHORT(PACKETSZ, p); /* max packet length - is 512 suitable default for non-EDNS0 resolvers? */
|
||||||
|
PUTLONG(0, p); /* extended RCODE */
|
||||||
|
lenp = p;
|
||||||
|
PUTSHORT(0, p); /* RDLEN */
|
||||||
|
rdlen = 0;
|
||||||
|
if (((ssize_t)maclen) > (parm->limit - (p + 4)))
|
||||||
|
return 0; /* Too big */
|
||||||
|
header->arcount = htons(1);
|
||||||
|
datap = p;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i, is_sign;
|
||||||
|
unsigned short code, len;
|
||||||
|
|
||||||
|
if (ntohs(header->arcount) != 1 ||
|
||||||
|
!(p = find_pseudoheader(header, parm->plen, NULL, NULL, &is_sign)) ||
|
||||||
|
is_sign ||
|
||||||
|
(!(p = skip_name(p, header, parm->plen, 10))))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
p += 8; /* skip UDP length and RCODE */
|
||||||
|
|
||||||
|
lenp = p;
|
||||||
|
GETSHORT(rdlen, p);
|
||||||
|
if (!CHECK_LEN(header, p, parm->plen, rdlen))
|
||||||
|
return 0; /* bad packet */
|
||||||
|
datap = p;
|
||||||
|
|
||||||
|
/* check if option already there */
|
||||||
|
for (i = 0; i + 4 < rdlen; i += len + 4)
|
||||||
|
{
|
||||||
|
GETSHORT(code, p);
|
||||||
|
GETSHORT(len, p);
|
||||||
|
if (code == EDNS0_OPTION_MAC)
|
||||||
|
return 0;
|
||||||
|
p += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((ssize_t)maclen) > (parm->limit - (p + 4)))
|
||||||
|
return 0; /* Too big */
|
||||||
|
}
|
||||||
|
|
||||||
|
PUTSHORT(EDNS0_OPTION_MAC, p);
|
||||||
|
PUTSHORT(maclen, p);
|
||||||
|
memcpy(p, mac, maclen);
|
||||||
|
p += maclen;
|
||||||
|
|
||||||
|
PUTSHORT(p - datap, lenp);
|
||||||
|
parm->plen = p - (unsigned char *)header;
|
||||||
|
|
||||||
|
return 0; /* done */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t add_mac(HEADER *header, size_t plen, char *limit, union mysockaddr *l3)
|
||||||
|
{
|
||||||
|
struct macparm parm;
|
||||||
|
|
||||||
|
/* Must have an existing pseudoheader as the only ar-record,
|
||||||
|
or have no ar-records. Must also not be signed */
|
||||||
|
|
||||||
|
if (ntohs(header->arcount) > 1)
|
||||||
|
return plen;
|
||||||
|
|
||||||
|
parm.header = header;
|
||||||
|
parm.limit = (unsigned char *)limit;
|
||||||
|
parm.plen = plen;
|
||||||
|
parm.l3 = l3;
|
||||||
|
|
||||||
|
iface_enumerate(AF_UNSPEC, &parm, filter_mac);
|
||||||
|
|
||||||
|
return parm.plen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* is addr in the non-globally-routed IP space? */
|
/* is addr in the non-globally-routed IP space? */
|
||||||
static int private_net(struct in_addr addr)
|
static int private_net(struct in_addr addr, int ban_localhost)
|
||||||
{
|
{
|
||||||
in_addr_t ip_addr = ntohl(addr.s_addr);
|
in_addr_t ip_addr = ntohl(addr.s_addr);
|
||||||
|
|
||||||
return
|
return
|
||||||
((ip_addr & 0xFF000000) == 0x7F000000) /* 127.0.0.0/8 (loopback) */ ||
|
(((ip_addr & 0xFF000000) == 0x7F000000) && ban_localhost) /* 127.0.0.0/8 (loopback) */ ||
|
||||||
((ip_addr & 0xFFFF0000) == 0xC0A80000) /* 192.168.0.0/16 (private) */ ||
|
((ip_addr & 0xFFFF0000) == 0xC0A80000) /* 192.168.0.0/16 (private) */ ||
|
||||||
((ip_addr & 0xFF000000) == 0x0A000000) /* 10.0.0.0/8 (private) */ ||
|
((ip_addr & 0xFF000000) == 0x0A000000) /* 10.0.0.0/8 (private) */ ||
|
||||||
((ip_addr & 0xFFF00000) == 0xAC100000) /* 172.16.0.0/12 (private) */ ||
|
((ip_addr & 0xFFF00000) == 0xAC100000) /* 172.16.0.0/12 (private) */ ||
|
||||||
((ip_addr & 0xFFFF0000) == 0xA9FE0000) /* 169.254.0.0/16 (zeroconf) */ ;
|
((ip_addr & 0xFFFF0000) == 0xA9FE0000) /* 169.254.0.0/16 (zeroconf) */ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *do_doctor(unsigned char *p, int count, HEADER *header, size_t qlen)
|
static unsigned char *do_doctor(unsigned char *p, int count, HEADER *header, size_t qlen, char *name)
|
||||||
{
|
{
|
||||||
int i, qtype, qclass, rdlen;
|
int i, qtype, qclass, rdlen;
|
||||||
unsigned long ttl;
|
unsigned long ttl;
|
||||||
|
|
||||||
for (i = count; i != 0; i--)
|
for (i = count; i != 0; i--)
|
||||||
{
|
{
|
||||||
if (!(p = skip_name(p, header, qlen, 10)))
|
if (name && option_bool(OPT_LOG))
|
||||||
|
{
|
||||||
|
if (!extract_name(header, qlen, &p, name, 1, 10))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (!(p = skip_name(p, header, qlen, 10)))
|
||||||
return 0; /* bad packet */
|
return 0; /* bad packet */
|
||||||
|
|
||||||
GETSHORT(qtype, p);
|
GETSHORT(qtype, p);
|
||||||
@@ -540,15 +659,15 @@ static unsigned char *do_doctor(unsigned char *p, int count, HEADER *header, siz
|
|||||||
GETLONG(ttl, p);
|
GETLONG(ttl, p);
|
||||||
GETSHORT(rdlen, p);
|
GETSHORT(rdlen, p);
|
||||||
|
|
||||||
if ((qclass == C_IN) && (qtype == T_A))
|
if (qclass == C_IN && qtype == T_A)
|
||||||
{
|
{
|
||||||
struct doctor *doctor;
|
struct doctor *doctor;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
if (!CHECK_LEN(header, p, qlen, INADDRSZ))
|
if (!CHECK_LEN(header, p, qlen, INADDRSZ))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* alignment */
|
/* alignment */
|
||||||
memcpy(&addr, p, INADDRSZ);
|
memcpy(&addr, p, INADDRSZ);
|
||||||
|
|
||||||
for (doctor = daemon->doctors; doctor; doctor = doctor->next)
|
for (doctor = daemon->doctors; doctor; doctor = doctor->next)
|
||||||
@@ -561,7 +680,7 @@ static unsigned char *do_doctor(unsigned char *p, int count, HEADER *header, siz
|
|||||||
else if (ntohl(doctor->in.s_addr) > ntohl(addr.s_addr) ||
|
else if (ntohl(doctor->in.s_addr) > ntohl(addr.s_addr) ||
|
||||||
ntohl(doctor->end.s_addr) < ntohl(addr.s_addr))
|
ntohl(doctor->end.s_addr) < ntohl(addr.s_addr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
addr.s_addr &= ~doctor->mask.s_addr;
|
addr.s_addr &= ~doctor->mask.s_addr;
|
||||||
addr.s_addr |= (doctor->out.s_addr & doctor->mask.s_addr);
|
addr.s_addr |= (doctor->out.s_addr & doctor->mask.s_addr);
|
||||||
/* Since we munged the data, the server it came from is no longer authoritative */
|
/* Since we munged the data, the server it came from is no longer authoritative */
|
||||||
@@ -570,6 +689,30 @@ static unsigned char *do_doctor(unsigned char *p, int count, HEADER *header, siz
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (qtype == T_TXT && name && option_bool(OPT_LOG))
|
||||||
|
{
|
||||||
|
unsigned char *p1 = p;
|
||||||
|
if (!CHECK_LEN(header, p1, qlen, rdlen))
|
||||||
|
return 0;
|
||||||
|
while ((p1 - p) < rdlen)
|
||||||
|
{
|
||||||
|
unsigned int i, len = *p1;
|
||||||
|
unsigned char *p2 = p1;
|
||||||
|
/* make counted string zero-term and sanitise */
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
if (isprint(*(p2+1)))
|
||||||
|
{
|
||||||
|
*p2 = *(p2+1);
|
||||||
|
p2++;
|
||||||
|
}
|
||||||
|
*p2 = 0;
|
||||||
|
my_syslog(LOG_INFO, "reply %s is %s", name, p1);
|
||||||
|
/* restore */
|
||||||
|
memmove(p1 + 1, p1, len);
|
||||||
|
*p1 = len;
|
||||||
|
p1 += len+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!ADD_RDLEN(header, p, qlen, rdlen))
|
if (!ADD_RDLEN(header, p, qlen, rdlen))
|
||||||
return 0; /* bad packet */
|
return 0; /* bad packet */
|
||||||
@@ -578,7 +721,7 @@ static unsigned char *do_doctor(unsigned char *p, int count, HEADER *header, siz
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_soa(HEADER *header, size_t qlen)
|
static int find_soa(HEADER *header, size_t qlen, char *name)
|
||||||
{
|
{
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
int qtype, qclass, rdlen;
|
int qtype, qclass, rdlen;
|
||||||
@@ -587,7 +730,7 @@ static int find_soa(HEADER *header, size_t qlen)
|
|||||||
|
|
||||||
/* first move to NS section and find TTL from any SOA section */
|
/* first move to NS section and find TTL from any SOA section */
|
||||||
if (!(p = skip_questions(header, qlen)) ||
|
if (!(p = skip_questions(header, qlen)) ||
|
||||||
!(p = do_doctor(p, ntohs(header->ancount), header, qlen)))
|
!(p = do_doctor(p, ntohs(header->ancount), header, qlen, name)))
|
||||||
return 0; /* bad packet */
|
return 0; /* bad packet */
|
||||||
|
|
||||||
for (i = ntohs(header->nscount); i != 0; i--)
|
for (i = ntohs(header->nscount); i != 0; i--)
|
||||||
@@ -623,7 +766,7 @@ static int find_soa(HEADER *header, size_t qlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* rewrite addresses in additioal section too */
|
/* rewrite addresses in additioal section too */
|
||||||
if (!do_doctor(p, ntohs(header->arcount), header, qlen))
|
if (!do_doctor(p, ntohs(header->arcount), header, qlen, NULL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!found_soa)
|
if (!found_soa)
|
||||||
@@ -635,8 +778,9 @@ static int find_soa(HEADER *header, size_t qlen)
|
|||||||
/* Note that the following code can create CNAME chains that don't point to a real record,
|
/* Note that the following code can create CNAME chains that don't point to a real record,
|
||||||
either because of lack of memory, or lack of SOA records. These are treated by the cache code as
|
either because of lack of memory, or lack of SOA records. These are treated by the cache code as
|
||||||
expired and cleaned out that way.
|
expired and cleaned out that way.
|
||||||
Return 1 if we reject an address because it look like parct of dns-rebinding attack. */
|
Return 1 if we reject an address because it look like part of dns-rebinding attack. */
|
||||||
int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now,
|
||||||
|
int is_sign, int check_rebind, int checking_disabled)
|
||||||
{
|
{
|
||||||
unsigned char *p, *p1, *endrr, *namep;
|
unsigned char *p, *p1, *endrr, *namep;
|
||||||
int i, j, qtype, qclass, aqtype, aqclass, ardlen, res, searched_soa = 0;
|
int i, j, qtype, qclass, aqtype, aqclass, ardlen, res, searched_soa = 0;
|
||||||
@@ -645,11 +789,11 @@ int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
|||||||
|
|
||||||
cache_start_insert();
|
cache_start_insert();
|
||||||
|
|
||||||
/* find_soa is needed for dns_doctor side-effects, so don't call it lazily if there are any. */
|
/* find_soa is needed for dns_doctor and logging side-effects, so don't call it lazily if there are any. */
|
||||||
if (daemon->doctors)
|
if (daemon->doctors || option_bool(OPT_LOG))
|
||||||
{
|
{
|
||||||
searched_soa = 1;
|
searched_soa = 1;
|
||||||
ttl = find_soa(header, qlen);
|
ttl = find_soa(header, qlen, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* go through the questions. */
|
/* go through the questions. */
|
||||||
@@ -698,6 +842,11 @@ int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
|||||||
GETSHORT(aqtype, p1);
|
GETSHORT(aqtype, p1);
|
||||||
GETSHORT(aqclass, p1);
|
GETSHORT(aqclass, p1);
|
||||||
GETLONG(attl, p1);
|
GETLONG(attl, p1);
|
||||||
|
if ((daemon->max_ttl != 0) && (attl > daemon->max_ttl) && !is_sign)
|
||||||
|
{
|
||||||
|
(p1) -= NS_INT32SZ;
|
||||||
|
PUTLONG(daemon->max_ttl, p1);
|
||||||
|
}
|
||||||
GETSHORT(ardlen, p1);
|
GETSHORT(ardlen, p1);
|
||||||
endrr = p1+ardlen;
|
endrr = p1+ardlen;
|
||||||
|
|
||||||
@@ -727,12 +876,12 @@ int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && !(daemon->options & OPT_NO_NEG))
|
if (!found && !option_bool(OPT_NO_NEG))
|
||||||
{
|
{
|
||||||
if (!searched_soa)
|
if (!searched_soa)
|
||||||
{
|
{
|
||||||
searched_soa = 1;
|
searched_soa = 1;
|
||||||
ttl = find_soa(header, qlen);
|
ttl = find_soa(header, qlen, NULL);
|
||||||
}
|
}
|
||||||
if (ttl)
|
if (ttl)
|
||||||
cache_insert(NULL, &addr, now, ttl, name_encoding | F_REVERSE | F_NEG | flags);
|
cache_insert(NULL, &addr, now, ttl, name_encoding | F_REVERSE | F_NEG | flags);
|
||||||
@@ -773,6 +922,11 @@ int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
|||||||
GETSHORT(aqtype, p1);
|
GETSHORT(aqtype, p1);
|
||||||
GETSHORT(aqclass, p1);
|
GETSHORT(aqclass, p1);
|
||||||
GETLONG(attl, p1);
|
GETLONG(attl, p1);
|
||||||
|
if ((daemon->max_ttl != 0) && (attl > daemon->max_ttl) && !is_sign)
|
||||||
|
{
|
||||||
|
(p1) -= NS_INT32SZ;
|
||||||
|
PUTLONG(daemon->max_ttl, p1);
|
||||||
|
}
|
||||||
GETSHORT(ardlen, p1);
|
GETSHORT(ardlen, p1);
|
||||||
endrr = p1+ardlen;
|
endrr = p1+ardlen;
|
||||||
|
|
||||||
@@ -807,9 +961,9 @@ int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
|||||||
memcpy(&addr, p1, addrlen);
|
memcpy(&addr, p1, addrlen);
|
||||||
|
|
||||||
/* check for returned address in private space */
|
/* check for returned address in private space */
|
||||||
if ((daemon->options & OPT_NO_REBIND) &&
|
if (check_rebind &&
|
||||||
(flags & F_IPV4) &&
|
(flags & F_IPV4) &&
|
||||||
private_net(addr.addr.addr4))
|
private_net(addr.addr.addr4, !option_bool(OPT_LOCAL_REBIND)))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
newc = cache_insert(name, &addr, now, attl, flags | F_FORWARD);
|
newc = cache_insert(name, &addr, now, attl, flags | F_FORWARD);
|
||||||
@@ -828,12 +982,12 @@ int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && !(daemon->options & OPT_NO_NEG))
|
if (!found && !option_bool(OPT_NO_NEG))
|
||||||
{
|
{
|
||||||
if (!searched_soa)
|
if (!searched_soa)
|
||||||
{
|
{
|
||||||
searched_soa = 1;
|
searched_soa = 1;
|
||||||
ttl = find_soa(header, qlen);
|
ttl = find_soa(header, qlen, NULL);
|
||||||
}
|
}
|
||||||
/* If there's no SOA to get the TTL from, but there is a CNAME
|
/* If there's no SOA to get the TTL from, but there is a CNAME
|
||||||
pointing at this, inherit its TTL */
|
pointing at this, inherit its TTL */
|
||||||
@@ -850,18 +1004,19 @@ int extract_addresses(HEADER *header, size_t qlen, char *name, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't put stuff from a truncated packet into the cache, but do everything else */
|
/* Don't put stuff from a truncated packet into the cache,
|
||||||
if (!header->tc)
|
also don't cache replies where DNSSEC validation was turned off, either
|
||||||
|
the upstream server told us so, or the original query specified it. */
|
||||||
|
if (!header->tc && !header->cd && !checking_disabled)
|
||||||
cache_end_insert();
|
cache_end_insert();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the packet holds exactly one query
|
/* If the packet holds exactly one query
|
||||||
return F_IPV4 or F_IPV6 and leave the name from the query in name.
|
return F_IPV4 or F_IPV6 and leave the name from the query in name */
|
||||||
Abuse F_BIGNAME to indicate an NS query - yuck. */
|
|
||||||
|
|
||||||
unsigned short extract_request(HEADER *header, size_t qlen, char *name, unsigned short *typep)
|
unsigned int extract_request(HEADER *header, size_t qlen, char *name, unsigned short *typep)
|
||||||
{
|
{
|
||||||
unsigned char *p = (unsigned char *)(header+1);
|
unsigned char *p = (unsigned char *)(header+1);
|
||||||
int qtype, qclass;
|
int qtype, qclass;
|
||||||
@@ -890,7 +1045,7 @@ unsigned short extract_request(HEADER *header, size_t qlen, char *name, unsigned
|
|||||||
if (qtype == T_ANY)
|
if (qtype == T_ANY)
|
||||||
return F_IPV4 | F_IPV6;
|
return F_IPV4 | F_IPV6;
|
||||||
if (qtype == T_NS || qtype == T_SOA)
|
if (qtype == T_NS || qtype == T_SOA)
|
||||||
return F_QUERY | F_BIGNAME;
|
return F_QUERY | F_NSRR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return F_QUERY;
|
return F_QUERY;
|
||||||
@@ -898,7 +1053,7 @@ unsigned short extract_request(HEADER *header, size_t qlen, char *name, unsigned
|
|||||||
|
|
||||||
|
|
||||||
size_t setup_reply(HEADER *header, size_t qlen,
|
size_t setup_reply(HEADER *header, size_t qlen,
|
||||||
struct all_addr *addrp, unsigned short flags, unsigned long ttl)
|
struct all_addr *addrp, unsigned int flags, unsigned long ttl)
|
||||||
{
|
{
|
||||||
unsigned char *p = skip_questions(header, qlen);
|
unsigned char *p = skip_questions(header, qlen);
|
||||||
|
|
||||||
@@ -1120,7 +1275,11 @@ static unsigned long crec_ttl(struct crec *crecp, time_t now)
|
|||||||
if (crecp->flags & (F_IMMORTAL | F_DHCP))
|
if (crecp->flags & (F_IMMORTAL | F_DHCP))
|
||||||
return daemon->local_ttl;
|
return daemon->local_ttl;
|
||||||
|
|
||||||
return crecp->ttd - now;
|
/* Return the Max TTL value if it is lower then the actual TTL */
|
||||||
|
if (daemon->max_ttl == 0 || ((unsigned)(crecp->ttd - now) < daemon->max_ttl))
|
||||||
|
return crecp->ttd - now;
|
||||||
|
else
|
||||||
|
return daemon->max_ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1206,7 +1365,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
ans = 1;
|
ans = 1;
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
log_query(F_CNAME | F_FORWARD | F_CONFIG | F_NXDOMAIN, name, NULL, "<TXT>");
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>");
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
daemon->local_ttl, NULL,
|
daemon->local_ttl, NULL,
|
||||||
T_TXT, t->class, "t", t->len, t->txt))
|
T_TXT, t->class, "t", t->len, t->txt))
|
||||||
@@ -1257,7 +1416,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
ans = 1;
|
ans = 1;
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
log_query(F_CNAME | F_FORWARD | F_CONFIG | F_NXDOMAIN, name, NULL, "<PTR>");
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<PTR>");
|
||||||
for (ptr = daemon->ptr; ptr; ptr = ptr->next)
|
for (ptr = daemon->ptr; ptr; ptr = ptr->next)
|
||||||
if (hostname_isequal(name, ptr->name) &&
|
if (hostname_isequal(name, ptr->name) &&
|
||||||
add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
@@ -1301,8 +1460,8 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
}
|
}
|
||||||
} while ((crecp = cache_find_by_addr(crecp, &addr, now, is_arpa)));
|
} while ((crecp = cache_find_by_addr(crecp, &addr, now, is_arpa)));
|
||||||
else if (is_arpa == F_IPV4 &&
|
else if (is_arpa == F_IPV4 &&
|
||||||
(daemon->options & OPT_BOGUSPRIV) &&
|
option_bool(OPT_BOGUSPRIV) &&
|
||||||
private_net(addr.addr.addr4))
|
private_net(addr.addr.addr4, 1))
|
||||||
{
|
{
|
||||||
/* if not in cache, enabled and private IPV4 address, return NXDOMAIN */
|
/* if not in cache, enabled and private IPV4 address, return NXDOMAIN */
|
||||||
ans = 1;
|
ans = 1;
|
||||||
@@ -1327,18 +1486,41 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
if (qtype != type && qtype != T_ANY)
|
if (qtype != type && qtype != T_ANY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Check for "A for A" queries */
|
/* Check for "A for A" queries; be rather conservative
|
||||||
if (qtype == T_A && (addr.addr.addr4.s_addr = inet_addr(name)) != (in_addr_t) -1)
|
about what looks like dotted-quad. */
|
||||||
|
if (qtype == T_A)
|
||||||
{
|
{
|
||||||
ans = 1;
|
char *cp;
|
||||||
if (!dryrun)
|
unsigned int i, a;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
for (cp = name, i = 0, a = 0; *cp; i++)
|
||||||
{
|
{
|
||||||
log_query(F_FORWARD | F_CONFIG | F_IPV4, name, &addr, NULL);
|
if (!isdigit(*cp) || (x = strtol(cp, &cp, 10)) > 255)
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
{
|
||||||
daemon->local_ttl, NULL, type, C_IN, "4", &addr))
|
i = 5;
|
||||||
anscount++;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
a = (a << 8) + x;
|
||||||
|
|
||||||
|
if (*cp == '.')
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 4)
|
||||||
|
{
|
||||||
|
ans = 1;
|
||||||
|
if (!dryrun)
|
||||||
|
{
|
||||||
|
addr.addr.addr4.s_addr = htonl(a);
|
||||||
|
log_query(F_FORWARD | F_CONFIG | F_IPV4, name, &addr, NULL);
|
||||||
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
daemon->local_ttl, NULL, type, C_IN, "4", &addr))
|
||||||
|
anscount++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* interface name stuff */
|
/* interface name stuff */
|
||||||
@@ -1376,7 +1558,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
|
|
||||||
/* See if a putative address is on the network from which we recieved
|
/* See if a putative address is on the network from which we recieved
|
||||||
the query, is so we'll filter other answers. */
|
the query, is so we'll filter other answers. */
|
||||||
if (local_addr.s_addr != 0 && (daemon->options & OPT_LOCALISE) && flag == F_IPV4)
|
if (local_addr.s_addr != 0 && option_bool(OPT_LOCALISE) && flag == F_IPV4)
|
||||||
{
|
{
|
||||||
struct crec *save = crecp;
|
struct crec *save = crecp;
|
||||||
do {
|
do {
|
||||||
@@ -1459,7 +1641,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
log_query(F_CNAME | F_FORWARD | F_CONFIG | F_NXDOMAIN, name, NULL, "<MX>");
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
||||||
&offset, T_MX, C_IN, "sd", rec->weight, rec->target))
|
&offset, T_MX, C_IN, "sd", rec->weight, rec->target))
|
||||||
{
|
{
|
||||||
@@ -1470,16 +1652,16 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found && (daemon->options & (OPT_SELFMX | OPT_LOCALMX)) &&
|
if (!found && (option_bool(OPT_SELFMX) || option_bool(OPT_LOCALMX)) &&
|
||||||
cache_find_by_name(NULL, name, now, F_HOSTS | F_DHCP))
|
cache_find_by_name(NULL, name, now, F_HOSTS | F_DHCP))
|
||||||
{
|
{
|
||||||
ans = 1;
|
ans = 1;
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
log_query(F_CNAME | F_FORWARD | F_CONFIG | F_NXDOMAIN, name, NULL, "<MX>");
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl, NULL,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl, NULL,
|
||||||
T_MX, C_IN, "sd", 1,
|
T_MX, C_IN, "sd", 1,
|
||||||
(daemon->options & OPT_SELFMX) ? name : daemon->mxtarget))
|
option_bool(OPT_SELFMX) ? name : daemon->mxtarget))
|
||||||
anscount++;
|
anscount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1488,7 +1670,8 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
if (qtype == T_SRV || qtype == T_ANY)
|
if (qtype == T_SRV || qtype == T_ANY)
|
||||||
{
|
{
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
struct mx_srv_record *move = NULL, **up = &daemon->mxnames;
|
||||||
|
|
||||||
for (rec = daemon->mxnames; rec; rec = rec->next)
|
for (rec = daemon->mxnames; rec; rec = rec->next)
|
||||||
if (rec->issrv && hostname_isequal(name, rec->name))
|
if (rec->issrv && hostname_isequal(name, rec->name))
|
||||||
{
|
{
|
||||||
@@ -1496,7 +1679,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
log_query(F_CNAME | F_FORWARD | F_CONFIG | F_NXDOMAIN, name, NULL, "<SRV>");
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<SRV>");
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
||||||
&offset, T_SRV, C_IN, "sssd",
|
&offset, T_SRV, C_IN, "sssd",
|
||||||
rec->priority, rec->weight, rec->srvport, rec->target))
|
rec->priority, rec->weight, rec->srvport, rec->target))
|
||||||
@@ -1506,9 +1689,27 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
rec->offset = offset;
|
rec->offset = offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* unlink first SRV record found */
|
||||||
|
if (!move)
|
||||||
|
{
|
||||||
|
move = rec;
|
||||||
|
*up = rec->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
up = &rec->next;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
up = &rec->next;
|
||||||
|
|
||||||
|
/* put first SRV record back at the end. */
|
||||||
|
if (move)
|
||||||
|
{
|
||||||
|
*up = move;
|
||||||
|
move->next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!found && (daemon->options & OPT_FILTER) && (qtype == T_SRV || (qtype == T_ANY && strchr(name, '_'))))
|
if (!found && option_bool(OPT_FILTER) && (qtype == T_SRV || (qtype == T_ANY && strchr(name, '_'))))
|
||||||
{
|
{
|
||||||
ans = 1;
|
ans = 1;
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
@@ -1525,7 +1726,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
ans = 1;
|
ans = 1;
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
log_query(F_CNAME | F_FORWARD | F_CONFIG | F_NXDOMAIN, name, NULL, "<NAPTR>");
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<NAPTR>");
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
||||||
NULL, T_NAPTR, C_IN, "sszzzd",
|
NULL, T_NAPTR, C_IN, "sszzzd",
|
||||||
na->order, na->pref, na->flags, na->services, na->regexp, na->replace))
|
na->order, na->pref, na->flags, na->services, na->regexp, na->replace))
|
||||||
@@ -1537,7 +1738,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
if (qtype == T_MAILB)
|
if (qtype == T_MAILB)
|
||||||
ans = 1, nxdomain = 1;
|
ans = 1, nxdomain = 1;
|
||||||
|
|
||||||
if (qtype == T_SOA && (daemon->options & OPT_FILTER))
|
if (qtype == T_SOA && option_bool(OPT_FILTER))
|
||||||
{
|
{
|
||||||
ans = 1;
|
ans = 1;
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
|
|||||||
+521
-284
File diff suppressed because it is too large.
Load diff
+177
-66
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#ifdef HAVE_TFTP
|
#ifdef HAVE_TFTP
|
||||||
|
|
||||||
static struct tftp_file *check_tftp_fileperm(ssize_t *len);
|
static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix, int special);
|
||||||
static void free_transfer(struct tftp_transfer *transfer);
|
static void free_transfer(struct tftp_transfer *transfer);
|
||||||
static ssize_t tftp_err(int err, char *packet, char *mess, char *file);
|
static ssize_t tftp_err(int err, char *packet, char *mess, char *file);
|
||||||
static ssize_t tftp_err_oops(char *packet, char *file);
|
static ssize_t tftp_err_oops(char *packet, char *file);
|
||||||
@@ -43,20 +43,31 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
ssize_t len;
|
ssize_t len;
|
||||||
char *packet = daemon->packet;
|
char *packet = daemon->packet;
|
||||||
char *filename, *mode, *p, *end, *opt;
|
char *filename, *mode, *p, *end, *opt;
|
||||||
struct sockaddr_in addr, peer;
|
union mysockaddr addr, peer;
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int is_err = 1, if_index = 0, mtu = 0;
|
int is_err = 1, if_index = 0, mtu = 0, special = 0;
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
|
#endif
|
||||||
struct tftp_transfer *transfer;
|
struct tftp_transfer *transfer;
|
||||||
int port = daemon->start_tftp_port; /* may be zero to use ephemeral port */
|
int port = daemon->start_tftp_port; /* may be zero to use ephemeral port */
|
||||||
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
|
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
|
||||||
int mtuflag = IP_PMTUDISC_DONT;
|
int mtuflag = IP_PMTUDISC_DONT;
|
||||||
#endif
|
#endif
|
||||||
|
char namebuff[IF_NAMESIZE];
|
||||||
|
char pretty_addr[ADDRSTRLEN];
|
||||||
|
char *name;
|
||||||
|
char *prefix = daemon->tftp_prefix;
|
||||||
|
struct tftp_prefix *pref;
|
||||||
|
struct interface_list *ir;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct cmsghdr align; /* this ensures alignment */
|
struct cmsghdr align; /* this ensures alignment */
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
|
||||||
|
#endif
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
@@ -83,68 +94,152 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
if ((len = recvmsg(listen->tftpfd, &msg, 0)) < 2)
|
if ((len = recvmsg(listen->tftpfd, &msg, 0)) < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (daemon->options & OPT_NOWILD)
|
if (option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
addr = listen->iface->addr.in;
|
addr = listen->iface->addr;
|
||||||
mtu = listen->iface->mtu;
|
mtu = listen->iface->mtu;
|
||||||
|
name = listen->iface->name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char name[IF_NAMESIZE];
|
|
||||||
struct cmsghdr *cmptr;
|
struct cmsghdr *cmptr;
|
||||||
|
int check;
|
||||||
|
struct interface_list *ir;
|
||||||
|
|
||||||
|
if (msg.msg_controllen < sizeof(struct cmsghdr))
|
||||||
|
return;
|
||||||
|
|
||||||
addr.sin_addr.s_addr = 0;
|
addr.sa.sa_family = listen->family;
|
||||||
|
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
if (listen->family == AF_INET)
|
||||||
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
{
|
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
|
||||||
addr.sin_addr = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_spec_dst;
|
{
|
||||||
if_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
|
union {
|
||||||
}
|
unsigned char *c;
|
||||||
|
struct in_pktinfo *p;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
addr.in.sin_addr = p.p->ipi_spec_dst;
|
||||||
|
if_index = p.p->ipi_ifindex;
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
if (listen->family == AF_INET)
|
||||||
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
addr.sin_addr = *((struct in_addr *)CMSG_DATA(cmptr));
|
{
|
||||||
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
union {
|
||||||
if_index = *((unsigned int *)CMSG_DATA(cmptr));
|
unsigned char *c;
|
||||||
|
struct in_addr *a;
|
||||||
|
unsigned int *i;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
||||||
|
addr.in.sin_addr = *(p.a);
|
||||||
|
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
|
if_index = *(p.i);
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
if (listen->family == AF_INET)
|
||||||
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
addr.sin_addr = *((struct in_addr *)CMSG_DATA(cmptr));
|
{
|
||||||
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
union {
|
||||||
if_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
unsigned char *c;
|
||||||
|
struct in_addr *a;
|
||||||
|
struct sockaddr_dl *s;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
||||||
|
addr.in.sin_addr = *(p.a);
|
||||||
|
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
|
if_index = p.s->sdl_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (listen->family == AF_INET6)
|
||||||
|
{
|
||||||
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
|
if (cmptr->cmsg_level == IPV6_LEVEL && cmptr->cmsg_type == daemon->v6pktinfo)
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
unsigned char *c;
|
||||||
|
struct in6_pktinfo *p;
|
||||||
|
} p;
|
||||||
|
p.c = CMSG_DATA(cmptr);
|
||||||
|
|
||||||
|
addr.in6.sin6_addr = p.p->ipi6_addr;
|
||||||
|
if_index = p.p->ipi6_ifindex;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!indextoname(listen->tftpfd, if_index, name) ||
|
if (!indextoname(listen->tftpfd, if_index, namebuff))
|
||||||
addr.sin_addr.s_addr == 0 ||
|
|
||||||
!iface_check(AF_INET, (struct all_addr *)&addr.sin_addr, name, &if_index))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* allowed interfaces are the same as for DHCP */
|
name = namebuff;
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
|
||||||
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
#ifdef HAVE_IPV6
|
||||||
return;
|
if (listen->family == AF_INET6)
|
||||||
|
check = iface_check(AF_INET6, (struct all_addr *)&addr.in6.sin6_addr, name, &if_index);
|
||||||
strncpy(name, ifr.ifr_name, IF_NAMESIZE);
|
else
|
||||||
|
#endif
|
||||||
|
check = iface_check(AF_INET, (struct all_addr *)&addr.in.sin_addr, name, &if_index);
|
||||||
|
|
||||||
|
/* wierd TFTP service override */
|
||||||
|
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
||||||
|
if (strcmp(ir->interface, name) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!ir)
|
||||||
|
{
|
||||||
|
if (!daemon->tftp_unlimited || !check)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
/* allowed interfaces are the same as for DHCP */
|
||||||
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
||||||
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
||||||
mtu = ifr.ifr_mtu;
|
mtu = ifr.ifr_mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr.sin_port = htons(port);
|
/* check for per-interface prefix */
|
||||||
addr.sin_family = AF_INET;
|
for (pref = daemon->if_prefix; pref; pref = pref->next)
|
||||||
|
if (strcmp(pref->interface, name) == 0)
|
||||||
|
prefix = pref->prefix;
|
||||||
|
|
||||||
|
/* wierd TFTP interfaces disable special options. */
|
||||||
|
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
||||||
|
if (strcmp(ir->interface, name) == 0)
|
||||||
|
special = 1;
|
||||||
|
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||||
addr.sin_len = sizeof(addr);
|
addr.sa.sa_len = sa_len(&addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (listen->family == AF_INET)
|
||||||
|
addr.in.sin_port = htons(port);
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addr.in6.sin6_port = htons(port);
|
||||||
|
addr.in6.sin6_flowinfo = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!(transfer = whine_malloc(sizeof(struct tftp_transfer))))
|
if (!(transfer = whine_malloc(sizeof(struct tftp_transfer))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((transfer->sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
if ((transfer->sockfd = socket(listen->family, SOCK_DGRAM, 0)) == -1)
|
||||||
{
|
{
|
||||||
free(transfer);
|
free(transfer);
|
||||||
return;
|
return;
|
||||||
@@ -159,11 +254,13 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
transfer->file = NULL;
|
transfer->file = NULL;
|
||||||
transfer->opt_blocksize = transfer->opt_transize = 0;
|
transfer->opt_blocksize = transfer->opt_transize = 0;
|
||||||
transfer->netascii = transfer->carrylf = 0;
|
transfer->netascii = transfer->carrylf = 0;
|
||||||
|
|
||||||
|
prettyprint_addr(&peer, pretty_addr);
|
||||||
|
|
||||||
/* if we have a nailed-down range, iterate until we find a free one. */
|
/* if we have a nailed-down range, iterate until we find a free one. */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (bind(transfer->sockfd, (struct sockaddr *)&addr, sizeof(addr)) == -1 ||
|
if (bind(transfer->sockfd, &addr.sa, sizeof(addr)) == -1 ||
|
||||||
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
|
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
|
||||||
setsockopt(transfer->sockfd, SOL_IP, IP_MTU_DISCOVER, &mtuflag, sizeof(mtuflag)) == -1 ||
|
setsockopt(transfer->sockfd, SOL_IP, IP_MTU_DISCOVER, &mtuflag, sizeof(mtuflag)) == -1 ||
|
||||||
#endif
|
#endif
|
||||||
@@ -173,7 +270,12 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
{
|
{
|
||||||
if (++port <= daemon->end_tftp_port)
|
if (++port <= daemon->end_tftp_port)
|
||||||
{
|
{
|
||||||
addr.sin_port = htons(port);
|
if (listen->family == AF_INET)
|
||||||
|
addr.in.sin_port = htons(port);
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else
|
||||||
|
addr.in6.sin6_port = htons(port);
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
my_syslog(MS_TFTP | LOG_ERR, _("unable to get free port for TFTP"));
|
my_syslog(MS_TFTP | LOG_ERR, _("unable to get free port for TFTP"));
|
||||||
@@ -191,7 +293,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
!(filename = next(&p, end)) ||
|
!(filename = next(&p, end)) ||
|
||||||
!(mode = next(&p, end)) ||
|
!(mode = next(&p, end)) ||
|
||||||
(strcasecmp(mode, "octet") != 0 && strcasecmp(mode, "netascii") != 0))
|
(strcasecmp(mode, "octet") != 0 && strcasecmp(mode, "netascii") != 0))
|
||||||
len = tftp_err(ERR_ILL, packet, _("unsupported request from %s"), inet_ntoa(peer.sin_addr));
|
len = tftp_err(ERR_ILL, packet, _("unsupported request from %s"), pretty_addr);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strcasecmp(mode, "netascii") == 0)
|
if (strcasecmp(mode, "netascii") == 0)
|
||||||
@@ -202,7 +304,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
if (strcasecmp(opt, "blksize") == 0)
|
if (strcasecmp(opt, "blksize") == 0)
|
||||||
{
|
{
|
||||||
if ((opt = next(&p, end)) &&
|
if ((opt = next(&p, end)) &&
|
||||||
!(daemon->options & OPT_TFTP_NOBLOCK))
|
(special || !option_bool(OPT_TFTP_NOBLOCK)))
|
||||||
{
|
{
|
||||||
transfer->blocksize = atoi(opt);
|
transfer->blocksize = atoi(opt);
|
||||||
if (transfer->blocksize < 1)
|
if (transfer->blocksize < 1)
|
||||||
@@ -228,20 +330,20 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
*p = '/';
|
*p = '/';
|
||||||
|
|
||||||
strcpy(daemon->namebuff, "/");
|
strcpy(daemon->namebuff, "/");
|
||||||
if (daemon->tftp_prefix)
|
if (prefix)
|
||||||
{
|
{
|
||||||
if (daemon->tftp_prefix[0] == '/')
|
if (prefix[0] == '/')
|
||||||
daemon->namebuff[0] = 0;
|
daemon->namebuff[0] = 0;
|
||||||
strncat(daemon->namebuff, daemon->tftp_prefix, (MAXDNAME-1) - strlen(daemon->namebuff));
|
strncat(daemon->namebuff, prefix, (MAXDNAME-1) - strlen(daemon->namebuff));
|
||||||
if (daemon->tftp_prefix[strlen(daemon->tftp_prefix)-1] != '/')
|
if (prefix[strlen(prefix)-1] != '/')
|
||||||
strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
|
strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
|
||||||
|
|
||||||
if (daemon->options & OPT_TFTP_APREF)
|
if (!special && option_bool(OPT_TFTP_APREF))
|
||||||
{
|
{
|
||||||
size_t oldlen = strlen(daemon->namebuff);
|
size_t oldlen = strlen(daemon->namebuff);
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
strncat(daemon->namebuff, inet_ntoa(peer.sin_addr), (MAXDNAME-1) - strlen(daemon->namebuff));
|
strncat(daemon->namebuff, pretty_addr, (MAXDNAME-1) - strlen(daemon->namebuff));
|
||||||
strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
|
strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
|
||||||
|
|
||||||
/* remove unique-directory if it doesn't exist */
|
/* remove unique-directory if it doesn't exist */
|
||||||
@@ -263,7 +365,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
strncat(daemon->namebuff, filename, (MAXDNAME-1) - strlen(daemon->namebuff));
|
strncat(daemon->namebuff, filename, (MAXDNAME-1) - strlen(daemon->namebuff));
|
||||||
|
|
||||||
/* check permissions and open file */
|
/* check permissions and open file */
|
||||||
if ((transfer->file = check_tftp_fileperm(&len)))
|
if ((transfer->file = check_tftp_fileperm(&len, prefix, special)))
|
||||||
{
|
{
|
||||||
if ((len = get_block(packet, transfer)) == -1)
|
if ((len = get_block(packet, transfer)) == -1)
|
||||||
len = tftp_err_oops(packet, daemon->namebuff);
|
len = tftp_err_oops(packet, daemon->namebuff);
|
||||||
@@ -279,13 +381,12 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_syslog(MS_TFTP | LOG_INFO, _("TFTP sent %s to %s"), daemon->namebuff, inet_ntoa(peer.sin_addr));
|
|
||||||
transfer->next = daemon->tftp_trans;
|
transfer->next = daemon->tftp_trans;
|
||||||
daemon->tftp_trans = transfer;
|
daemon->tftp_trans = transfer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tftp_file *check_tftp_fileperm(ssize_t *len)
|
static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix, int special)
|
||||||
{
|
{
|
||||||
char *packet = daemon->packet, *namebuff = daemon->namebuff;
|
char *packet = daemon->packet, *namebuff = daemon->namebuff;
|
||||||
struct tftp_file *file;
|
struct tftp_file *file;
|
||||||
@@ -295,7 +396,7 @@ static struct tftp_file *check_tftp_fileperm(ssize_t *len)
|
|||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
/* trick to ban moving out of the subtree */
|
/* trick to ban moving out of the subtree */
|
||||||
if (daemon->tftp_prefix && strstr(namebuff, "/../"))
|
if (prefix && strstr(namebuff, "/../"))
|
||||||
goto perm;
|
goto perm;
|
||||||
|
|
||||||
if ((fd = open(namebuff, O_RDONLY)) == -1)
|
if ((fd = open(namebuff, O_RDONLY)) == -1)
|
||||||
@@ -322,7 +423,7 @@ static struct tftp_file *check_tftp_fileperm(ssize_t *len)
|
|||||||
goto perm;
|
goto perm;
|
||||||
}
|
}
|
||||||
/* in secure mode, must be owned by user running dnsmasq */
|
/* in secure mode, must be owned by user running dnsmasq */
|
||||||
else if ((daemon->options & OPT_TFTP_SECURE) && uid != statbuf.st_uid)
|
else if (!special && option_bool(OPT_TFTP_SECURE) && uid != statbuf.st_uid)
|
||||||
goto perm;
|
goto perm;
|
||||||
|
|
||||||
/* If we're doing many tranfers from the same file, only
|
/* If we're doing many tranfers from the same file, only
|
||||||
@@ -372,6 +473,7 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
{
|
{
|
||||||
struct tftp_transfer *transfer, *tmp, **up;
|
struct tftp_transfer *transfer, *tmp, **up;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
char pretty_addr[ADDRSTRLEN];
|
||||||
|
|
||||||
struct ack {
|
struct ack {
|
||||||
unsigned short op, block;
|
unsigned short op, block;
|
||||||
@@ -386,6 +488,8 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
{
|
{
|
||||||
/* we overwrote the buffer... */
|
/* we overwrote the buffer... */
|
||||||
daemon->srv_save = NULL;
|
daemon->srv_save = NULL;
|
||||||
|
|
||||||
|
prettyprint_addr(&transfer->peer, pretty_addr);
|
||||||
|
|
||||||
if ((len = recv(transfer->sockfd, daemon->packet, daemon->packet_buff_sz, 0)) >= (ssize_t)sizeof(struct ack))
|
if ((len = recv(transfer->sockfd, daemon->packet, daemon->packet_buff_sz, 0)) >= (ssize_t)sizeof(struct ack))
|
||||||
{
|
{
|
||||||
@@ -402,6 +506,7 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
char *p = daemon->packet + sizeof(struct ack);
|
char *p = daemon->packet + sizeof(struct ack);
|
||||||
char *end = daemon->packet + len;
|
char *end = daemon->packet + len;
|
||||||
char *err = next(&p, end);
|
char *err = next(&p, end);
|
||||||
|
|
||||||
/* Sanitise error message */
|
/* Sanitise error message */
|
||||||
if (!err)
|
if (!err)
|
||||||
err = "";
|
err = "";
|
||||||
@@ -413,9 +518,10 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
*(q++) = *r;
|
*(q++) = *r;
|
||||||
*q = 0;
|
*q = 0;
|
||||||
}
|
}
|
||||||
my_syslog(MS_TFTP | LOG_ERR, _("TFTP error %d %s received from %s"),
|
|
||||||
|
my_syslog(MS_TFTP | LOG_ERR, _("error %d %s received from %s"),
|
||||||
(int)ntohs(mess->block), err,
|
(int)ntohs(mess->block), err,
|
||||||
inet_ntoa(transfer->peer.sin_addr));
|
pretty_addr);
|
||||||
|
|
||||||
/* Got err, ensure we take abort */
|
/* Got err, ensure we take abort */
|
||||||
transfer->timeout = now;
|
transfer->timeout = now;
|
||||||
@@ -444,9 +550,12 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
/* don't complain about timeout when we're awaiting the last
|
/* don't complain about timeout when we're awaiting the last
|
||||||
ACK, some clients never send it */
|
ACK, some clients never send it */
|
||||||
if (len != 0)
|
if (len != 0)
|
||||||
my_syslog(MS_TFTP | LOG_ERR, _("TFTP failed sending %s to %s"),
|
{
|
||||||
transfer->file->filename, inet_ntoa(transfer->peer.sin_addr));
|
my_syslog(MS_TFTP | LOG_ERR, _("failed sending %s to %s"),
|
||||||
len = 0;
|
transfer->file->filename, pretty_addr);
|
||||||
|
len = 0;
|
||||||
|
endcon = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len != 0)
|
if (len != 0)
|
||||||
@@ -455,6 +564,8 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
|
|
||||||
if (endcon || len == 0)
|
if (endcon || len == 0)
|
||||||
{
|
{
|
||||||
|
if (!endcon)
|
||||||
|
my_syslog(MS_TFTP | LOG_INFO, _("sent %s to %s"), transfer->file->filename, pretty_addr);
|
||||||
/* unlink */
|
/* unlink */
|
||||||
*up = tmp;
|
*up = tmp;
|
||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
@@ -463,7 +574,7 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
up = &transfer->next;
|
up = &transfer->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_transfer(struct tftp_transfer *transfer)
|
static void free_transfer(struct tftp_transfer *transfer)
|
||||||
@@ -503,7 +614,7 @@ static ssize_t tftp_err(int err, char *packet, char *message, char *file)
|
|||||||
mess->op = htons(OP_ERR);
|
mess->op = htons(OP_ERR);
|
||||||
mess->err = htons(err);
|
mess->err = htons(err);
|
||||||
ret += (snprintf(mess->message, 500, message, file, errstr) + 1);
|
ret += (snprintf(mess->message, 500, message, file, errstr) + 1);
|
||||||
my_syslog(MS_TFTP | LOG_ERR, "TFTP %s", mess->message);
|
my_syslog(MS_TFTP | LOG_ERR, "%s", mess->message);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-3
@@ -1,4 +1,4 @@
|
|||||||
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley
|
/* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -365,7 +365,8 @@ void prettyprint_time(char *buf, unsigned int t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* in may equal out, when maxlen may be -1 (No max len). */
|
/* in may equal out, when maxlen may be -1 (No max len).
|
||||||
|
Return -1 for extraneous no-hex chars found. */
|
||||||
int parse_hex(char *in, unsigned char *out, int maxlen,
|
int parse_hex(char *in, unsigned char *out, int maxlen,
|
||||||
unsigned int *wildcard_mask, int *mac_type)
|
unsigned int *wildcard_mask, int *mac_type)
|
||||||
{
|
{
|
||||||
@@ -377,7 +378,10 @@ int parse_hex(char *in, unsigned char *out, int maxlen,
|
|||||||
|
|
||||||
while (maxlen == -1 || i < maxlen)
|
while (maxlen == -1 || i < maxlen)
|
||||||
{
|
{
|
||||||
for (r = in; *r != 0 && *r != ':' && *r != '-'; r++);
|
for (r = in; *r != 0 && *r != ':' && *r != '-'; r++)
|
||||||
|
if (!isxdigit((int)*r))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (*r == 0)
|
if (*r == 0)
|
||||||
maxlen = i;
|
maxlen = i;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user