Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Very simple DNS server

Tags:

c

linux

perl

dns

I have a linux server has an ad-hoc wireless network for clients to connect to. Once connected I want users to always be redirected to it's own web server no matter what URL they type in. The large solution would be to set up a full DNS server (with BIND or equivalent) but that seems like overkill. All I need is a simple program that will listen for any DNS request and always respond with the same IP address.

I looked around for one but couldn't seem to find one. It would preferably be written in C or Perl as I don't really want to install any other scripting languages.

like image 747
jasonlfunk Avatar asked Jun 14 '12 16:06

jasonlfunk


2 Answers

Use Net::DNS::Nameserver and write your own reply handler.

For C, look at:

  • How to Build a custom simple DNS server in C/C++
  • Create custom DNS name server in C
like image 155
Boris Ivanov Avatar answered Oct 01 '22 19:10

Boris Ivanov


I would suggest using dnsmasq. It's more full-featured than you absolutely need, but it's very well-written, small, and easy to install, and the only configuration you would need to give it is --address='/#/1.2.3.4' to tell it to answer all queries (that don't match some other rule) with the address 1.2.3.4. dnsmasq is well-known and maintained and probably a more robust server than Net::DNS::Nameserver.

like image 39
hobbs Avatar answered Oct 01 '22 19:10

hobbs