The dnsreflector daemon listens for DNS queries on a local UDP port

and answers with records pointing back to localhost. Combined with
packet filter pf(4) this works as a bandwidth efficient spamtrap.

WWW: http://www.wolfermann.org/dnsreflector.html

PR:		ports/135077
Submitted by:	ismail.yenigul at endersys.com.tr
This commit is contained in:
Martin Wilke 2009-05-30 18:43:33 +00:00
parent f82fc5825c
commit bf21c8ac85
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=234846
7 changed files with 148 additions and 0 deletions

View File

@ -35,6 +35,7 @@
SUBDIR += dnsmax-perl
SUBDIR += dnsperf
SUBDIR += dnsproxy
SUBDIR += dnsreflector
SUBDIR += dnstop
SUBDIR += dnstracer
SUBDIR += dnsutl

31
dns/dnsreflector/Makefile Normal file
View File

@ -0,0 +1,31 @@
# New ports collection makefile for: dnsreflector
# Date created: May 30 2009
# Whom: ismail.yenigul@endersys.com.tr
#
# $FreeBSD$
#
PORTNAME= dnsreflector
PORTVERSION= 1.02
CATEGORIES= dns
MASTER_SITES= http://www.wolfermann.org/
MAINTAINER= ismail.yenigul@endersys.com.tr
COMMENT= Listens for DNS queries on a UDP port and change the answer
USE_RC_SUBR= dnsreflector
MAN1= dnsreflector.1
PORTDOCS= README
PLIST_FILES= sbin/dnsreflector
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/dnsreflector ${PREFIX}/sbin
${INSTALL_DATA} ${WRKSRC}/dnsreflector.1 ${MANPREFIX}/man/man1/
.if !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}
.endif
.include <bsd.port.mk>

View File

@ -0,0 +1,3 @@
MD5 (dnsreflector-1.02.tar.gz) = 119c9d1e4949840319aec5def44e1d55
SHA256 (dnsreflector-1.02.tar.gz) = 5c838485167b3288fffeaceab840c31536290f3734a118713e22eb9811ce142a
SIZE (dnsreflector-1.02.tar.gz) = 4324

View File

@ -0,0 +1,32 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: dnsreflector
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Define these dnsreflector_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
#
# dnsreflector_enable="YES" # Run the dnsreflector(1) daemon (YES/NO).
# dnsreflector_flags="" # Extra flags for dnsreflector(1) (if enabled).
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
dnsreflector_enable=${dnsreflector_enable:-"NO"}
command_args=${dnsreflector_flags:-"-d -a 127.0.0.1 -p 53000"}
. %%RC_SUBR%%
name="dnsreflector"
rcvar=`set_rcvar`
command="%%PREFIX%%/sbin/dnsreflector"
load_rc_config $name
run_rc_command "$1"

View File

@ -0,0 +1,36 @@
--- Makefile.orig 2003-05-01 16:12:56.000000000 +0300
+++ Makefile 2009-05-30 15:06:02.000000000 +0300
@@ -1,25 +1,12 @@
-# $Id: Makefile,v 1.7 2003/05/01 13:12:56 armin Exp $
-PROG=dnsreflector
-SRCS=dnsreflector.c
-MAN=dnsreflector.1
+OBJS = dnsreflector.o
+CFLAGS = -g -Wall -Werror
+CC = gcc
+STRIP = strip
-BINDIR=/usr/local/sbin
-MANDIR=/usr/local/man/cat
+all: $(OBJS)
+ $(CC) -o dnsreflector $(OBJS) $(CFLAGS)
-CFLAGS+=-g -Wall -Werror
+clean:
+ rm -f dnsreflector *.o core.* *~
-VERS=1.02
-LVERS="$(PROG) $(VERS) (`date +%Y-%b-%d`)"
-dist:
- rm -rf /tmp/dnsreflector-$(VERS)/
- mkdir /tmp/dnsreflector-$(VERS)/
- cp -pR * /tmp/dnsreflector-$(VERS)/
- cd /tmp/dnsreflector-$(VERS)/ && make cleandir
- cd /tmp/dnsreflector-$(VERS)/ && rm -rf ./CVS/
- (echo $(LVERS); cat README) >/tmp/dnsreflector-$(VERS)/README
- cd /tmp && tar cf dnsreflector-$(VERS).tar ./dnsreflector-$(VERS)/
- cd /tmp && gzip -f9 dnsreflector-$(VERS).tar
- cd /tmp && rm -rf ./dnsreflector-$(VERS)/
-
-.include <bsd.prog.mk>

View File

@ -0,0 +1,40 @@
--- dnsreflector.c.orig 2009-05-30 14:02:43.000000000 +0300
+++ dnsreflector.c 2009-05-30 14:04:31.000000000 +0300
@@ -87,8 +87,7 @@
#define MAXQUERY (PACKETSZ - sizeof(ADDITIONAL) - sizeof(AUTHORITY) - sizeof(ANSWER_AAAA))
-static struct syslog_data sdata = SYSLOG_DATA_INIT;
-
+static int daemonize = 0;
static void
logit(int level, const char *fmt, ...)
{
@@ -97,8 +96,8 @@
va_start(ap, fmt);
- if (sdata.opened) {
- vsyslog_r(level, &sdata, fmt, ap);
+ if (daemonize) {
+ vsyslog(level, fmt, ap);
} else {
fprintf(stderr, "%s: ", __progname);
vfprintf(stderr, fmt, ap);
@@ -148,7 +147,6 @@
/* Options and their defaults */
char *address = NULL;
- int daemonize = 0;
int port = 53000;
/* Process commandline arguments */
@@ -186,8 +184,6 @@
/* Use syslog if daemonized */
if (daemonize) {
tzset();
- openlog_r("dnsreflector", LOG_PID | LOG_NDELAY, LOG_DAEMON,
- &sdata);
}
/* Daemonize if requested */

View File

@ -0,0 +1,5 @@
The dnsreflector daemon listens for DNS queries on a local UDP port
and answers with records pointing back to localhost. Combined with
packet filter pf(4) this works as a bandwidth efficient spamtrap.
WWW: http://www.wolfermann.org/dnsreflector.html