If the goal is to learn how to write one, use Sergey's suggestion.
Otherwise, if you are only interested in a solution to solve your problem, I'd recommend simply installing existing DNS server software on a "server" on your LAN and point your PCs to use it as their DNS server.
A search of Linux repositories turns up a number of them, or, on Windows, you could use this:
http://maradns.samiam.org