Writing a catch-all

Patrick Goggins pgoggins at cc.edu
Mon Mar 23 22:34:12 EDT 2009


Excellent! Just what I was looking for.



~Patrick


-----Original Message-----
From: list-bounces at maradns.org [mailto:list-bounces at maradns.org] On
Behalf Of Sam Trenholme
Sent: Monday, March 23, 2009 4:43 PM
To: list at maradns.org
Subject: Re: Writing a catch-all

> I've just started using maradns and am trying to write a catch-all so
> all requests resolve to the same ip.

Well, you can use csv2_default_zonefile to do this, or you can
download and use a program far simpler than MaraDNS to do this:

/*Placed in the public domain by Sam Trenholme*/
#include <arpa/inet.h>
#include <string.h>
#define Z struct sockaddr
#define Y sizeof(d)
int main(int a,char **b){int i;char q[512],p[17
]="\xc0\f\0\x01\0\x01\0\0\0\0\0\x04";if(a>1){a=
socket(AF_INET,SOCK_DGRAM,0);struct sockaddr_in
d;bzero(&d,Y);d.sin_port=htons(53);*((int *)(p+
12))=inet_addr(b[1]);d.sin_family=AF_INET;bind(
a,(Z*)&d,Y);socklen_t f=511;for(;;){i=recvfrom(
a,q,255,0,(Z*)&d,&f);if(i>9&&q[2]>=0){q[7]++;q[
2]|=128;memcpy(q+i,p,16);sendto(a,q,i+16,0,(Z*)
&d,Y);}}}return 0;}

(note that this will only work on a 32-bit machine)

I have a more readable form of this program (that, yes, will work on a
64-bit machine and what not) which you are free to use here:

http://www.samiam.org/software/microdns.html

- Sam


More information about the list mailing list