19
4
I want to do some tests on linux. I want to put a small web server on a machine with IP: 1.2.3.4 (assumption) and when a DNS query is made for a specific URL : kitty.myweb.com I want to return this IP address.
Scenarios:
- When I open a browser(firefox or whatever), I input the URL kitty.myweb.com and the browser will do the DNS query
- I want to write a program which does the DNS query for kitty.myweb.com
I know that each computer has a local DNS resolver which caches some entries; a call to a URL will query the local DNS resolver first, and if there is no corresponding entries it will send the query to an external DNS resolver on the LAN or Internet.
What I want to is to add an entry(kitty.myweb.com : 1.2.3.4) to the local DNS resolver, so that for the 2 scenarios above, the DNS response will be 1.2.3.4 without having to make an external query.
Is it possible to do this on linux, and if so, how? Are there perhaps any C code snippets that would do this?