Project 2 Dynamic DNS Part A October 28 2008 Due Nov 12 11 59 59 pm EE122 Introduction to Communication Networks Fall 2008 Department of Electrical Engineering and Computer Science College of Engineering University of California Berkeley 1 Overview In this project you will implement a DNS server system The project has two parts Part A Dynamic Domain Name System DNS server and client Part B Peer to peer gossiping with the other DNS servers to learn DNS records This document describes Part A Your DNS server will implement a limited version of the real DNS protocol Your server will interoperate with the live Internet DNS system For example You will be able to query your server with standard commands like nslookup and dig We will give you your own publicly accessible subdomain to be served by your server Within this subdomain you will be able to create your own names that anyone on the Internet can use If you d like and if you have your own server on which to run it you can even purchase your own domain name and use your server to serve it Surprisingly ee122madeallmydreamscometrue com is unclaimed as of this writing Standard old DNS servers like named on Unix learn their name to IP address mappings by reading a configuration file Your server however will be much much slicker Specifically it will accept mapping messages over the network from a dynamic DNS client You can run the client on your laptop so when you move around from one wireless network to another and thus change IP addresses your laptop will always be available at the same DNS name This is similar to services such as DynDNS com Key concepts in Part A of the project include Working with a real protocol Use of UDP Use of soft state 1 2 Command line interfaces Server Your server should take one command line argument a port to which to bind accepting incoming UDP DNS queries For example we should be able to run it on port 6001 like this server 6001 It should then keep running waiting for and replying to queries until it is killed manually Your server doesn t need to print anything out to the console although this will help you in debugging Recall that the DNS protocol expects servers to run on port 53 But only root can bind to ports 1023 or less So to run on the instructional machines you ll have to use a port number of 1024 or greater It goes without saying that your server should not crash regardless of what it receives over the network and should not have memory leaks Client The dynamic DNS client should accept four arguments a server IP server port a domain name a corresponding IP address and a TTL For example client 128 32 48 169 6001 mylaptop fakedomain com 128 2 1 2 120 The client should then contact the server at the given IP here 128 32 48 169 and port 6001 using the protocols described in Section 3 below It should tell the server to install the given mapping mylaptop fakedomain com 128 2 1 2 for the given amount of time 120 seconds If this all works you should be able to query the server within the next two minutes nslookup mylaptop fakedomain com 128 32 48 169 port 6001 and get a reply showing the IP address 128 2 1 2 3 Network protocol and semantics Having specified the interface between humans and your programs in the previous section we now specify the interface between the programs themselves across the network Your server will accept and reply to DNS Question messages on UDP The client will install mappings in the server by sending a DNS Response message to the server Hence it all comes down to the DNS protocol Next we give a detailed description of the DNS protocol followed by how it should be used by your client and server The DNS protocol A DNS datagram is formatted as follows 16 bits I DENTIFICATION Set by the client when it sends a query the server should keep this the same in its reply allowing the client to match up the response with the request 16 bits PARAMETER An assortment of bits annotating the query or response indicating error conditions and so on As a simplification of the protocol you don t need to deal with most of these Handle the bits as follows Bit 0 is set to 0 in queries and 1 in responses When your server gets a name lookup query this bit will be set to 0 its reply should set the bit to 1 To install a name mapping your dynamic client should send a message to the server with this bit set to 1 2 Bit 5 is set to 1 if the message is a response and the answer is authoritative otherwise the bit is set to 0 Your server should act as the authoritative name server for all names installed in it by your dynamic client All other bits in the parameter field should be ignored in messages you receive and should be set to 0 in messages that you send 16 bits 4 N UMBER OF QUESTIONS N UMBER OF ANSWERS N UMBER OF AUTHORITY N UMBER OF ADDITIONAL in that order These integers specify the number of entries in the corresponding four sections which follow As a simplification of the protocol you may assume that the N UMBER OF QUESTIONS and N UMBER OF ANSWERS are are either 0 or 1 and the N UMBER OF AUTHORITY and N UMBER OF ADDITIONAL are always 0 Variable length Q UESTION SECTION This section contains zero or more questions the number of which is specified above You ll need to deal only with zero or one questions Each question has the following format Variable length D OMAIN NAME This is the name that the querier wishes to be translated to an IP address It is not just a sequence of characters instead it uses a representation that can compresses the size if there are many names similar names mentioned in this datagram Good news we will give you code to translate from this format to a standard string and vice versa If you want you can also implement this yourself 16 bits T YPE This integer can take any one of dozens of values specifying the type of query including some corresponding to types we discussed in lecture like A CNAME and MX As a simplification of the protocol your server can assume that the query type is always A in which case this field has the value 1 not 4 as previously advertised 16 bits C LASS This integer describes the type of address requested in the reply For the purposes of this project this value should always be set to 1 which corresponds to the Internet class Although several other classes are defined they are not used in practice Variable length A NSWER SECTION This section contains zero or more answers the number of which is specified above You ll need to deal only …
View Full Document