mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-08 16:11:30 +00:00
Compare commits
9
Commits
v2.76test5
...
v2.76test8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ace25c5d6 | ||
|
|
1e5051228d | ||
|
|
926332a764 | ||
|
|
d05dd58de1 | ||
|
|
f7443d76f7 | ||
|
|
f344dbc622 | ||
|
|
f4d0c660ca | ||
|
|
1801a29226 | ||
|
|
92be34a407 |
No files matched your search
@@ -22,6 +22,29 @@ version 2.76
|
|||||||
reading a hosts-file fails. Thanks to André Glüpker
|
reading a hosts-file fails. Thanks to André Glüpker
|
||||||
for the patch.
|
for the patch.
|
||||||
|
|
||||||
|
Fix wrong answer to simple name query when --domain-needed
|
||||||
|
set, but no upstream servers configured. Dnsmasq returned
|
||||||
|
REFUSED, in this case, when it should be the same as when
|
||||||
|
upstream servers are configured - NOERROR. Thanks to
|
||||||
|
Allain Legacy for spotting the problem.
|
||||||
|
|
||||||
|
Return REFUSED when running out of forwarding table slots,
|
||||||
|
not SERVFAIL.
|
||||||
|
|
||||||
|
Add --max-port configuration. Thanks to Hans Dedecker for
|
||||||
|
the patch.
|
||||||
|
|
||||||
|
Add --script-arp and two new functions for the dhcp-script.
|
||||||
|
These are "arp" and "arp-old" which announce the arrival and
|
||||||
|
removal of entries in the ARP or nieghbour tables.
|
||||||
|
|
||||||
|
Extend --add-mac to allow a new encoding of the MAC address
|
||||||
|
as base64, by configurting --add-mac=base64
|
||||||
|
|
||||||
|
Add --add-cpe-id option.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
version 2.75
|
version 2.75
|
||||||
Fix reversion on 2.74 which caused 100% CPU use when a
|
Fix reversion on 2.74 which caused 100% CPU use when a
|
||||||
|
|||||||
+39
-5
@@ -174,6 +174,13 @@ queries. Dnsmasq picks random ports as source for outbound queries:
|
|||||||
when this option is given, the ports used will always to larger
|
when this option is given, the ports used will always to larger
|
||||||
than that specified. Useful for systems behind firewalls.
|
than that specified. Useful for systems behind firewalls.
|
||||||
.TP
|
.TP
|
||||||
|
.B --max-port=<port>
|
||||||
|
Use ports lower than that given as source for outbound DNS queries.
|
||||||
|
Dnsmasq picks random ports as source for outbound queries:
|
||||||
|
when this option is given, the ports used will always be lower
|
||||||
|
than that specified. Useful for systems behind firewalls.
|
||||||
|
.TP
|
||||||
|
|
||||||
.B \-i, --interface=<interface name>
|
.B \-i, --interface=<interface name>
|
||||||
Listen only on the specified interface(s). Dnsmasq automatically adds
|
Listen only on the specified interface(s). Dnsmasq automatically adds
|
||||||
the loopback (local) interface to the list of interfaces to use when
|
the loopback (local) interface to the list of interfaces to use when
|
||||||
@@ -405,7 +412,10 @@ xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag
|
|||||||
.B -S /internal.thekelleys.org.uk/192.168.1.1
|
.B -S /internal.thekelleys.org.uk/192.168.1.1
|
||||||
will send all queries for
|
will send all queries for
|
||||||
internal machines to that nameserver, everything else will go to the
|
internal machines to that nameserver, everything else will go to the
|
||||||
servers in /etc/resolv.conf. An empty domain specification,
|
servers in /etc/resolv.conf. DNSSEC validation is turned off for such
|
||||||
|
private nameservers, UNLESS a
|
||||||
|
.B --trust-anchor
|
||||||
|
is specified for the domain in question. An empty domain specification,
|
||||||
.B //
|
.B //
|
||||||
has the special meaning of "unqualified names only" ie names without any
|
has the special meaning of "unqualified names only" ie names without any
|
||||||
dots in them. A non-standard port may be specified as
|
dots in them. A non-standard port may be specified as
|
||||||
@@ -594,7 +604,7 @@ configured a zero is added in front of the label. ::1 becomes 0--1.
|
|||||||
The address range can be of the form
|
The address range can be of the form
|
||||||
<ip address>,<ip address> or <ip address>/<netmask>
|
<ip address>,<ip address> or <ip address>/<netmask>
|
||||||
.TP
|
.TP
|
||||||
.B --add-mac
|
.B --add-mac[=base64]
|
||||||
Add the MAC address of the requestor to DNS queries which are
|
Add the MAC address of the requestor to DNS queries which are
|
||||||
forwarded upstream. This may be used to DNS filtering by the upstream
|
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
|
server. The MAC address can only be added if the requestor is on the same
|
||||||
@@ -602,7 +612,12 @@ subnet as the dnsmasq server. Note that the mechanism used to achieve this (an E
|
|||||||
is not yet standardised, so this should be considered
|
is not yet standardised, so this should be considered
|
||||||
experimental. Also note that exposing MAC addresses in this way may
|
experimental. Also note that exposing MAC addresses in this way may
|
||||||
have security and privacy implications. The warning about caching
|
have security and privacy implications. The warning about caching
|
||||||
given for --add-subnet applies to --add-mac too.
|
given for --add-subnet applies to --add-mac too. An alternative encoding of the
|
||||||
|
MAC, as base64, is enabled by adding the "base64" parameter.
|
||||||
|
.TP
|
||||||
|
.B --add-cpe-id=<string>
|
||||||
|
Add a arbitrary identifying string to o DNS queries which are
|
||||||
|
forwarded upstream.
|
||||||
.TP
|
.TP
|
||||||
.B --add-subnet[[=[<IPv4 address>/]<IPv4 prefix length>][,[<IPv6 address>/]<IPv6 prefix length>]]
|
.B --add-subnet[[=[<IPv4 address>/]<IPv4 prefix length>][,[<IPv6 address>/]<IPv6 prefix length>]]
|
||||||
Add a subnet address to the DNS queries which are forwarded
|
Add a subnet address to the DNS queries which are forwarded
|
||||||
@@ -1536,8 +1551,8 @@ receives a HUP signal, the script will be invoked for existing leases
|
|||||||
with an "old" event.
|
with an "old" event.
|
||||||
|
|
||||||
|
|
||||||
There are two further actions which may appear as the first argument
|
There are four further actions which may appear as the first argument
|
||||||
to the script, "init" and "tftp". More may be added in the future, so
|
to the script, "init", "arp", "arp-old" and "tftp". More may be added in the future, so
|
||||||
scripts should be written to ignore unknown actions. "init" is
|
scripts should be written to ignore unknown actions. "init" is
|
||||||
described below in
|
described below in
|
||||||
.B --leasefile-ro
|
.B --leasefile-ro
|
||||||
@@ -1545,6 +1560,11 @@ The "tftp" action is invoked when a TFTP file transfer completes: the
|
|||||||
arguments are the file size in bytes, the address to which the file
|
arguments are the file size in bytes, the address to which the file
|
||||||
was sent, and the complete pathname of the file.
|
was sent, and the complete pathname of the file.
|
||||||
|
|
||||||
|
The "arp" and "arp-old" actions are only called if enabled with
|
||||||
|
.B --script-arp
|
||||||
|
They are are supplied with a MAC address and IP address as arguments. "arp" indicates
|
||||||
|
the arrival of a new entry in the ARP or neighbour table, and arp-old indicates the deletion of same.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-luascript=<path>
|
.B --dhcp-luascript=<path>
|
||||||
Specify a script written in Lua, to be run when leases are created,
|
Specify a script written in Lua, to be run when leases are created,
|
||||||
@@ -1591,10 +1611,24 @@ table holds the tags
|
|||||||
.B file_name
|
.B file_name
|
||||||
and
|
and
|
||||||
.B file_size.
|
.B file_size.
|
||||||
|
|
||||||
|
The
|
||||||
|
.B arp
|
||||||
|
and
|
||||||
|
.B arp-old
|
||||||
|
functions are called only when enabled with
|
||||||
|
.B --script-arp
|
||||||
|
and have a table which holds the tags
|
||||||
|
.B mac_addres
|
||||||
|
and
|
||||||
|
.B client_address.
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-scriptuser
|
.B --dhcp-scriptuser
|
||||||
Specify the user as which to run the lease-change script or Lua script. This defaults to root, but can be changed to another user using this flag.
|
Specify the user as which to run the lease-change script or Lua script. This defaults to root, but can be changed to another user using this flag.
|
||||||
.TP
|
.TP
|
||||||
|
.B --script-arp
|
||||||
|
Enable the "arp" and "arp-old" functions in the dhcp-script and dhcp-luascript.
|
||||||
|
.TP
|
||||||
.B \-9, --leasefile-ro
|
.B \-9, --leasefile-ro
|
||||||
Completely suppress use of the lease database file. The file will not
|
Completely suppress use of the lease database file. The file will not
|
||||||
be created, read, or written. Change the way the lease-change
|
be created, read, or written. Change the way the lease-change
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
|
|||||||
|
|
||||||
/* If the database is less then INTERVAL old, look in there */
|
/* If the database is less then INTERVAL old, look in there */
|
||||||
if (difftime(now, last) < INTERVAL)
|
if (difftime(now, last) < INTERVAL)
|
||||||
|
{
|
||||||
|
/* addr == NULL -> just make cache up-to-date */
|
||||||
|
if (!addr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (arp = arps; arp; arp = arp->next)
|
for (arp = arps; arp; arp = arp->next)
|
||||||
{
|
{
|
||||||
if (addr->sa.sa_family == arp->family)
|
if (addr->sa.sa_family == arp->family)
|
||||||
@@ -140,6 +145,7 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
|
|||||||
return arp->hwlen;
|
return arp->hwlen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Not found, try the kernel */
|
/* Not found, try the kernel */
|
||||||
if (!updated)
|
if (!updated)
|
||||||
@@ -188,6 +194,7 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
|
|||||||
arps = arp;
|
arps = arp;
|
||||||
arp->status = ARP_EMPTY;
|
arp->status = ARP_EMPTY;
|
||||||
arp->family = addr->sa.sa_family;
|
arp->family = addr->sa.sa_family;
|
||||||
|
arp->hwlen = 0;
|
||||||
|
|
||||||
if (addr->sa.sa_family == AF_INET)
|
if (addr->sa.sa_family == AF_INET)
|
||||||
arp->addr.addr.addr4.s_addr = addr->in.sin_addr.s_addr;
|
arp->addr.addr.addr4.s_addr = addr->in.sin_addr.s_addr;
|
||||||
@@ -208,7 +215,7 @@ int do_arp_script_run(void)
|
|||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SCRIPT
|
#ifdef HAVE_SCRIPT
|
||||||
if (option_bool(OPT_DNS_CLIENT))
|
if (option_bool(OPT_SCRIPT_ARP))
|
||||||
queue_arp(ACTION_ARP_OLD, old->hwaddr, old->hwlen, old->family, &old->addr);
|
queue_arp(ACTION_ARP_OLD, old->hwaddr, old->hwlen, old->family, &old->addr);
|
||||||
#endif
|
#endif
|
||||||
arp = old;
|
arp = old;
|
||||||
@@ -222,7 +229,7 @@ int do_arp_script_run(void)
|
|||||||
if (arp->status == ARP_NEW)
|
if (arp->status == ARP_NEW)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SCRIPT
|
#ifdef HAVE_SCRIPT
|
||||||
if (option_bool(OPT_DNS_CLIENT))
|
if (option_bool(OPT_SCRIPT_ARP))
|
||||||
queue_arp(ACTION_ARP, arp->hwaddr, arp->hwlen, arp->family, &arp->addr);
|
queue_arp(ACTION_ARP, arp->hwaddr, arp->hwlen, arp->family, &arp->addr);
|
||||||
#endif
|
#endif
|
||||||
arp->status = ARP_FOUND;
|
arp->status = ARP_FOUND;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#define NAMESERVER_PORT 53
|
#define NAMESERVER_PORT 53
|
||||||
#define TFTP_PORT 69
|
#define TFTP_PORT 69
|
||||||
|
#define MAX_PORT 65535u
|
||||||
|
|
||||||
#define IN6ADDRSZ 16
|
#define IN6ADDRSZ 16
|
||||||
#define INADDRSZ 4
|
#define INADDRSZ 4
|
||||||
|
|||||||
+12
-3
@@ -220,6 +220,12 @@ int main (int argc, char **argv)
|
|||||||
die(_("loop detection not available: set HAVE_LOOP in src/config.h"), NULL, EC_BADCONF);
|
die(_("loop detection not available: set HAVE_LOOP in src/config.h"), NULL, EC_BADCONF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (daemon->max_port != MAX_PORT && daemon->min_port == 0)
|
||||||
|
daemon->min_port = 1024u;
|
||||||
|
|
||||||
|
if (daemon->max_port < daemon->min_port)
|
||||||
|
die(_("max_port cannot be smaller than min_port"), NULL, EC_BADCONF);
|
||||||
|
|
||||||
now = dnsmasq_time();
|
now = dnsmasq_time();
|
||||||
|
|
||||||
/* Create a serial at startup if not configured. */
|
/* Create a serial at startup if not configured. */
|
||||||
@@ -254,10 +260,10 @@ int main (int argc, char **argv)
|
|||||||
creating any file descriptors which shouldn't be leaked
|
creating any file descriptors which shouldn't be leaked
|
||||||
to the lease-script init process. We need to call common_init
|
to the lease-script init process. We need to call common_init
|
||||||
before lease_init to allocate buffers it uses.
|
before lease_init to allocate buffers it uses.
|
||||||
The script subsystrm relies on DHCP buffers, hence the last two
|
The script subsystem relies on DHCP buffers, hence the last two
|
||||||
conditions below. */
|
conditions below. */
|
||||||
if (daemon->dhcp || daemon->doing_dhcp6 || daemon->relay4 ||
|
if (daemon->dhcp || daemon->doing_dhcp6 || daemon->relay4 ||
|
||||||
daemon->relay6 || option_bool(OPT_TFTP) || option_bool(OPT_DNS_CLIENT))
|
daemon->relay6 || option_bool(OPT_TFTP) || option_bool(OPT_SCRIPT_ARP))
|
||||||
{
|
{
|
||||||
dhcp_common_init();
|
dhcp_common_init();
|
||||||
if (daemon->dhcp || daemon->doing_dhcp6)
|
if (daemon->dhcp || daemon->doing_dhcp6)
|
||||||
@@ -564,7 +570,7 @@ int main (int argc, char **argv)
|
|||||||
/* 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;
|
||||||
#ifdef HAVE_SCRIPT
|
#ifdef HAVE_SCRIPT
|
||||||
if ((daemon->dhcp || daemon->dhcp6 || option_bool(OPT_TFTP) || option_bool(OPT_DNS_CLIENT)) &&
|
if ((daemon->dhcp || daemon->dhcp6 || option_bool(OPT_TFTP) || option_bool(OPT_SCRIPT_ARP)) &&
|
||||||
(daemon->lease_change_command || daemon->luascript))
|
(daemon->lease_change_command || daemon->luascript))
|
||||||
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
|
||||||
@@ -931,6 +937,9 @@ int main (int argc, char **argv)
|
|||||||
while (helper_buf_empty() && do_script_run(now));
|
while (helper_buf_empty() && do_script_run(now));
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
/* Refresh cache */
|
||||||
|
if (option_bool(OPT_SCRIPT_ARP))
|
||||||
|
find_mac(NULL, NULL, 0, now);
|
||||||
while (helper_buf_empty() && do_arp_script_run());
|
while (helper_buf_empty() && do_arp_script_run());
|
||||||
|
|
||||||
# ifdef HAVE_TFTP
|
# ifdef HAVE_TFTP
|
||||||
|
|||||||
+4
-3
@@ -235,8 +235,9 @@ struct event_desc {
|
|||||||
#define OPT_LOOP_DETECT 50
|
#define OPT_LOOP_DETECT 50
|
||||||
#define OPT_EXTRALOG 51
|
#define OPT_EXTRALOG 51
|
||||||
#define OPT_TFTP_NO_FAIL 52
|
#define OPT_TFTP_NO_FAIL 52
|
||||||
#define OPT_DNS_CLIENT 53
|
#define OPT_SCRIPT_ARP 53
|
||||||
#define OPT_LAST 54
|
#define OPT_MAC_B64 54
|
||||||
|
#define OPT_LAST 55
|
||||||
|
|
||||||
/* 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. */
|
||||||
@@ -950,7 +951,7 @@ extern struct daemon {
|
|||||||
char *log_file; /* optional log file */
|
char *log_file; /* optional log file */
|
||||||
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, max_port;
|
||||||
unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl;
|
unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl;
|
||||||
char *dns_client_id;
|
char *dns_client_id;
|
||||||
struct hostsfile *addn_hosts;
|
struct hostsfile *addn_hosts;
|
||||||
|
|||||||
+5
-5
@@ -233,10 +233,6 @@ static size_t add_dns_client(struct dns_header *header, size_t plen, unsigned ch
|
|||||||
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMDEVICEID, (unsigned char *)encode, 8, 0);
|
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMDEVICEID, (unsigned char *)encode, 8, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (daemon->dns_client_id)
|
|
||||||
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMCPEID,
|
|
||||||
(unsigned char *)daemon->dns_client_id, strlen(daemon->dns_client_id), 0);
|
|
||||||
|
|
||||||
return plen;
|
return plen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,9 +377,13 @@ size_t add_edns0_config(struct dns_header *header, size_t plen, unsigned char *l
|
|||||||
if (option_bool(OPT_ADD_MAC))
|
if (option_bool(OPT_ADD_MAC))
|
||||||
plen = add_mac(header, plen, limit, source, now);
|
plen = add_mac(header, plen, limit, source, now);
|
||||||
|
|
||||||
if (option_bool(OPT_DNS_CLIENT))
|
if (option_bool(OPT_MAC_B64))
|
||||||
plen = add_dns_client(header, plen, limit, source, now);
|
plen = add_dns_client(header, plen, limit, source, now);
|
||||||
|
|
||||||
|
if (daemon->dns_client_id)
|
||||||
|
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMCPEID,
|
||||||
|
(unsigned char *)daemon->dns_client_id, strlen(daemon->dns_client_id), 0);
|
||||||
|
|
||||||
if (option_bool(OPT_CLIENT_SUBNET))
|
if (option_bool(OPT_CLIENT_SUBNET))
|
||||||
{
|
{
|
||||||
plen = add_source_addr(header, plen, limit, source);
|
plen = add_source_addr(header, plen, limit, source);
|
||||||
|
|||||||
+153
-37
@@ -151,7 +151,7 @@ static unsigned int search_servers(time_t now, struct all_addr **addrpp, unsigne
|
|||||||
hostname_isequal(matchstart, serv->domain) &&
|
hostname_isequal(matchstart, serv->domain) &&
|
||||||
(domainlen == 0 || namelen == domainlen || *(matchstart-1) == '.' ))
|
(domainlen == 0 || namelen == domainlen || *(matchstart-1) == '.' ))
|
||||||
{
|
{
|
||||||
if (serv->flags & SERV_NO_REBIND)
|
if ((serv->flags & SERV_NO_REBIND) && norebind)
|
||||||
*norebind = 1;
|
*norebind = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -249,9 +249,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
(void)do_bit;
|
(void)do_bit;
|
||||||
|
|
||||||
/* may be no servers available. */
|
/* may be no servers available. */
|
||||||
if (!daemon->servers)
|
if (forward || (hash && (forward = lookup_frec_by_sender(ntohs(header->id), udpaddr, hash))))
|
||||||
forward = NULL;
|
|
||||||
else if (forward || (hash && (forward = lookup_frec_by_sender(ntohs(header->id), udpaddr, hash))))
|
|
||||||
{
|
{
|
||||||
/* If we didn't get an answer advertising a maximal packet in EDNS,
|
/* If we didn't get an answer advertising a maximal packet in EDNS,
|
||||||
fall back to 1280, which should work everywhere on IPv6.
|
fall back to 1280, which should work everywhere on IPv6.
|
||||||
@@ -331,12 +329,12 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
do_dnssec = type & SERV_DO_DNSSEC;
|
do_dnssec = type & SERV_DO_DNSSEC;
|
||||||
type &= ~SERV_DO_DNSSEC;
|
|
||||||
#endif
|
#endif
|
||||||
|
type &= ~SERV_DO_DNSSEC;
|
||||||
|
|
||||||
if (!flags && !(forward = get_new_frec(now, NULL, 0)))
|
if (daemon->servers && !flags)
|
||||||
/* table full - server failure. */
|
forward = get_new_frec(now, NULL, 0);
|
||||||
flags = F_NEG;
|
/* table full - flags == 0, return REFUSED */
|
||||||
|
|
||||||
if (forward)
|
if (forward)
|
||||||
{
|
{
|
||||||
@@ -644,7 +642,7 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server
|
|||||||
return resize_packet(header, n, pheader, plen);
|
return resize_packet(header, n, pheader, plen);
|
||||||
|
|
||||||
/* Complain loudly if the upstream server is non-recursive. */
|
/* Complain loudly if the upstream server is non-recursive. */
|
||||||
if (!(header->hb4 & HB4_RA) && RCODE(header) == NOERROR && ntohs(header->ancount) == 0 &&
|
if (!(header->hb4 & HB4_RA) && RCODE(header) == NOERROR &&
|
||||||
server && !(server->flags & SERV_WARNED_RECURSIVE))
|
server && !(server->flags & SERV_WARNED_RECURSIVE))
|
||||||
{
|
{
|
||||||
prettyprint_addr(&server->addr, daemon->namebuff);
|
prettyprint_addr(&server->addr, daemon->namebuff);
|
||||||
@@ -810,9 +808,9 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
{
|
{
|
||||||
header->hb3 &= ~(HB3_QR | HB3_AA | HB3_TC);
|
header->hb3 &= ~(HB3_QR | HB3_AA | HB3_TC);
|
||||||
header->hb4 &= ~(HB4_RA | HB4_RCODE | HB4_CD | HB4_AD);
|
header->hb4 &= ~(HB4_RA | HB4_RCODE | HB4_CD | HB4_AD);
|
||||||
if (forward->flags |= FREC_CHECKING_DISABLED)
|
if (forward->flags & FREC_CHECKING_DISABLED)
|
||||||
header->hb4 |= HB4_CD;
|
header->hb4 |= HB4_CD;
|
||||||
if (forward->flags |= FREC_AD_QUESTION)
|
if (forward->flags & FREC_AD_QUESTION)
|
||||||
header->hb4 |= HB4_AD;
|
header->hb4 |= HB4_AD;
|
||||||
if (forward->flags & FREC_DO_QUESTION)
|
if (forward->flags & FREC_DO_QUESTION)
|
||||||
add_do_bit(header, nn, (unsigned char *)pheader + plen);
|
add_do_bit(header, nn, (unsigned char *)pheader + plen);
|
||||||
@@ -855,7 +853,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
we get a good reply from another server. Kill it when we've
|
we get a good reply from another server. Kill it when we've
|
||||||
had replies from all to avoid filling the forwarding table when
|
had replies from all to avoid filling the forwarding table when
|
||||||
everything is broken */
|
everything is broken */
|
||||||
if (forward->forwardall == 0 || --forward->forwardall == 1 || RCODE(header) != SERVFAIL)
|
if (forward->forwardall == 0 || --forward->forwardall == 1 || RCODE(header) != REFUSED)
|
||||||
{
|
{
|
||||||
int check_rebind = 0, no_cache_dnssec = 0, cache_secure = 0, bogusanswer = 0;
|
int check_rebind = 0, no_cache_dnssec = 0, cache_secure = 0, bogusanswer = 0;
|
||||||
|
|
||||||
@@ -923,12 +921,48 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
status = STAT_ABANDONED;
|
status = STAT_ABANDONED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int fd;
|
int fd, type = SERV_DO_DNSSEC;
|
||||||
struct frec *next = new->next;
|
struct frec *next = new->next;
|
||||||
|
char *domain;
|
||||||
|
|
||||||
*new = *forward; /* copy everything, then overwrite */
|
*new = *forward; /* copy everything, then overwrite */
|
||||||
new->next = next;
|
new->next = next;
|
||||||
new->blocking_query = NULL;
|
new->blocking_query = NULL;
|
||||||
|
|
||||||
|
/* Find server to forward to. This will normally be the
|
||||||
|
same as for the original query, but may be another if
|
||||||
|
servers for domains are involved. */
|
||||||
|
if (search_servers(now, NULL, F_QUERY, daemon->keyname, &type, &domain, NULL) == 0)
|
||||||
|
{
|
||||||
|
struct server *start = server, *new_server = NULL;
|
||||||
|
type &= ~SERV_DO_DNSSEC;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (type == (start->flags & SERV_TYPE) &&
|
||||||
|
(type != SERV_HAS_DOMAIN || hostname_isequal(domain, start->domain)) &&
|
||||||
|
!(start->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)))
|
||||||
|
{
|
||||||
|
new_server = start;
|
||||||
|
if (server == start)
|
||||||
|
{
|
||||||
|
new_server = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(start = start->next))
|
||||||
|
start = daemon->servers;
|
||||||
|
if (start == server)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_server)
|
||||||
|
server = new_server;
|
||||||
|
}
|
||||||
|
|
||||||
new->sentto = server;
|
new->sentto = server;
|
||||||
|
|
||||||
new->rfd4 = NULL;
|
new->rfd4 = NULL;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
new->rfd6 = NULL;
|
new->rfd6 = NULL;
|
||||||
@@ -982,6 +1016,15 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_CONNTRACK
|
||||||
|
/* Copy connection mark of incoming query to outgoing connection. */
|
||||||
|
if (option_bool(OPT_CONNTRACK))
|
||||||
|
{
|
||||||
|
unsigned int mark;
|
||||||
|
if (get_incoming_mark(&orig->source, &orig->dest, 0, &mark))
|
||||||
|
setsockopt(fd, SOL_SOCKET, SO_MARK, &mark, sizeof(unsigned int));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (retry_send(sendto(fd, (char *)header, nn, 0,
|
while (retry_send(sendto(fd, (char *)header, nn, 0,
|
||||||
&server->addr.sa,
|
&server->addr.sa,
|
||||||
sa_len(&server->addr))));
|
sa_len(&server->addr))));
|
||||||
@@ -1044,7 +1087,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
else
|
else
|
||||||
header->hb4 &= ~HB4_CD;
|
header->hb4 &= ~HB4_CD;
|
||||||
|
|
||||||
if ((nn = process_reply(header, now, server, (size_t)n, check_rebind, no_cache_dnssec, cache_secure, bogusanswer,
|
if ((nn = process_reply(header, now, forward->sentto, (size_t)n, check_rebind, no_cache_dnssec, cache_secure, bogusanswer,
|
||||||
forward->flags & FREC_AD_QUESTION, forward->flags & FREC_DO_QUESTION,
|
forward->flags & FREC_AD_QUESTION, forward->flags & FREC_DO_QUESTION,
|
||||||
forward->flags & FREC_ADDED_PHEADER, forward->flags & FREC_HAS_SUBNET, &forward->source)))
|
forward->flags & FREC_ADDED_PHEADER, forward->flags & FREC_HAS_SUBNET, &forward->source)))
|
||||||
{
|
{
|
||||||
@@ -1405,20 +1448,24 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
static int tcp_key_recurse(time_t now, int status, struct dns_header *header, size_t n,
|
|
||||||
int class, char *name, char *keyname, struct server *server, int *keycount)
|
|
||||||
{
|
|
||||||
/* Recurse up the key heirarchy */
|
/* Recurse up the key heirarchy */
|
||||||
|
static int tcp_key_recurse(time_t now, int status, struct dns_header *header, size_t n,
|
||||||
|
int class, char *name, char *keyname, struct server *server,
|
||||||
|
int have_mark, unsigned int mark, int *keycount)
|
||||||
|
{
|
||||||
int new_status;
|
int new_status;
|
||||||
unsigned char *packet = NULL;
|
unsigned char *packet = NULL;
|
||||||
size_t m;
|
|
||||||
unsigned char *payload = NULL;
|
unsigned char *payload = NULL;
|
||||||
struct dns_header *new_header = NULL;
|
struct dns_header *new_header = NULL;
|
||||||
u16 *length = NULL;
|
u16 *length = NULL;
|
||||||
unsigned char c1, c2;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
int type = SERV_DO_DNSSEC;
|
||||||
|
char *domain;
|
||||||
|
size_t m;
|
||||||
|
unsigned char c1, c2;
|
||||||
|
|
||||||
/* limit the amount of work we do, to avoid cycling forever on loops in the DNS */
|
/* limit the amount of work we do, to avoid cycling forever on loops in the DNS */
|
||||||
if (--(*keycount) == 0)
|
if (--(*keycount) == 0)
|
||||||
new_status = STAT_ABANDONED;
|
new_status = STAT_ABANDONED;
|
||||||
@@ -1453,6 +1500,67 @@ static int tcp_key_recurse(time_t now, int status, struct dns_header *header, si
|
|||||||
|
|
||||||
*length = htons(m);
|
*length = htons(m);
|
||||||
|
|
||||||
|
/* Find server to forward to. This will normally be the
|
||||||
|
same as for the original query, but may be another if
|
||||||
|
servers for domains are involved. */
|
||||||
|
if (search_servers(now, NULL, F_QUERY, keyname, &type, &domain, NULL) == 0)
|
||||||
|
{
|
||||||
|
struct server *start = server, *new_server = NULL;
|
||||||
|
type &= ~SERV_DO_DNSSEC;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (type == (start->flags & SERV_TYPE) &&
|
||||||
|
(type != SERV_HAS_DOMAIN || hostname_isequal(domain, start->domain)) &&
|
||||||
|
!(start->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)))
|
||||||
|
{
|
||||||
|
new_server = start;
|
||||||
|
if (server == start)
|
||||||
|
{
|
||||||
|
new_server = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(start = start->next))
|
||||||
|
start = daemon->servers;
|
||||||
|
if (start == server)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (new_server)
|
||||||
|
{
|
||||||
|
server = new_server;
|
||||||
|
/* may need to make new connection. */
|
||||||
|
if (server->tcpfd == -1)
|
||||||
|
{
|
||||||
|
if ((server->tcpfd = socket(server->addr.sa.sa_family, SOCK_STREAM, 0)) == -1)
|
||||||
|
{
|
||||||
|
new_status = STAT_ABANDONED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CONNTRACK
|
||||||
|
/* Copy connection mark of incoming query to outgoing connection. */
|
||||||
|
if (have_mark)
|
||||||
|
setsockopt(server->tcpfd, SOL_SOCKET, SO_MARK, &mark, sizeof(unsigned int));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!local_bind(server->tcpfd, &server->source_addr, server->interface, 1) ||
|
||||||
|
connect(server->tcpfd, &server->addr.sa, sa_len(&server->addr)) == -1)
|
||||||
|
{
|
||||||
|
close(server->tcpfd);
|
||||||
|
server->tcpfd = -1;
|
||||||
|
new_status = STAT_ABANDONED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!read_write(server->tcpfd, packet, m + sizeof(u16), 0) ||
|
if (!read_write(server->tcpfd, packet, m + sizeof(u16), 0) ||
|
||||||
!read_write(server->tcpfd, &c1, 1, 1) ||
|
!read_write(server->tcpfd, &c1, 1, 1) ||
|
||||||
!read_write(server->tcpfd, &c2, 1, 1) ||
|
!read_write(server->tcpfd, &c2, 1, 1) ||
|
||||||
@@ -1464,7 +1572,7 @@ static int tcp_key_recurse(time_t now, int status, struct dns_header *header, si
|
|||||||
|
|
||||||
m = (c1 << 8) | c2;
|
m = (c1 << 8) | c2;
|
||||||
|
|
||||||
new_status = tcp_key_recurse(now, new_status, new_header, m, class, name, keyname, server, keycount);
|
new_status = tcp_key_recurse(now, new_status, new_header, m, class, name, keyname, server, have_mark, mark, keycount);
|
||||||
|
|
||||||
if (new_status != STAT_OK)
|
if (new_status != STAT_OK)
|
||||||
break;
|
break;
|
||||||
@@ -1508,10 +1616,31 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
socklen_t peer_len = sizeof(union mysockaddr);
|
socklen_t peer_len = sizeof(union mysockaddr);
|
||||||
int query_count = 0;
|
int query_count = 0;
|
||||||
unsigned char *pheader;
|
unsigned char *pheader;
|
||||||
|
unsigned int mark = 0;
|
||||||
|
int have_mark = 0;
|
||||||
|
|
||||||
|
(void)mark;
|
||||||
|
(void)have_mark;
|
||||||
|
|
||||||
if (getpeername(confd, (struct sockaddr *)&peer_addr, &peer_len) == -1)
|
if (getpeername(confd, (struct sockaddr *)&peer_addr, &peer_len) == -1)
|
||||||
return packet;
|
return packet;
|
||||||
|
|
||||||
|
#ifdef HAVE_CONNTRACK
|
||||||
|
/* Get connection mark of incoming query to set on outgoing connections. */
|
||||||
|
if (option_bool(OPT_CONNTRACK))
|
||||||
|
{
|
||||||
|
struct all_addr local;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (local_addr->sa.sa_family == AF_INET6)
|
||||||
|
local.addr.addr6 = local_addr->in6.sin6_addr;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
local.addr.addr4 = local_addr->in.sin_addr;
|
||||||
|
|
||||||
|
have_mark = get_incoming_mark(&peer_addr, &local, 1, &mark);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We can be configured to only accept queries from at-most-one-hop-away addresses. */
|
/* We can be configured to only accept queries from at-most-one-hop-away addresses. */
|
||||||
if (option_bool(OPT_LOCAL_SERVICE))
|
if (option_bool(OPT_LOCAL_SERVICE))
|
||||||
{
|
{
|
||||||
@@ -1637,7 +1766,7 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
{
|
{
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
struct all_addr *addrp = NULL;
|
struct all_addr *addrp = NULL;
|
||||||
int type = 0;
|
int type = SERV_DO_DNSSEC;
|
||||||
char *domain = NULL;
|
char *domain = NULL;
|
||||||
size_t new_size = add_edns0_config(header, size, ((unsigned char *) header) + 65536, &peer_addr, now, &check_subnet);
|
size_t new_size = add_edns0_config(header, size, ((unsigned char *) header) + 65536, &peer_addr, now, &check_subnet);
|
||||||
|
|
||||||
@@ -1650,9 +1779,7 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
if (gotname)
|
if (gotname)
|
||||||
flags = search_servers(now, &addrp, gotname, daemon->namebuff, &type, &domain, &norebind);
|
flags = search_servers(now, &addrp, gotname, daemon->namebuff, &type, &domain, &norebind);
|
||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
|
||||||
type &= ~SERV_DO_DNSSEC;
|
type &= ~SERV_DO_DNSSEC;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (type != 0 || option_bool(OPT_ORDER) || !daemon->last_server)
|
if (type != 0 || option_bool(OPT_ORDER) || !daemon->last_server)
|
||||||
last_server = daemon->servers;
|
last_server = daemon->servers;
|
||||||
@@ -1700,20 +1827,8 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
|
|
||||||
#ifdef HAVE_CONNTRACK
|
#ifdef HAVE_CONNTRACK
|
||||||
/* Copy connection mark of incoming query to outgoing connection. */
|
/* Copy connection mark of incoming query to outgoing connection. */
|
||||||
if (option_bool(OPT_CONNTRACK))
|
if (have_mark)
|
||||||
{
|
|
||||||
unsigned int mark;
|
|
||||||
struct all_addr local;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (local_addr->sa.sa_family == AF_INET6)
|
|
||||||
local.addr.addr6 = local_addr->in6.sin6_addr;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
local.addr.addr4 = local_addr->in.sin_addr;
|
|
||||||
|
|
||||||
if (get_incoming_mark(&peer_addr, &local, 1, &mark))
|
|
||||||
setsockopt(last_server->tcpfd, SOL_SOCKET, SO_MARK, &mark, sizeof(unsigned int));
|
setsockopt(last_server->tcpfd, SOL_SOCKET, SO_MARK, &mark, sizeof(unsigned int));
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((!local_bind(last_server->tcpfd, &last_server->source_addr, last_server->interface, 1) ||
|
if ((!local_bind(last_server->tcpfd, &last_server->source_addr, last_server->interface, 1) ||
|
||||||
@@ -1774,7 +1889,8 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
if (option_bool(OPT_DNSSEC_VALID) && !checking_disabled && (last_server->flags & SERV_DO_DNSSEC))
|
if (option_bool(OPT_DNSSEC_VALID) && !checking_disabled && (last_server->flags & SERV_DO_DNSSEC))
|
||||||
{
|
{
|
||||||
int keycount = DNSSEC_WORK; /* Limit to number of DNSSEC questions, to catch loops and avoid filling cache. */
|
int keycount = DNSSEC_WORK; /* Limit to number of DNSSEC questions, to catch loops and avoid filling cache. */
|
||||||
int status = tcp_key_recurse(now, STAT_OK, header, m, 0, daemon->namebuff, daemon->keyname, last_server, &keycount);
|
int status = tcp_key_recurse(now, STAT_OK, header, m, 0, daemon->namebuff, daemon->keyname,
|
||||||
|
last_server, have_mark, mark, &keycount);
|
||||||
char *result, *domain = "result";
|
char *result, *domain = "result";
|
||||||
|
|
||||||
if (status == STAT_ABANDONED)
|
if (status == STAT_ABANDONED)
|
||||||
|
|||||||
+8
-3
@@ -1119,7 +1119,7 @@ int random_sock(int family)
|
|||||||
if ((fd = socket(family, SOCK_DGRAM, 0)) != -1)
|
if ((fd = socket(family, SOCK_DGRAM, 0)) != -1)
|
||||||
{
|
{
|
||||||
union mysockaddr addr;
|
union mysockaddr addr;
|
||||||
unsigned int ports_avail = 65536u - (unsigned short)daemon->min_port;
|
unsigned int ports_avail = ((unsigned short)daemon->max_port - (unsigned short)daemon->min_port) + 1;
|
||||||
int tries = ports_avail < 30 ? 3 * ports_avail : 100;
|
int tries = ports_avail < 30 ? 3 * ports_avail : 100;
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
@@ -1132,7 +1132,7 @@ int random_sock(int family)
|
|||||||
{
|
{
|
||||||
unsigned short port = rand16();
|
unsigned short port = rand16();
|
||||||
|
|
||||||
if (daemon->min_port != 0)
|
if (daemon->min_port != 0 || daemon->max_port != MAX_PORT)
|
||||||
port = htons(daemon->min_port + (port % ((unsigned short)ports_avail)));
|
port = htons(daemon->min_port + (port % ((unsigned short)ports_avail)));
|
||||||
|
|
||||||
if (family == AF_INET)
|
if (family == AF_INET)
|
||||||
@@ -1442,7 +1442,9 @@ void check_servers(void)
|
|||||||
if (!(serv->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND)))
|
if (!(serv->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND)))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
if (option_bool(OPT_DNSSEC_VALID) && (serv->flags & SERV_HAS_DOMAIN))
|
if (option_bool(OPT_DNSSEC_VALID))
|
||||||
|
{
|
||||||
|
if (serv->flags & SERV_HAS_DOMAIN)
|
||||||
{
|
{
|
||||||
struct ds_config *ds;
|
struct ds_config *ds;
|
||||||
char *domain = serv->domain;
|
char *domain = serv->domain;
|
||||||
@@ -1458,6 +1460,9 @@ void check_servers(void)
|
|||||||
if (!ds)
|
if (!ds)
|
||||||
serv->flags &= ~SERV_DO_DNSSEC;
|
serv->flags &= ~SERV_DO_DNSSEC;
|
||||||
}
|
}
|
||||||
|
else if (serv->flags & SERV_FOR_NODOTS)
|
||||||
|
serv->flags &= ~SERV_DO_DNSSEC;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
port = prettyprint_addr(&serv->addr, daemon->namebuff);
|
port = prettyprint_addr(&serv->addr, daemon->namebuff);
|
||||||
|
|||||||
+31
-7
@@ -154,7 +154,9 @@ struct myoption {
|
|||||||
#define LOPT_HOST_INOTIFY 342
|
#define LOPT_HOST_INOTIFY 342
|
||||||
#define LOPT_DNSSEC_STAMP 343
|
#define LOPT_DNSSEC_STAMP 343
|
||||||
#define LOPT_TFTP_NO_FAIL 344
|
#define LOPT_TFTP_NO_FAIL 344
|
||||||
#define LOPT_DNS_CLIENT_ID 355
|
#define LOPT_MAXPORT 345
|
||||||
|
#define LOPT_CPE_ID 346
|
||||||
|
#define LOPT_SCRIPT_ARP 347
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
static const struct option opts[] =
|
static const struct option opts[] =
|
||||||
@@ -271,6 +273,7 @@ static const struct myoption opts[] =
|
|||||||
{ "dhcp-alternate-port", 2, 0, LOPT_ALTPORT },
|
{ "dhcp-alternate-port", 2, 0, LOPT_ALTPORT },
|
||||||
{ "dhcp-scriptuser", 1, 0, LOPT_SCRIPTUSR },
|
{ "dhcp-scriptuser", 1, 0, LOPT_SCRIPTUSR },
|
||||||
{ "min-port", 1, 0, LOPT_MINPORT },
|
{ "min-port", 1, 0, LOPT_MINPORT },
|
||||||
|
{ "max-port", 1, 0, LOPT_MAXPORT },
|
||||||
{ "dhcp-fqdn", 0, 0, LOPT_DHCP_FQDN },
|
{ "dhcp-fqdn", 0, 0, LOPT_DHCP_FQDN },
|
||||||
{ "cname", 1, 0, LOPT_CNAME },
|
{ "cname", 1, 0, LOPT_CNAME },
|
||||||
{ "pxe-prompt", 1, 0, LOPT_PXE_PROMT },
|
{ "pxe-prompt", 1, 0, LOPT_PXE_PROMT },
|
||||||
@@ -280,9 +283,9 @@ static const struct myoption opts[] =
|
|||||||
{ "dhcp-proxy", 2, 0, LOPT_PROXY },
|
{ "dhcp-proxy", 2, 0, LOPT_PROXY },
|
||||||
{ "dhcp-generate-names", 2, 0, LOPT_GEN_NAMES },
|
{ "dhcp-generate-names", 2, 0, LOPT_GEN_NAMES },
|
||||||
{ "rebind-localhost-ok", 0, 0, LOPT_LOC_REBND },
|
{ "rebind-localhost-ok", 0, 0, LOPT_LOC_REBND },
|
||||||
{ "add-mac", 0, 0, LOPT_ADD_MAC },
|
{ "add-mac", 2, 0, LOPT_ADD_MAC },
|
||||||
{ "add-subnet", 2, 0, LOPT_ADD_SBNET },
|
{ "add-subnet", 2, 0, LOPT_ADD_SBNET },
|
||||||
{ "add-dns-client", 2, 0 , LOPT_DNS_CLIENT_ID },
|
{ "add-cpe-id", 1, 0 , LOPT_CPE_ID },
|
||||||
{ "proxy-dnssec", 0, 0, LOPT_DNSSEC },
|
{ "proxy-dnssec", 0, 0, LOPT_DNSSEC },
|
||||||
{ "dhcp-sequential-ip", 0, 0, LOPT_INCR_ADDR },
|
{ "dhcp-sequential-ip", 0, 0, LOPT_INCR_ADDR },
|
||||||
{ "conntrack", 0, 0, LOPT_CONNTRACK },
|
{ "conntrack", 0, 0, LOPT_CONNTRACK },
|
||||||
@@ -315,6 +318,7 @@ static const struct myoption opts[] =
|
|||||||
{ "quiet-dhcp6", 0, 0, LOPT_QUIET_DHCP6 },
|
{ "quiet-dhcp6", 0, 0, LOPT_QUIET_DHCP6 },
|
||||||
{ "quiet-ra", 0, 0, LOPT_QUIET_RA },
|
{ "quiet-ra", 0, 0, LOPT_QUIET_RA },
|
||||||
{ "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT },
|
{ "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT },
|
||||||
|
{ "script-arp", 0, 0, LOPT_SCRIPT_ARP },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -412,6 +416,7 @@ static struct {
|
|||||||
{ '6', ARG_ONE, "<path>", gettext_noop("Shell script to run on DHCP lease creation and destruction."), NULL },
|
{ '6', ARG_ONE, "<path>", gettext_noop("Shell script to run on DHCP lease creation and destruction."), NULL },
|
||||||
{ LOPT_LUASCRIPT, ARG_DUP, "path", gettext_noop("Lua script to run on DHCP lease creation and destruction."), NULL },
|
{ LOPT_LUASCRIPT, ARG_DUP, "path", gettext_noop("Lua script to run on DHCP lease creation and destruction."), NULL },
|
||||||
{ LOPT_SCRIPTUSR, ARG_ONE, "<username>", gettext_noop("Run lease-change scripts as this user."), NULL },
|
{ LOPT_SCRIPTUSR, ARG_ONE, "<username>", gettext_noop("Run lease-change scripts as this user."), NULL },
|
||||||
|
{ LOPT_SCRIPT_ARP, OPT_SCRIPT_ARP, NULL, gettext_noop("Call dhcp-script with changes to local ARP table."), NULL },
|
||||||
{ '7', ARG_DUP, "<path>", gettext_noop("Read configuration from all the files in this directory."), NULL },
|
{ '7', ARG_DUP, "<path>", gettext_noop("Read configuration from all the files in this directory."), NULL },
|
||||||
{ '8', ARG_ONE, "<facilty>|<file>", gettext_noop("Log to this syslog facility or file. (defaults to DAEMON)"), NULL },
|
{ '8', ARG_ONE, "<facilty>|<file>", gettext_noop("Log to this syslog facility or file. (defaults to DAEMON)"), NULL },
|
||||||
{ '9', OPT_LEASE_RO, NULL, gettext_noop("Do not use leasefile."), NULL },
|
{ '9', OPT_LEASE_RO, NULL, gettext_noop("Do not use leasefile."), NULL },
|
||||||
@@ -438,6 +443,7 @@ static struct {
|
|||||||
{ LOPT_ALTPORT, ARG_ONE, "[=<ports>]", gettext_noop("Use alternative ports for DHCP."), NULL },
|
{ LOPT_ALTPORT, ARG_ONE, "[=<ports>]", gettext_noop("Use alternative ports for DHCP."), NULL },
|
||||||
{ LOPT_NAPTR, ARG_DUP, "<name>,<naptr>", gettext_noop("Specify NAPTR DNS record."), NULL },
|
{ LOPT_NAPTR, ARG_DUP, "<name>,<naptr>", gettext_noop("Specify NAPTR DNS record."), NULL },
|
||||||
{ LOPT_MINPORT, ARG_ONE, "<port>", gettext_noop("Specify lowest port available for DNS query transmission."), NULL },
|
{ LOPT_MINPORT, ARG_ONE, "<port>", gettext_noop("Specify lowest port available for DNS query transmission."), NULL },
|
||||||
|
{ LOPT_MAXPORT, ARG_ONE, "<port>", gettext_noop("Specify highest port available for DNS query transmission."), NULL },
|
||||||
{ LOPT_DHCP_FQDN, OPT_DHCP_FQDN, NULL, gettext_noop("Use only fully qualified domain names for DHCP clients."), NULL },
|
{ LOPT_DHCP_FQDN, OPT_DHCP_FQDN, NULL, gettext_noop("Use only fully qualified domain names for DHCP clients."), NULL },
|
||||||
{ LOPT_GEN_NAMES, ARG_DUP, "[=tag:<tag>]", gettext_noop("Generate hostnames based on MAC address for nameless clients."), NULL},
|
{ LOPT_GEN_NAMES, ARG_DUP, "[=tag:<tag>]", gettext_noop("Generate hostnames based on MAC address for nameless clients."), NULL},
|
||||||
{ LOPT_PROXY, ARG_DUP, "[=<ipaddr>]...", gettext_noop("Use these DHCP relays as full proxies."), NULL },
|
{ LOPT_PROXY, ARG_DUP, "[=<ipaddr>]...", gettext_noop("Use these DHCP relays as full proxies."), NULL },
|
||||||
@@ -446,9 +452,9 @@ static struct {
|
|||||||
{ LOPT_PXE_PROMT, ARG_DUP, "<prompt>,[<timeout>]", gettext_noop("Prompt to send to PXE clients."), NULL },
|
{ LOPT_PXE_PROMT, ARG_DUP, "<prompt>,[<timeout>]", gettext_noop("Prompt to send to PXE clients."), NULL },
|
||||||
{ LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL },
|
{ LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL },
|
||||||
{ LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL },
|
{ LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL },
|
||||||
{ LOPT_ADD_MAC, OPT_ADD_MAC, NULL, gettext_noop("Add requestor's MAC address to forwarded DNS queries."), NULL },
|
{ LOPT_ADD_MAC, ARG_DUP, "[=base64]", gettext_noop("Add requestor's MAC address to forwarded DNS queries."), NULL },
|
||||||
{ LOPT_ADD_SBNET, ARG_ONE, "<v4 pref>[,<v6 pref>]", gettext_noop("Add specified IP subnet to forwarded DNS queries."), NULL },
|
{ LOPT_ADD_SBNET, ARG_ONE, "<v4 pref>[,<v6 pref>]", gettext_noop("Add specified IP subnet to forwarded DNS queries."), NULL },
|
||||||
{ LOPT_DNS_CLIENT_ID, ARG_ONE, "<proxyname>", gettext_noop("Add client identification to forwarded DNS queries."), NULL },
|
{ LOPT_CPE_ID, ARG_ONE, "<text>", gettext_noop("Add client identification to forwarded DNS queries."), NULL },
|
||||||
{ LOPT_DNSSEC, OPT_DNSSEC_PROXY, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers."), NULL },
|
{ LOPT_DNSSEC, OPT_DNSSEC_PROXY, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers."), NULL },
|
||||||
{ LOPT_INCR_ADDR, OPT_CONSEC_ADDR, NULL, gettext_noop("Attempt to allocate sequential IP addresses to DHCP clients."), NULL },
|
{ LOPT_INCR_ADDR, OPT_CONSEC_ADDR, NULL, gettext_noop("Attempt to allocate sequential IP addresses to DHCP clients."), NULL },
|
||||||
{ LOPT_CONNTRACK, OPT_CONNTRACK, NULL, gettext_noop("Copy connection-track mark from queries to upstream connections."), NULL },
|
{ LOPT_CONNTRACK, OPT_CONNTRACK, NULL, gettext_noop("Copy connection-track mark from queries to upstream connections."), NULL },
|
||||||
@@ -2153,12 +2159,24 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOPT_DNS_CLIENT_ID: /* --add-dns-client */
|
case LOPT_CPE_ID: /* --add-dns-client */
|
||||||
set_option_bool(OPT_DNS_CLIENT);
|
|
||||||
if (arg)
|
if (arg)
|
||||||
daemon->dns_client_id = opt_string_alloc(arg);
|
daemon->dns_client_id = opt_string_alloc(arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LOPT_ADD_MAC:
|
||||||
|
if (!arg)
|
||||||
|
set_option_bool(OPT_ADD_MAC);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unhide_metas(arg);
|
||||||
|
if (strcmp(arg, "base64") == 0)
|
||||||
|
set_option_bool(OPT_MAC_B64);
|
||||||
|
else
|
||||||
|
ret_err(gen_err);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'u': /* --user */
|
case 'u': /* --user */
|
||||||
daemon->username = opt_string_alloc(arg);
|
daemon->username = opt_string_alloc(arg);
|
||||||
break;
|
break;
|
||||||
@@ -2512,6 +2530,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LOPT_MAXPORT: /* --max-port */
|
||||||
|
if (!atoi_check16(arg, &daemon->max_port))
|
||||||
|
ret_err(gen_err);
|
||||||
|
break;
|
||||||
|
|
||||||
case '0': /* --dns-forward-max */
|
case '0': /* --dns-forward-max */
|
||||||
if (!atoi_check(arg, &daemon->ftabsize))
|
if (!atoi_check(arg, &daemon->ftabsize))
|
||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
@@ -4462,6 +4485,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
daemon->soa_refresh = SOA_REFRESH;
|
daemon->soa_refresh = SOA_REFRESH;
|
||||||
daemon->soa_retry = SOA_RETRY;
|
daemon->soa_retry = SOA_RETRY;
|
||||||
daemon->soa_expiry = SOA_EXPIRY;
|
daemon->soa_expiry = SOA_EXPIRY;
|
||||||
|
daemon->max_port = MAX_PORT;
|
||||||
|
|
||||||
add_txt("version.bind", "dnsmasq-" VERSION, 0 );
|
add_txt("version.bind", "dnsmasq-" VERSION, 0 );
|
||||||
add_txt("authors.bind", "Simon Kelley", 0);
|
add_txt("authors.bind", "Simon Kelley", 0);
|
||||||
|
|||||||
+1
-3
@@ -896,9 +896,7 @@ size_t setup_reply(struct dns_header *header, size_t qlen,
|
|||||||
header->nscount = htons(0);
|
header->nscount = htons(0);
|
||||||
header->arcount = htons(0);
|
header->arcount = htons(0);
|
||||||
header->ancount = htons(0); /* no answers unless changed below */
|
header->ancount = htons(0); /* no answers unless changed below */
|
||||||
if (flags == F_NEG)
|
if (flags == F_NOERR)
|
||||||
SET_RCODE(header, SERVFAIL); /* couldn't get memory */
|
|
||||||
else if (flags == F_NOERR)
|
|
||||||
SET_RCODE(header, NOERROR); /* empty domain */
|
SET_RCODE(header, NOERROR); /* empty domain */
|
||||||
else if (flags == F_NXDOMAIN)
|
else if (flags == F_NXDOMAIN)
|
||||||
SET_RCODE(header, NXDOMAIN);
|
SET_RCODE(header, NXDOMAIN);
|
||||||
|
|||||||
Reference in new issue
Block a user