mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-26 20:48:32 +00:00
Default min-port to 1024 to avoid reserved ports.
This commit is contained in:
1 parent
486bcd5a7b
commit
baf553db0c
5 files changed
+5
-8
No files matched your search
+2
-1
@@ -182,7 +182,8 @@ OS: this was the default behaviour in versions prior to 2.43.
|
|||||||
Do not use ports less than that given as source for outbound DNS
|
Do not use ports less than that given as source for outbound DNS
|
||||||
queries. Dnsmasq picks random ports as source for outbound queries:
|
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. If not specified,
|
||||||
|
defaults to 1024.
|
||||||
.TP
|
.TP
|
||||||
.B --max-port=<port>
|
.B --max-port=<port>
|
||||||
Use ports lower than that given as source for outbound DNS queries.
|
Use ports lower than that given as source for outbound DNS queries.
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#define NAMESERVER_PORT 53
|
#define NAMESERVER_PORT 53
|
||||||
#define TFTP_PORT 69
|
#define TFTP_PORT 69
|
||||||
|
#define MIN_PORT 1024 /* first non-reserved port */
|
||||||
#define MAX_PORT 65535u
|
#define MAX_PORT 65535u
|
||||||
|
|
||||||
#define IN6ADDRSZ 16
|
#define IN6ADDRSZ 16
|
||||||
|
|||||||
@@ -224,9 +224,6 @@ 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)
|
if (daemon->max_port < daemon->min_port)
|
||||||
die(_("max_port cannot be smaller than min_port"), NULL, EC_BADCONF);
|
die(_("max_port cannot be smaller than min_port"), NULL, EC_BADCONF);
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -1149,10 +1149,7 @@ int random_sock(int family)
|
|||||||
if (fix_fd(fd))
|
if (fix_fd(fd))
|
||||||
while(tries--)
|
while(tries--)
|
||||||
{
|
{
|
||||||
unsigned short port = rand16();
|
unsigned short port = htons(daemon->min_port + (rand16() % ((unsigned short)ports_avail)));
|
||||||
|
|
||||||
if (daemon->min_port != 0 || daemon->max_port != MAX_PORT)
|
|
||||||
port = htons(daemon->min_port + (port % ((unsigned short)ports_avail)));
|
|
||||||
|
|
||||||
if (family == AF_INET)
|
if (family == AF_INET)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4653,6 +4653,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
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;
|
daemon->max_port = MAX_PORT;
|
||||||
|
daemon->min_port = MIN_PORT;
|
||||||
|
|
||||||
#ifndef NO_ID
|
#ifndef NO_ID
|
||||||
add_txt("version.bind", "dnsmasq-" VERSION, 0 );
|
add_txt("version.bind", "dnsmasq-" VERSION, 0 );
|
||||||
|
|||||||
Reference in new issue
Block a user