tags:

views:

549

answers:

6

I would like to have a local DNS server which I can configure in some way. Maybe a php script, which gets the requested hostname and returns the IP. I don't want to have an IP/Hostname list, but I want to generate the IPs in code! Do you know how to do this?

A: 

How about utilizing your hosts file?

leppie
As I said, I don't want a list of ips and hostnames, but I want to generate the IP dynamically in code. And I don't want to code the whole dns protocol on my own.. ;)
eWolf
Please Google for the hosts file, there is no implementation. Just a simple text mapping of a hostname to an ip.
leppie
See my comment above. In the hosts file, ther is no implementation, but I want one!!>> For every DNS request, I want to send another request to another server (in the internet) which returns me the IP (it's not a DNS server, of course). So caching is no problem, but I also can't put all IPs in the hosts file..
eWolf
+1  A: 

I think that host file should be your option.

Client and other DNS server caches DNS queries anyway therefore there is no reason why to generate these on the fly. You have to refresh host file periodically.

Jiri
A: 

I'm not quite sure what it is that you want, but many routers have a built in DNS capability which is usually very easy to use.

GameFreak
+3  A: 

Simple DNS Plus has several APIs (plain HTTP, .NET, COM, command line) that are easy to use.

For example, you could add an IP-address (A-record) by seding it a simple HTTP request like "http://127.0.0.1:8053/updatehost?host=test.example.com&data=1.2.3.4" - which you could issue from your PHP script with the standard cURL library.

Jesper
Sounds great. I'll try it. =)
eWolf
A: 

Maybe MyDNS is something to look into. It gets the IPs from a database (MySQL or PostgreSQL).

I don't know if it can be hooked directly to another source. But maybe it is wiser to decouple that and let the database be updated from the internet-source and let the DNS system query the database.

Ansgar