DNS and DHCP

 

DHCP and DNS are two essential services to make IT administrators life easier, DHCP has the capability of automatically assigning IP addresses to devices and DNS has the capability of mapping those IP’s to human readable names, let’s dive into it !

DHCP

Device network parameters such as ip addresses , subnet masks, default gateways , DNS servers can be assigned in two ways, dynamically and statically by DHCP. Best practices :

  • Use static addresses for all shared network systems such as routers and servers
  • Use dynamic addresses all client systems such as PC’s phones or laptops.

Wait a minute. What is DHCP ?Well, DHCP stands for the Dynamic Host Configuration Protocol , it provides a way to dynamically configure hosts on a network. Defined in RFC 2131 , DHCP improves on its predecessor BOOTP in many ways, first of all it it introduces the mechanism of using a “lease” for IP addresses, which is basically a defined period of time for which a DHCP client will hold his IP address. Routers can act as agents to relay DHCP messages from client to server. DHCP server Uses port 67 and clients use port 68 . DHCP has 3 ways of allocating addresses :

  • Manual : Server Admin configured the DHCP Server to match an IP address with a MAC address so a client that contacts the DHCP with that MAC will always recieve the same address
  • Automatic : DHCP server will hand out an IP address to a host but  permanently allocate that IP to that client
  • Dynamic : DHCP Server will hand out an IP for a limited time or until the host explicitly releases that address. Addresses can be released manually by the client or automatically after the lease expires, (The lease is the time lapse for which an IP address is Once that address is released it go backs to usable IP’s

What is the process of assigning a dynamic IP address  ?

  1. The clients sents a DHCPDISCOVER which is a 255.255.255.255 broadcast, typically it is saying : “DHCP Server , where are you ? “
    • If the DHCPDISCOVER hits a router and the router is configured with a DHCP relay agent, it will forward the request to the DHCP server it has configured , it’s like the router says “Oh, I see you’re looking for a DHCP server, I know one, let me send your message to him”
  2. The server recieves the request and sends back a DHCPOFFER : it’s like the server is saying : “Hey I got the message, you need an IP address right, Is this ok for you ? “
  3. The client recieves the DHCPOFFER and send’s back a DHCPREQUEST in which it confirms the DHCPOFFER and in which it can specify other options. It’s like the client is saying : “I recieved the offer, that’s fine for me , can you just add this option please  ? “
  4. The server recieves the DHCPREQUEST and sends back a DHCPACK that acknowledges that confirms the lease and has all correct IP config . It’s like the server is saying : “If everything is good for you and me then here is your IP address, Subnet Mask, Gateway and all other requested information”
  5. On the contrary if the server has an issue with itself or the client it will send a DHCPNAK which means it is uncapable of treating the request. It’s like the server is saying : “I see that you made a request but unfornately I’m not able of treating your request right now, please try again later “

One important note for a network engineer to remember is to always place DHCP Servers in the campus datacenter / server farm / shared services block.

DNS
What is DNS ?DNS is short for Domain naming system. It is a directory system that helps us match IP’s with domain name, for example 8.8.8.8 is one of google.com IP’s
How does it work ?The client devices sends a request to the local DNS server to resolve the IP of google.com The local DNS Server sends a request to the remote DNS server on where Google.com is configured. The response from Google.com is stored in cache of the local DNS Server The local dns server provides the response to the client machine which then can send information to the IP of the recieved destination.

So in more simpler words DNS saves normal users from the hassle of remembering the IP addresses of all their favorite websites and maps the IP’s to more human friendly names, the command to test DNS resolution is NSLOOKUP, let me show you :

nslookup
> google.com
Server:		208.67.222.222
Address:	208.67.222.222#53

Non-authoritative answer:
Name:	google.com
Address: 172.217.168.238


Non-authoritative answer:Name: google.comAddress: 172.217.168.238You can see above that for the NSLOOKUP request I did for google.com the DNS server that responded to me on port 53 and sent me back the response that google.com IP address is the 172.217.168.238.DNS Data are called resource records, there are different types of them :

  • A records : Simply put, name to IP mapping
  • AAAA : IPV6 address
  • CNAME : Canonical name, used for aliases or nicknames
  • MX : points to the server where mail should be delivered
  • NS : Name server : points to the DNS server for a particular domain
  • PTR : pointer : used for reverse mapping , IP to names
  • SOA : start of authority : designates the start of a zone , This device is the master of all DNS RR’s for a zone

Dns uses port 53 UDP/TCP

One important note for a network engineer to remember is to always place DNS Servers in the campus datacenter / server farm / shared services block.


Comments