COSC 4377 - Introduction to Computer Networks

Spring 2012

MW 1:00-2:30pm at PGH347

InstructorOmprakash Gnawali

Homework 11 : DNS Server

Due: midnight April 18, 2012

In this assignment, we will implement a DNS server. While a full-featured DNS server is a complex software, our DNS server only supports one type of query: A records.

DNS protocol

Unlike other protocols we have implemented in this course so far, DNS protocol uses binary format. What that means is you will not be able to print the messages transmitted and received as string to debug your implementation. Often you wil have to look at individual bits to understand the messages. When you are sending messages, you will have to set individual bits.

A good place to start would be to read this RFC 1035 that describes the basic DNS names and protocols.

Implementation Guide

DNS server is a socket program that listens on a well known port (53). The clients that need to find an IP address for a name, send their request to the server running at that port. In response, the clients receive an answer from the server. In this assignment we will use the C programming language to implement our DNS server.

Focus on understanding how an A record query is formatted. Once you understand that, you should be able to print the A record request. Specifically, you should be able to print the domain name in the query as string to the stdout of the server. For example, if we send a request to the server to find the IP address for "", we need to first be able to correctly parse this name at the server.

Once you know how to extract the name in the query, you need to learn how to send a response. You can read the RFC to understand how to format the response.


Because you will be running your DNS server on the port you were assigned, we cannot use a standard DNS query. We need to send our DNS query to a server running at a specific port. The "dig" command allows you to specify the port number of the server. Learn how to use dig to send a query for a name to your DNS server. You can print the query name on the server.

We will execute your DNS server as:

./dnsserver -p 

For example:

./dnsserver -p 10001

The example above will launch the DNS server on port 10001.

Your DNS server must return these IP addresses for these names:
NameIP address


  1. What is the difference between text and binary protocols?
  2. Are most protocols in the Internet binary or text?


Please include the source(s) and Makefile in a folder with the name: uhid_hw11, where uhid is the prefix of your email address. Then, zip the directory and upload the zip file using Blackboard. Your program must compile and execute on bayou.