How do I simulate a DNS server returning a SERVFAIL in response to a A query?

1

Goal

When an A query returns an NXDOMAIN response, my java app throws an UnknownHostException. I would like to know if a SERVFAIL response from DNS servers caused java to throw this error as well.

Idea

  • Is it possible to run dnsmasq and make it return a SERVFAIL for any FQDN ?
  • Is it simple enough to write a listener on port 53 to listen for UDP requests and return a SERVFAIL ?

socgen hacker

Posted 2015-07-24T20:01:44.663

Reputation: 267

I'm sure dnsmasq would do that if you pointed it to an unreachable upstream --server, as would Bind9 and Unbound. One of the SERVFAIL meanings is "I couldn't reach the upstream server." – user1686 – 2015-07-24T20:45:05.633

Answers

0

Yes, you can. As Java programmer, I would point you to Java implementation of a simple DNS server: http://sourceforge.net/projects/dnsjava/

Take it, edit the source to return SERVFAIL, shutdown your DNS service, compile and run dnsjava

Pavel Bernshtam

Posted 2015-07-24T20:01:44.663

Reputation: 131

Sound like what I want, let me take a look at the source first. – socgen hacker – 2015-07-24T20:58:51.697