<?xml version="1.0" encoding="utf-8"?>
<!-- generator="" -->
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<title type="text">Domain Name System (DNS)</title>
	<subtitle type="text">Leading Network Security &amp; Cyber Security site. Cisco Routing/Switching, VPN, Microsoft, SASE, SSE, F5, PaloAlto Firewalls, Protocol Analysis, Tips &amp; more.</subtitle>
	<link rel="alternate" type="text/html" href="https://www.firewall.cx"/>
	<id>https://www.firewall.cx/networking/network-protocols/dns-protocol.feed</id>
	<updated>2026-04-11T12:40:06+10:00</updated>
	<author>
		<name>Firewall.cx Website</name>
	</author>
	<generator uri="https://www.joomla.org"></generator>
	<link rel="self" type="application/atom+xml" href="https://www.firewall.cx/networking/network-protocols/dns-protocol.feed?type=atom"/>
	<entry>
		<title>The DNS Protocol - Part 4: DNS Response Message Format</title>
		<link rel="alternate" type="text/html" href="https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html"/>
		<published>2011-05-17T06:28:59+10:00</published>
		<updated>2011-05-17T06:28:59+10:00</updated>
		<id>https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html</id>
		<author>
			<name>Administrator</name>
		</author>
		<summary type="html">&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The previous article covered the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html&quot; target=&quot;_blank&quot; title=&quot;DNS Query message formats&quot;&gt;DNS Query message formats&lt;/a&gt;. In the article we analysed them in great detail and showed how various options are selected by the host using the &lt;strong&gt;Flags/Parameters field&lt;/strong&gt;.&amp;nbsp; This article moves one more step ahead by covering the &lt;strong&gt;DNS response&lt;/strong&gt; received from the previously generated DNS queries. &lt;strong&gt;DNS responses&lt;/strong&gt;, in the case of a &lt;strong&gt;recursive DNS query&lt;/strong&gt;, come directly from the &lt;strong&gt;DNS server&lt;/strong&gt; that received our initial DNS query, while in the case of a &lt;strong&gt;non-recursive DNS query&lt;/strong&gt;, the response arrives from the &lt;strong&gt;last DNS server&lt;/strong&gt; the client (PC) queries in order to get the required DNS information.&lt;/p&gt;
&lt;h2&gt;DNS Analysis - Server Response&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Here is the &lt;strong&gt;response&lt;/strong&gt; (highlighted section in the screenshot below) to the previous &lt;strong&gt;DNS query&lt;/strong&gt; sent to DNS server with IP address 139.130.4.4:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-1.gif&quot; alt=&quot;dns-response-format-1&quot; width=&quot;630&quot; height=&quot;51&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Something worth paying attention to is &lt;strong&gt;the time it took&lt;/strong&gt; to receive and &lt;strong&gt;answer to our DNS query&lt;/strong&gt;, which was only&lt;strong&gt; 0.991 seconds&lt;/strong&gt;!&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;There are a lot of factors that contribute to this fairly fast reponse: The &lt;strong&gt;UDP &lt;/strong&gt;&lt;strong&gt;transport protocol &lt;/strong&gt;, which does not require any &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/tcp-udp-protocol/tcp-flag-options.html&quot; target=&quot;_blank&quot; title=&quot;TCP 3-way handshake&quot;&gt;3-way handshake&lt;/a&gt;, the load of the initial DNS server queried, the load of the other DNS servers that had to be ask, the connection speeds of everyone (our workstation, DNS servers, etc), and the traffic load between all paths our packets have taken during this DNS query/response!&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Analyzing a DNS Packet&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Following is the &lt;a href=&quot;https://www.firewall.cx/networking/ethernet/ethernet-ii.html&quot; target=&quot;_blank&quot; title=&quot;Ethernet II packet&quot;&gt;Ethernet II packet&lt;/a&gt; that runs on the local network. The structure is the same as our previous DNS query packet, but varies in size:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-2.gif&quot; alt=&quot;dns-response-format-2&quot; width=&quot;342&quot; height=&quot;157&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;DNS Query/Response Packet Structure&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Now, to make the analysis of the DNS Section easier we have also included the &lt;strong&gt;DNS Query&lt;/strong&gt; (left) and &lt;strong&gt;DNS Response&lt;/strong&gt; (right). This allows us to easily compare both &lt;strong&gt;DNS query and response packets&lt;/strong&gt;:&lt;/p&gt;
&lt;p style=&quot;text-align: center;&quot; align=&quot;left&quot;&gt;&amp;nbsp;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-3.gif&quot; alt=&quot;dns-response-format-3&quot; width=&quot;236&quot; height=&quot;301&quot; title=&quot;DNS Query Packet&quot; /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-4.gif&quot; alt=&quot;dns-response-format-4&quot; width=&quot;337&quot; height=&quot;301&quot; title=&quot;DNS Response packet&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;By comparing the two packets, we can see that there are fields in the &lt;strong&gt;DNS Response&lt;/strong&gt; packet (marked with green arrows) that &lt;strong&gt;didn't exist in the Query&lt;/strong&gt;. Let's see again what each field means and anaylse them again as we did in the previous page.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The &lt;strong&gt;DNS Section&lt;/strong&gt; in a &lt;strong&gt;response packet&lt;/strong&gt; is considerably &lt;strong&gt;larger&lt;/strong&gt; and &lt;strong&gt;complex&lt;/strong&gt; than that of a query packet. For this reason we are going to analyse it in parts rather than all together. The query had only one section that required in-depth analysis whereas the response has three since the first one is the original query sent:&lt;/p&gt;
&lt;p&gt;Here is the section of a &lt;strong&gt;DNS response&lt;/strong&gt;:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-5.gif&quot; alt=&quot;dns-response-format-5&quot; width=&quot;630&quot; height=&quot;147&quot; style=&quot;display: block; margin-right: auto; margin-left: auto;&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;You can clearly see that everything after the&amp;nbsp; block labeled &quot;&lt;strong&gt;DNS Query Section&lt;/strong&gt;&quot; is new. We are going to focus on these &lt;strong&gt;3 new blocks&lt;/strong&gt;, which are part of the &lt;strong&gt;DNS Response Section&lt;/strong&gt;, as the rest has been covered in the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html&quot; target=&quot;_blank&quot; title=&quot;DNS Query Format&quot;&gt;previous article&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;DNS Response Section&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The diagram below shows you the contents of the 3 new blocks (sections) we are looking at and they are:&lt;/p&gt;
&lt;ul class=&quot;check&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Answers &lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Authoritative Nameservers&lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Additional Records&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&amp;nbsp;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-6.gif&quot; alt=&quot;dns-response-format-6&quot; width=&quot;235&quot; height=&quot;479&quot; title=&quot;DNS Response Breakdown&quot; /&gt; &lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-7.gif&quot; alt=&quot;dns-response-format-7&quot; width=&quot;401&quot; height=&quot;479&quot; title=&quot;Packet Decoding of DNS Response&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;What we need to need understand is that each of these three sections have &lt;strong&gt;identical fields&lt;/strong&gt;. Even though the information they contain might seem a bit different, the fields are exactly the same and we will see this shortly.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In the picture above, we have only expanded the&lt;strong&gt; first part&lt;/strong&gt; of the &lt;strong&gt;Answer&lt;/strong&gt; section which is underlined in green so you can compare the fields with the ones contained in the left hand picture.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This picture below shows the expanded version from the &lt;strong&gt;first part&lt;/strong&gt; of &lt;strong&gt;both Answers &amp;amp; Authoritative&lt;/strong&gt; sections. We have already marked and labeled the fields to prove to you that they are all identical and vary only in the information they contain:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-8.gif&quot; alt=&quot;dns-response-format-8&quot; width=&quot;406&quot; height=&quot;526&quot; style=&quot;margin: 5px; float: left;&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;Looking carefully at &lt;strong&gt;both Answers &amp;amp; Authoritative&lt;/strong&gt; sections, we notice that the &lt;strong&gt;Resource Data&lt;/strong&gt; field is first, where according to the analysis of the sections in the picture above (left side), you would expect it last.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The actual position of the field is last, but it's presented first by the packet analyser to make the presented data more user friendly.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This is also the reason the first line of each part in each section is used to provide a quick summary of the information captured.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;For example, looking at &lt;strong&gt;line 1&lt;/strong&gt; in the &lt;strong&gt;Answers Section&lt;/strong&gt; (underlined in green), we get a summary of the data that will follow: &lt;strong&gt;www.firewall.cx&lt;/strong&gt;, &lt;strong&gt;type INET&lt;/strong&gt;, &lt;strong&gt;cname firewall.cx&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This proves that the fields in all of these 3 sections contained in the &lt;strong&gt;DNS Response Section&lt;/strong&gt; are identical, but contain different values/data.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Looking at each section (coloured area), one can notice that there are actually&lt;strong&gt; two answers&lt;/strong&gt; which appear as a hierachical tree with the boxed '+' symbol next to them.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;A question often asked is why are there two answers for each section and could there be more or less answers?&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The answer is simple and logical, there are as many answers as needed, depending on the way the domain has been setup. For example, Firewall.cx currently has two nameservers configured domain, which explains the two answers for each section. If we had three nameservers configured, then we would get three answers per section.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;To help make this clear, we also captured a &lt;strong&gt;DNS Response&lt;/strong&gt; packet from a &lt;strong&gt;DNS query&lt;/strong&gt; for the domain &lt;strong&gt;ibm.com&lt;/strong&gt;:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-9.gif&quot; alt=&quot;dns-response-format-9&quot; width=&quot;452&quot; height=&quot;463&quot; style=&quot;margin: 5px; float: left;&quot; title=&quot;Analysing DNS response Packet &quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;As it is evident, our query for IBM.COM gave us a response which has 4 answers per section!&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Again, each answer in every section has identical fields, but different data/values.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;You might have noticed a pattern here as well. In every &lt;strong&gt;DNS Response&lt;/strong&gt; you will find the same number of answers per section.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;For example, the screenshot on the left shows us 4 answers for the &lt;strong&gt;Answers&lt;/strong&gt;, &lt;strong&gt;Authoritative&lt;/strong&gt; and &lt;strong&gt;Additional records &lt;/strong&gt;sections and this is no coincidence.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;Type&lt;/strong&gt; field will help us understand why. Let's take a look at it.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Type Field&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;Type&lt;/strong&gt; field determines the type of information we require about a domain.&lt;/p&gt;
&lt;p&gt;The table below contains the most frequently requested Type of DNS information:&lt;/p&gt;
&lt;table border=&quot;1&quot; style=&quot;width: 100%; height: 293px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;background-color: #6699ff; width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 10pt; color: #000000;&quot;&gt;&lt;strong&gt;Type&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;background-color: #6699ff; width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 10pt; color: #000000;&quot;&gt;&lt;strong&gt;Meaning&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;background-color: #6699ff; width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 10pt; color: #000000;&quot;&gt;&lt;strong&gt;Contents&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;A&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Host Address &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;32-Bit IP Address of host or domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;CNAME&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Canonical Name (Alias)&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Canonical domain name for and alias e.g www&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;HINFO&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;CPU &amp;amp; OS &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Name of CPU and Operating System&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;MINFO&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Mailbox &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Info about a mailbox or mail list&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;MX&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Mail Exchange &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;16-bit preference and name of the host that acts as a mail exchange server for a domain e.g mail.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;NS&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Name Server &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Authoritative name server for the domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;PTR&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Pointer&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Symbolic link for a domain. e.g net.firewall.cx points to www.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;SOA&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Start Of Authority&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Multiple fields that specify which parts of the naming hiererchy a server implements &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;TXT&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Arbitrary Text &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Uninterpreted string of ASCII text&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;To give a simple example, when we have a &lt;strong&gt;Type=A&lt;/strong&gt; , we are given the IP Address of the domain or host (look at &lt;strong&gt;Answers&lt;/strong&gt; section below), whereas a &lt;strong&gt;Type=NS&lt;/strong&gt; means we are given the &lt;strong&gt;Authoritative Name Servers&lt;/strong&gt; that are responsible for the domain (look at&lt;strong&gt; Authoritative Name Servers&lt;/strong&gt; section below).&lt;/p&gt;
&lt;p&gt;The screenshot below, was taken from our first example (query for firewall.cx) and we can see why the &lt;strong&gt;Type&lt;/strong&gt; field is responsible for the data we receive about the domain:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-10.gif&quot; alt=&quot;dns-response-format-10&quot; width=&quot;396&quot; height=&quot;527&quot; style=&quot;margin: 5px auto; vertical-align: middle; display: block;&quot; title=&quot;DNS Response packet - analysis Nameservers and IP addresses&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;As we can see, the &lt;strong&gt;Type&lt;/strong&gt; field (red circle) in the first answer of the &lt;strong&gt;Authoritative Name Servers &lt;/strong&gt;section is set to NS, which means this part contains information about the &lt;strong&gt;Authoritative name servers&lt;/strong&gt; of the queried domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Going to the first answer of the &lt;strong&gt;Additional records&lt;/strong&gt;, we can see that the &lt;strong&gt;Type&lt;/strong&gt; field here is set to&lt;strong&gt; A&lt;/strong&gt;, which means the data contained in this part is an&lt;strong&gt; IP address&lt;/strong&gt; for the particular host.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;When requesting the &lt;strong&gt;name servers&lt;/strong&gt; for a domain, it also also essential their&lt;strong&gt; IP address&lt;/strong&gt; is also provided, so that the client can construct a DNS query and send it to the name servers for that domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In this article we analysed the &lt;strong&gt;DNS response message format&lt;/strong&gt; by looking into the details of a &lt;strong&gt;DNS response packet&lt;/strong&gt;. We also covered the different &lt;strong&gt;DNS type field messages&lt;/strong&gt; and &lt;strong&gt;explained&lt;/strong&gt; the contents of the &lt;strong&gt;DNS Response message&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot;&gt;&lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol.html&quot; title=&quot;DNS Protocols Section&quot;&gt;Back to the DNS Protocol Section&lt;/a&gt;&lt;/p&gt;
&lt;div id=&quot;_mcePaste&quot; class=&quot;mcePaste&quot; style=&quot;overflow: hidden; position: absolute; left: -10000px; top: 3845px; width: 1px; height: 1px;&quot;&gt;
&lt;table border=&quot;1&quot; style=&quot;width: 100%; height: 293px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot; bgcolor=&quot;#006600&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Type&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot; bgcolor=&quot;#005f8c&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Meaning&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot; bgcolor=&quot;#5e265e&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Contents&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;A&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Host Address &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;32-Bit IP Address of host or domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;CNAME&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Canonical Name (Alias)&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Canonical domain name for and alias e.g www&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;HINFO&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;CPU &amp;amp; OS &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Name of CPU and Operating System&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;MINFO&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Mailbox &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Info about a mailbox or mail list&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;MX&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Mail Exchange &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;16-bit preference and name of the host that acts as a mail exchange server for a domain e.g mail.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;NS&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Name Server &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Authoritative name server for the domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;PTR&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Pointer&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Symbolic link for a domain. e.g net.firewall.cx points to www.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;SOA&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Start Of Authority&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Multiple fields that specify which parts of the naming hiererchy a server implements &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;TXT&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Arbitrary Text &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Uninterpreted string of ASCII text&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</summary>
		<content type="html">&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The previous article covered the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html&quot; target=&quot;_blank&quot; title=&quot;DNS Query message formats&quot;&gt;DNS Query message formats&lt;/a&gt;. In the article we analysed them in great detail and showed how various options are selected by the host using the &lt;strong&gt;Flags/Parameters field&lt;/strong&gt;.&amp;nbsp; This article moves one more step ahead by covering the &lt;strong&gt;DNS response&lt;/strong&gt; received from the previously generated DNS queries. &lt;strong&gt;DNS responses&lt;/strong&gt;, in the case of a &lt;strong&gt;recursive DNS query&lt;/strong&gt;, come directly from the &lt;strong&gt;DNS server&lt;/strong&gt; that received our initial DNS query, while in the case of a &lt;strong&gt;non-recursive DNS query&lt;/strong&gt;, the response arrives from the &lt;strong&gt;last DNS server&lt;/strong&gt; the client (PC) queries in order to get the required DNS information.&lt;/p&gt;
&lt;h2&gt;DNS Analysis - Server Response&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Here is the &lt;strong&gt;response&lt;/strong&gt; (highlighted section in the screenshot below) to the previous &lt;strong&gt;DNS query&lt;/strong&gt; sent to DNS server with IP address 139.130.4.4:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-1.gif&quot; alt=&quot;dns-response-format-1&quot; width=&quot;630&quot; height=&quot;51&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Something worth paying attention to is &lt;strong&gt;the time it took&lt;/strong&gt; to receive and &lt;strong&gt;answer to our DNS query&lt;/strong&gt;, which was only&lt;strong&gt; 0.991 seconds&lt;/strong&gt;!&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;There are a lot of factors that contribute to this fairly fast reponse: The &lt;strong&gt;UDP &lt;/strong&gt;&lt;strong&gt;transport protocol &lt;/strong&gt;, which does not require any &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/tcp-udp-protocol/tcp-flag-options.html&quot; target=&quot;_blank&quot; title=&quot;TCP 3-way handshake&quot;&gt;3-way handshake&lt;/a&gt;, the load of the initial DNS server queried, the load of the other DNS servers that had to be ask, the connection speeds of everyone (our workstation, DNS servers, etc), and the traffic load between all paths our packets have taken during this DNS query/response!&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Analyzing a DNS Packet&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Following is the &lt;a href=&quot;https://www.firewall.cx/networking/ethernet/ethernet-ii.html&quot; target=&quot;_blank&quot; title=&quot;Ethernet II packet&quot;&gt;Ethernet II packet&lt;/a&gt; that runs on the local network. The structure is the same as our previous DNS query packet, but varies in size:&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-2.gif&quot; alt=&quot;dns-response-format-2&quot; width=&quot;342&quot; height=&quot;157&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;DNS Query/Response Packet Structure&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Now, to make the analysis of the DNS Section easier we have also included the &lt;strong&gt;DNS Query&lt;/strong&gt; (left) and &lt;strong&gt;DNS Response&lt;/strong&gt; (right). This allows us to easily compare both &lt;strong&gt;DNS query and response packets&lt;/strong&gt;:&lt;/p&gt;
&lt;p style=&quot;text-align: center;&quot; align=&quot;left&quot;&gt;&amp;nbsp;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-3.gif&quot; alt=&quot;dns-response-format-3&quot; width=&quot;236&quot; height=&quot;301&quot; title=&quot;DNS Query Packet&quot; /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-4.gif&quot; alt=&quot;dns-response-format-4&quot; width=&quot;337&quot; height=&quot;301&quot; title=&quot;DNS Response packet&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;By comparing the two packets, we can see that there are fields in the &lt;strong&gt;DNS Response&lt;/strong&gt; packet (marked with green arrows) that &lt;strong&gt;didn't exist in the Query&lt;/strong&gt;. Let's see again what each field means and anaylse them again as we did in the previous page.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The &lt;strong&gt;DNS Section&lt;/strong&gt; in a &lt;strong&gt;response packet&lt;/strong&gt; is considerably &lt;strong&gt;larger&lt;/strong&gt; and &lt;strong&gt;complex&lt;/strong&gt; than that of a query packet. For this reason we are going to analyse it in parts rather than all together. The query had only one section that required in-depth analysis whereas the response has three since the first one is the original query sent:&lt;/p&gt;
&lt;p&gt;Here is the section of a &lt;strong&gt;DNS response&lt;/strong&gt;:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-5.gif&quot; alt=&quot;dns-response-format-5&quot; width=&quot;630&quot; height=&quot;147&quot; style=&quot;display: block; margin-right: auto; margin-left: auto;&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;You can clearly see that everything after the&amp;nbsp; block labeled &quot;&lt;strong&gt;DNS Query Section&lt;/strong&gt;&quot; is new. We are going to focus on these &lt;strong&gt;3 new blocks&lt;/strong&gt;, which are part of the &lt;strong&gt;DNS Response Section&lt;/strong&gt;, as the rest has been covered in the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html&quot; target=&quot;_blank&quot; title=&quot;DNS Query Format&quot;&gt;previous article&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;DNS Response Section&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The diagram below shows you the contents of the 3 new blocks (sections) we are looking at and they are:&lt;/p&gt;
&lt;ul class=&quot;check&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Answers &lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Authoritative Nameservers&lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Additional Records&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&amp;nbsp;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-6.gif&quot; alt=&quot;dns-response-format-6&quot; width=&quot;235&quot; height=&quot;479&quot; title=&quot;DNS Response Breakdown&quot; /&gt; &lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-7.gif&quot; alt=&quot;dns-response-format-7&quot; width=&quot;401&quot; height=&quot;479&quot; title=&quot;Packet Decoding of DNS Response&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;What we need to need understand is that each of these three sections have &lt;strong&gt;identical fields&lt;/strong&gt;. Even though the information they contain might seem a bit different, the fields are exactly the same and we will see this shortly.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In the picture above, we have only expanded the&lt;strong&gt; first part&lt;/strong&gt; of the &lt;strong&gt;Answer&lt;/strong&gt; section which is underlined in green so you can compare the fields with the ones contained in the left hand picture.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This picture below shows the expanded version from the &lt;strong&gt;first part&lt;/strong&gt; of &lt;strong&gt;both Answers &amp;amp; Authoritative&lt;/strong&gt; sections. We have already marked and labeled the fields to prove to you that they are all identical and vary only in the information they contain:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-8.gif&quot; alt=&quot;dns-response-format-8&quot; width=&quot;406&quot; height=&quot;526&quot; style=&quot;margin: 5px; float: left;&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;Looking carefully at &lt;strong&gt;both Answers &amp;amp; Authoritative&lt;/strong&gt; sections, we notice that the &lt;strong&gt;Resource Data&lt;/strong&gt; field is first, where according to the analysis of the sections in the picture above (left side), you would expect it last.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The actual position of the field is last, but it's presented first by the packet analyser to make the presented data more user friendly.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This is also the reason the first line of each part in each section is used to provide a quick summary of the information captured.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;For example, looking at &lt;strong&gt;line 1&lt;/strong&gt; in the &lt;strong&gt;Answers Section&lt;/strong&gt; (underlined in green), we get a summary of the data that will follow: &lt;strong&gt;www.firewall.cx&lt;/strong&gt;, &lt;strong&gt;type INET&lt;/strong&gt;, &lt;strong&gt;cname firewall.cx&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This proves that the fields in all of these 3 sections contained in the &lt;strong&gt;DNS Response Section&lt;/strong&gt; are identical, but contain different values/data.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Looking at each section (coloured area), one can notice that there are actually&lt;strong&gt; two answers&lt;/strong&gt; which appear as a hierachical tree with the boxed '+' symbol next to them.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;A question often asked is why are there two answers for each section and could there be more or less answers?&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The answer is simple and logical, there are as many answers as needed, depending on the way the domain has been setup. For example, Firewall.cx currently has two nameservers configured domain, which explains the two answers for each section. If we had three nameservers configured, then we would get three answers per section.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;To help make this clear, we also captured a &lt;strong&gt;DNS Response&lt;/strong&gt; packet from a &lt;strong&gt;DNS query&lt;/strong&gt; for the domain &lt;strong&gt;ibm.com&lt;/strong&gt;:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-9.gif&quot; alt=&quot;dns-response-format-9&quot; width=&quot;452&quot; height=&quot;463&quot; style=&quot;margin: 5px; float: left;&quot; title=&quot;Analysing DNS response Packet &quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;As it is evident, our query for IBM.COM gave us a response which has 4 answers per section!&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Again, each answer in every section has identical fields, but different data/values.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;You might have noticed a pattern here as well. In every &lt;strong&gt;DNS Response&lt;/strong&gt; you will find the same number of answers per section.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;For example, the screenshot on the left shows us 4 answers for the &lt;strong&gt;Answers&lt;/strong&gt;, &lt;strong&gt;Authoritative&lt;/strong&gt; and &lt;strong&gt;Additional records &lt;/strong&gt;sections and this is no coincidence.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;Type&lt;/strong&gt; field will help us understand why. Let's take a look at it.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Type Field&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;Type&lt;/strong&gt; field determines the type of information we require about a domain.&lt;/p&gt;
&lt;p&gt;The table below contains the most frequently requested Type of DNS information:&lt;/p&gt;
&lt;table border=&quot;1&quot; style=&quot;width: 100%; height: 293px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;background-color: #6699ff; width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 10pt; color: #000000;&quot;&gt;&lt;strong&gt;Type&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;background-color: #6699ff; width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 10pt; color: #000000;&quot;&gt;&lt;strong&gt;Meaning&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;background-color: #6699ff; width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 10pt; color: #000000;&quot;&gt;&lt;strong&gt;Contents&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;A&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Host Address &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;32-Bit IP Address of host or domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;CNAME&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Canonical Name (Alias)&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Canonical domain name for and alias e.g www&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;HINFO&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;CPU &amp;amp; OS &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Name of CPU and Operating System&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;MINFO&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Mailbox &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Info about a mailbox or mail list&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;MX&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Mail Exchange &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;16-bit preference and name of the host that acts as a mail exchange server for a domain e.g mail.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;NS&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Name Server &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Authoritative name server for the domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;PTR&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Pointer&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Symbolic link for a domain. e.g net.firewall.cx points to www.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;SOA&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Start Of Authority&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Multiple fields that specify which parts of the naming hiererchy a server implements &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: verdana, geneva; font-size: 8pt;&quot;&gt;TXT&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Arbitrary Text &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: verdana,geneva; font-size: 8pt;&quot;&gt;Uninterpreted string of ASCII text&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;To give a simple example, when we have a &lt;strong&gt;Type=A&lt;/strong&gt; , we are given the IP Address of the domain or host (look at &lt;strong&gt;Answers&lt;/strong&gt; section below), whereas a &lt;strong&gt;Type=NS&lt;/strong&gt; means we are given the &lt;strong&gt;Authoritative Name Servers&lt;/strong&gt; that are responsible for the domain (look at&lt;strong&gt; Authoritative Name Servers&lt;/strong&gt; section below).&lt;/p&gt;
&lt;p&gt;The screenshot below, was taken from our first example (query for firewall.cx) and we can see why the &lt;strong&gt;Type&lt;/strong&gt; field is responsible for the data we receive about the domain:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.firewall.cx//images/stories/dns-response-format-10.gif&quot; alt=&quot;dns-response-format-10&quot; width=&quot;396&quot; height=&quot;527&quot; style=&quot;margin: 5px auto; vertical-align: middle; display: block;&quot; title=&quot;DNS Response packet - analysis Nameservers and IP addresses&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;As we can see, the &lt;strong&gt;Type&lt;/strong&gt; field (red circle) in the first answer of the &lt;strong&gt;Authoritative Name Servers &lt;/strong&gt;section is set to NS, which means this part contains information about the &lt;strong&gt;Authoritative name servers&lt;/strong&gt; of the queried domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Going to the first answer of the &lt;strong&gt;Additional records&lt;/strong&gt;, we can see that the &lt;strong&gt;Type&lt;/strong&gt; field here is set to&lt;strong&gt; A&lt;/strong&gt;, which means the data contained in this part is an&lt;strong&gt; IP address&lt;/strong&gt; for the particular host.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;When requesting the &lt;strong&gt;name servers&lt;/strong&gt; for a domain, it also also essential their&lt;strong&gt; IP address&lt;/strong&gt; is also provided, so that the client can construct a DNS query and send it to the name servers for that domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In this article we analysed the &lt;strong&gt;DNS response message format&lt;/strong&gt; by looking into the details of a &lt;strong&gt;DNS response packet&lt;/strong&gt;. We also covered the different &lt;strong&gt;DNS type field messages&lt;/strong&gt; and &lt;strong&gt;explained&lt;/strong&gt; the contents of the &lt;strong&gt;DNS Response message&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot;&gt;&lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol.html&quot; title=&quot;DNS Protocols Section&quot;&gt;Back to the DNS Protocol Section&lt;/a&gt;&lt;/p&gt;
&lt;div id=&quot;_mcePaste&quot; class=&quot;mcePaste&quot; style=&quot;overflow: hidden; position: absolute; left: -10000px; top: 3845px; width: 1px; height: 1px;&quot;&gt;
&lt;table border=&quot;1&quot; style=&quot;width: 100%; height: 293px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot; bgcolor=&quot;#006600&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Type&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot; bgcolor=&quot;#005f8c&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Meaning&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot; bgcolor=&quot;#5e265e&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Contents&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;A&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Host Address &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;32-Bit IP Address of host or domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;CNAME&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Canonical Name (Alias)&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Canonical domain name for and alias e.g www&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;HINFO&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;CPU &amp;amp; OS &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Name of CPU and Operating System&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;MINFO&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Mailbox &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Info about a mailbox or mail list&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;MX&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Mail Exchange &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;16-bit preference and name of the host that acts as a mail exchange server for a domain e.g mail.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;NS&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Name Server &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Authoritative name server for the domain&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;PTR&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Pointer&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Symbolic link for a domain. e.g net.firewall.cx points to www.firewall.cx&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;SOA&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Start Of Authority&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Multiple fields that specify which parts of the naming hiererchy a server implements &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 19%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;TXT&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 32%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Arbitrary Text &lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 49%;&quot;&gt;
&lt;div align=&quot;center&quot;&gt;&lt;span style=&quot;font-family: Georgia,Times New Roman,Times,serif; font-size: x-small;&quot;&gt;Uninterpreted string of ASCII text&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</content>
		<category term="Domain Name System (DNS)" />
	</entry>
	<entry>
		<title>The DNS Protocol - Part 3: DNS Query Message Format</title>
		<link rel="alternate" type="text/html" href="https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html"/>
		<published>2011-05-16T07:50:54+10:00</published>
		<updated>2011-05-16T07:50:54+10:00</updated>
		<id>https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html</id>
		<author>
			<name>Administrator</name>
		</author>
		<summary type="html">&lt;p style=&quot;text-align: justify;&quot;&gt;This section will deal with the &lt;strong&gt;analysis&lt;/strong&gt; of the &lt;strong&gt;DNS packets&lt;/strong&gt; by examining how &lt;strong&gt;DNS messages are formatted&lt;/strong&gt; and the &lt;strong&gt;options&lt;/strong&gt; and &lt;strong&gt;variables&lt;/strong&gt; they contain. To fully understand a protocol, you must understand the information the protocol carries from one host to another, along with any options available.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Because the &lt;strong&gt;DNS message format&lt;/strong&gt; can vary, depending on the &lt;strong&gt;query&lt;/strong&gt; and the &lt;strong&gt;answer&lt;/strong&gt;, we've broken this analysis into two parts:&lt;/p&gt;
&lt;ul class=&quot;check&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;DNS Query Message Format&lt;/strong&gt; which shows the contents of a &lt;strong&gt;DNS query&lt;/strong&gt; packet to a DNS server, requesting to &lt;strong&gt;resolve a domain&lt;/strong&gt;.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;DNS Response Message Format&lt;/strong&gt; analyses the &lt;strong&gt;DNS format&lt;/strong&gt; of a response, that is, when the &lt;strong&gt;DNS server&lt;/strong&gt; is &lt;strong&gt;responding&lt;/strong&gt; to our inital &lt;strong&gt;DNS query&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;This breakdown help make our analysis easier to understand and follow, rather than analyzing DNS queries and responses at the same time. This article will deal with the DNS Query Message Format while the next article analyzes the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html&quot; target=&quot;_blank&quot; title=&quot;DNS Response Message Format&quot;&gt;&lt;strong&gt;DNS Response Message Format&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;DNS Query Message Format Analysis - Host Query&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;As mentioned in the previous sections of the DNS Protocol, a DNS query is generated when the client needs to resolve a domain name into an IP Address. This could be the result of entering &quot;&lt;strong&gt;www.firewall.cx&lt;/strong&gt;&quot; in the url field of your web browser, or simply by launching a program that uses the Internet and therefore generates DNS queries in order to successfully communicate with the host or server it needs.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;We've also included a live example (using a packet analyser), to help better understander the packets contents. Later on we'll be analysing each field within the DNS packet. For now, let's check out what a &lt;strong&gt;packet containing a DNS query&lt;/strong&gt; would look like on our network:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-1.gif&quot; alt=&quot;dns-query-format-1&quot; width=&quot;630&quot; height=&quot;53&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;DNS Query packet in a Network Analyser&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The above captured DNS query was generated by typing &lt;strong&gt;ping www.firewall.cx&lt;/strong&gt; from the prompt of our Linux server. The command generated this packet, which was then placed on our network and sent to a DNS server on the Internet.&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Notice the &lt;strong&gt;Destination Port&lt;/strong&gt; which is set to &lt;strong&gt;53&lt;/strong&gt;, the port the &lt;strong&gt;DNS protocol&lt;/strong&gt;. In addition, you'll notice that the transport protocol&amp;nbsp; used is UDP:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-2.gif&quot; alt=&quot;dns-query-format-2&quot; width=&quot;342&quot; height=&quot;241&quot; style=&quot;float: left;&quot; title=&quot;DNS Packet - Ethernet II Frame&quot; /&gt;&lt;/p&gt;
&lt;div style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-3.gif&quot; alt=&quot;dns-query-format-3&quot; width=&quot;236&quot; height=&quot;241&quot; title=&quot;DNS Packet Analysis - Structure&quot; /&gt;&lt;br /&gt;&lt;a href=&quot;https://www.firewall.cx/networking/ethernet/ethernet-ii.html&quot; target=&quot;_blank&quot; title=&quot;Ethernet II&quot;&gt;Ethernet II&lt;/a&gt; (Check &lt;a href=&quot;https://www.firewall.cx/networking/ethernet.html&quot; target=&quot;_blank&quot; title=&quot;Ethernet Frames&quot;&gt;Ethernet Frames&lt;/a&gt; section for more info) is the most common type of frame found on LANs, in fact it probably is the only type you will find on 95% of all networks if you're only running TCP/IP and Windows or Unix-like machines. This particular one contains a DNS section, which could be either a Query or Response. We are assuming a Query, so it can fit nicely in our example. &lt;br /&gt;&lt;br /&gt;We are going to take the DNS Section above and analyse its contents, which are already shown in the picture above (Right hand side, labeled &quot;Capture&quot;) taken from my packet analyser. &lt;br /&gt;&lt;br /&gt;Here they are again in a cool 3D diagram:&lt;/div&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-4.gif&quot; alt=&quot;dns-query-format-4&quot; width=&quot;630&quot; height=&quot;113&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;Ethernet II Packet with DNS Protocol information&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;From this whole packet, the DNS Query Section is the part we're interested in (analysed shortly), the rest is more or less overhead and information to let the server know a bit more information about our query.&lt;br /&gt;&lt;br /&gt;The analysis of each 3D block (field) is shown in the left picture below so you can understand the function of each field and the &lt;strong&gt;DNS Query Section&lt;/strong&gt; captured by my packet sniffer on the right:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-5.gif&quot; alt=&quot;dns-query-format-5&quot; width=&quot;209&quot; height=&quot;578&quot; title=&quot;DNS Query Packet &quot; /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-6.gif&quot; alt=&quot;dns-query-format-6&quot; width=&quot;397&quot; height=&quot;360&quot; style=&quot;vertical-align: top;&quot; title=&quot;DNS Query packet from Network Analyzer&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;All fields in the DNS Query section except the DNS Name field (underlined in red in the picture above), have set lengths. The DNS Name field has no set length because it varies depending on the domain name length as we are going to see soon.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;For example, a query for www.cisco.com will require DNS Name field to be smaller than a query for support.novell.com simply because the second domain is longer.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The DNS Name Field&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;To prove this I captured a few packets that show different lengths for the domain names I just mentioned but, because the DNS section in a packet provides no length field, we need to look one level above, which is the UDP header, in order to calculate the DNS section length. By subtracting the UDP header length (always 8 bytes - check the &lt;a href=&quot;https://www.firewall.cx//networking-topics/protocols/124-upd-protocol.html&quot; target=&quot;_blank&quot; title=&quot;UDP Protocol&quot;&gt;UDP article&lt;/a&gt; for more information) from the bytes in the Length field, we are left with the length of the DNS section:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-7.gif&quot; alt=&quot;dns-query-format-7&quot; width=&quot;298&quot; height=&quot;510&quot; style=&quot;float: left;&quot; title=&quot;DNS Name Field Length Packet&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-8.gif&quot; alt=&quot;dns-query-format-8&quot; width=&quot;302&quot; height=&quot;510&quot; title=&quot;DNS Name Field Length Packet&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The two examples clearly show that the &lt;strong&gt;Length Field&lt;/strong&gt; in the &lt;strong&gt;UDP header&lt;/strong&gt; varies depending on the domain we are trying to resolve. The &lt;strong&gt;UDP header&lt;/strong&gt; is &lt;strong&gt;8 bytes&lt;/strong&gt; in both examples and all fields in the &lt;strong&gt;DNS Section&lt;/strong&gt;, except for the &lt;strong&gt;DNS Name field&lt;/strong&gt;, are always &lt;strong&gt;2 bytes&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Flags/Parameters Field&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;Parameter Field&lt;/strong&gt; (labeled Flags) is one of the &lt;strong&gt;most important fields in DNS&lt;/strong&gt; because it is responsible for letting the server or client know a lot of important information about the DNS packet. For example, it contains information as to whether the DNS packet is a &lt;strong&gt;query&lt;/strong&gt; or &lt;strong&gt;response&lt;/strong&gt; and, in the case of a query, if it should be a &lt;strong&gt;recursive&lt;/strong&gt; or &lt;strong&gt;non-recursive&lt;/strong&gt; type. This is most important because as we've already seen, it determines how the query is handled by the server.&lt;br /&gt;&lt;br /&gt;Let's have a closer look at the flags and explain the meaning of each one. We've marked the &lt;strong&gt;bit numbers&lt;/strong&gt; with black on the left hand side of each &lt;strong&gt;flag parameter&lt;/strong&gt; so you can see which ones are used during a &lt;strong&gt;response&lt;/strong&gt;. The picture on the &lt;strong&gt;right&lt;/strong&gt; hand side explains the various &lt;strong&gt;bits&lt;/strong&gt;. You won't see all &lt;strong&gt;16 bits&lt;/strong&gt; used in a &lt;strong&gt;query&lt;/strong&gt; as the rest are used during a &lt;strong&gt;response&lt;/strong&gt; or might be reserved:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-9.gif&quot; alt=&quot;dns-query-format-9&quot; width=&quot;404&quot; height=&quot;363&quot; style=&quot;float: left;&quot; title=&quot;DNS Packet Structure - query&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-10.gif&quot; alt=&quot;dns-query-format-10&quot; width=&quot;226&quot; height=&quot;363&quot; title=&quot;DNS Packet Fields - Parameters&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;As you can see, only &lt;strong&gt;bits 1&lt;/strong&gt;,&lt;strong&gt; 2-5&lt;/strong&gt;, &lt;strong&gt;7&lt;/strong&gt;, &lt;strong&gt;8&lt;/strong&gt; and &lt;strong&gt;12&lt;/strong&gt; are used in this &lt;strong&gt;query&lt;/strong&gt;. The rest will be a combination of &lt;strong&gt;reserved bits&lt;/strong&gt; and &lt;strong&gt;bits that are used only in responses&lt;/strong&gt;. When you read the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html&quot; target=&quot;_blank&quot; title=&quot;DNS response message format&quot;&gt;DNS response message format&lt;/a&gt; page, you will find a similar packet captured which is a reponse to the above query and the rest of the bits used are analysed.&lt;br /&gt;&lt;br /&gt;And that just about does it for the &lt;strong&gt;DNS Query message format&lt;/strong&gt;. Next up is the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html&quot; title=&quot;DNS Response message format&quot;&gt;DNS Response message format&lt;/a&gt; page which we are sure you will find just as interesting!&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot;&gt;Next - &lt;a href=&quot;https://www.firewall.cx/networking-topics/protocols/domain-name-system-dns/161-protocols-dns-response.html&quot;&gt;The DNS Protocol - Part 4: DNS Response Message Format&lt;/a&gt;&lt;/p&gt;</summary>
		<content type="html">&lt;p style=&quot;text-align: justify;&quot;&gt;This section will deal with the &lt;strong&gt;analysis&lt;/strong&gt; of the &lt;strong&gt;DNS packets&lt;/strong&gt; by examining how &lt;strong&gt;DNS messages are formatted&lt;/strong&gt; and the &lt;strong&gt;options&lt;/strong&gt; and &lt;strong&gt;variables&lt;/strong&gt; they contain. To fully understand a protocol, you must understand the information the protocol carries from one host to another, along with any options available.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Because the &lt;strong&gt;DNS message format&lt;/strong&gt; can vary, depending on the &lt;strong&gt;query&lt;/strong&gt; and the &lt;strong&gt;answer&lt;/strong&gt;, we've broken this analysis into two parts:&lt;/p&gt;
&lt;ul class=&quot;check&quot;&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;DNS Query Message Format&lt;/strong&gt; which shows the contents of a &lt;strong&gt;DNS query&lt;/strong&gt; packet to a DNS server, requesting to &lt;strong&gt;resolve a domain&lt;/strong&gt;.&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;DNS Response Message Format&lt;/strong&gt; analyses the &lt;strong&gt;DNS format&lt;/strong&gt; of a response, that is, when the &lt;strong&gt;DNS server&lt;/strong&gt; is &lt;strong&gt;responding&lt;/strong&gt; to our inital &lt;strong&gt;DNS query&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;This breakdown help make our analysis easier to understand and follow, rather than analyzing DNS queries and responses at the same time. This article will deal with the DNS Query Message Format while the next article analyzes the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html&quot; target=&quot;_blank&quot; title=&quot;DNS Response Message Format&quot;&gt;&lt;strong&gt;DNS Response Message Format&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;DNS Query Message Format Analysis - Host Query&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;As mentioned in the previous sections of the DNS Protocol, a DNS query is generated when the client needs to resolve a domain name into an IP Address. This could be the result of entering &quot;&lt;strong&gt;www.firewall.cx&lt;/strong&gt;&quot; in the url field of your web browser, or simply by launching a program that uses the Internet and therefore generates DNS queries in order to successfully communicate with the host or server it needs.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;We've also included a live example (using a packet analyser), to help better understander the packets contents. Later on we'll be analysing each field within the DNS packet. For now, let's check out what a &lt;strong&gt;packet containing a DNS query&lt;/strong&gt; would look like on our network:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-1.gif&quot; alt=&quot;dns-query-format-1&quot; width=&quot;630&quot; height=&quot;53&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;DNS Query packet in a Network Analyser&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;The above captured DNS query was generated by typing &lt;strong&gt;ping www.firewall.cx&lt;/strong&gt; from the prompt of our Linux server. The command generated this packet, which was then placed on our network and sent to a DNS server on the Internet.&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;Notice the &lt;strong&gt;Destination Port&lt;/strong&gt; which is set to &lt;strong&gt;53&lt;/strong&gt;, the port the &lt;strong&gt;DNS protocol&lt;/strong&gt;. In addition, you'll notice that the transport protocol&amp;nbsp; used is UDP:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-2.gif&quot; alt=&quot;dns-query-format-2&quot; width=&quot;342&quot; height=&quot;241&quot; style=&quot;float: left;&quot; title=&quot;DNS Packet - Ethernet II Frame&quot; /&gt;&lt;/p&gt;
&lt;div style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-3.gif&quot; alt=&quot;dns-query-format-3&quot; width=&quot;236&quot; height=&quot;241&quot; title=&quot;DNS Packet Analysis - Structure&quot; /&gt;&lt;br /&gt;&lt;a href=&quot;https://www.firewall.cx/networking/ethernet/ethernet-ii.html&quot; target=&quot;_blank&quot; title=&quot;Ethernet II&quot;&gt;Ethernet II&lt;/a&gt; (Check &lt;a href=&quot;https://www.firewall.cx/networking/ethernet.html&quot; target=&quot;_blank&quot; title=&quot;Ethernet Frames&quot;&gt;Ethernet Frames&lt;/a&gt; section for more info) is the most common type of frame found on LANs, in fact it probably is the only type you will find on 95% of all networks if you're only running TCP/IP and Windows or Unix-like machines. This particular one contains a DNS section, which could be either a Query or Response. We are assuming a Query, so it can fit nicely in our example. &lt;br /&gt;&lt;br /&gt;We are going to take the DNS Section above and analyse its contents, which are already shown in the picture above (Right hand side, labeled &quot;Capture&quot;) taken from my packet analyser. &lt;br /&gt;&lt;br /&gt;Here they are again in a cool 3D diagram:&lt;/div&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-4.gif&quot; alt=&quot;dns-query-format-4&quot; width=&quot;630&quot; height=&quot;113&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;Ethernet II Packet with DNS Protocol information&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;From this whole packet, the DNS Query Section is the part we're interested in (analysed shortly), the rest is more or less overhead and information to let the server know a bit more information about our query.&lt;br /&gt;&lt;br /&gt;The analysis of each 3D block (field) is shown in the left picture below so you can understand the function of each field and the &lt;strong&gt;DNS Query Section&lt;/strong&gt; captured by my packet sniffer on the right:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-5.gif&quot; alt=&quot;dns-query-format-5&quot; width=&quot;209&quot; height=&quot;578&quot; title=&quot;DNS Query Packet &quot; /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-6.gif&quot; alt=&quot;dns-query-format-6&quot; width=&quot;397&quot; height=&quot;360&quot; style=&quot;vertical-align: top;&quot; title=&quot;DNS Query packet from Network Analyzer&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;All fields in the DNS Query section except the DNS Name field (underlined in red in the picture above), have set lengths. The DNS Name field has no set length because it varies depending on the domain name length as we are going to see soon.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;For example, a query for www.cisco.com will require DNS Name field to be smaller than a query for support.novell.com simply because the second domain is longer.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The DNS Name Field&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;To prove this I captured a few packets that show different lengths for the domain names I just mentioned but, because the DNS section in a packet provides no length field, we need to look one level above, which is the UDP header, in order to calculate the DNS section length. By subtracting the UDP header length (always 8 bytes - check the &lt;a href=&quot;https://www.firewall.cx//networking-topics/protocols/124-upd-protocol.html&quot; target=&quot;_blank&quot; title=&quot;UDP Protocol&quot;&gt;UDP article&lt;/a&gt; for more information) from the bytes in the Length field, we are left with the length of the DNS section:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-7.gif&quot; alt=&quot;dns-query-format-7&quot; width=&quot;298&quot; height=&quot;510&quot; style=&quot;float: left;&quot; title=&quot;DNS Name Field Length Packet&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-8.gif&quot; alt=&quot;dns-query-format-8&quot; width=&quot;302&quot; height=&quot;510&quot; title=&quot;DNS Name Field Length Packet&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The two examples clearly show that the &lt;strong&gt;Length Field&lt;/strong&gt; in the &lt;strong&gt;UDP header&lt;/strong&gt; varies depending on the domain we are trying to resolve. The &lt;strong&gt;UDP header&lt;/strong&gt; is &lt;strong&gt;8 bytes&lt;/strong&gt; in both examples and all fields in the &lt;strong&gt;DNS Section&lt;/strong&gt;, except for the &lt;strong&gt;DNS Name field&lt;/strong&gt;, are always &lt;strong&gt;2 bytes&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Flags/Parameters Field&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;Parameter Field&lt;/strong&gt; (labeled Flags) is one of the &lt;strong&gt;most important fields in DNS&lt;/strong&gt; because it is responsible for letting the server or client know a lot of important information about the DNS packet. For example, it contains information as to whether the DNS packet is a &lt;strong&gt;query&lt;/strong&gt; or &lt;strong&gt;response&lt;/strong&gt; and, in the case of a query, if it should be a &lt;strong&gt;recursive&lt;/strong&gt; or &lt;strong&gt;non-recursive&lt;/strong&gt; type. This is most important because as we've already seen, it determines how the query is handled by the server.&lt;br /&gt;&lt;br /&gt;Let's have a closer look at the flags and explain the meaning of each one. We've marked the &lt;strong&gt;bit numbers&lt;/strong&gt; with black on the left hand side of each &lt;strong&gt;flag parameter&lt;/strong&gt; so you can see which ones are used during a &lt;strong&gt;response&lt;/strong&gt;. The picture on the &lt;strong&gt;right&lt;/strong&gt; hand side explains the various &lt;strong&gt;bits&lt;/strong&gt;. You won't see all &lt;strong&gt;16 bits&lt;/strong&gt; used in a &lt;strong&gt;query&lt;/strong&gt; as the rest are used during a &lt;strong&gt;response&lt;/strong&gt; or might be reserved:&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-9.gif&quot; alt=&quot;dns-query-format-9&quot; width=&quot;404&quot; height=&quot;363&quot; style=&quot;float: left;&quot; title=&quot;DNS Packet Structure - query&quot; /&gt;&lt;/p&gt;
&lt;p align=&quot;left&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;img src=&quot;https://www.firewall.cx/images/stories/dns-query-format-10.gif&quot; alt=&quot;dns-query-format-10&quot; width=&quot;226&quot; height=&quot;363&quot; title=&quot;DNS Packet Fields - Parameters&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;As you can see, only &lt;strong&gt;bits 1&lt;/strong&gt;,&lt;strong&gt; 2-5&lt;/strong&gt;, &lt;strong&gt;7&lt;/strong&gt;, &lt;strong&gt;8&lt;/strong&gt; and &lt;strong&gt;12&lt;/strong&gt; are used in this &lt;strong&gt;query&lt;/strong&gt;. The rest will be a combination of &lt;strong&gt;reserved bits&lt;/strong&gt; and &lt;strong&gt;bits that are used only in responses&lt;/strong&gt;. When you read the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html&quot; target=&quot;_blank&quot; title=&quot;DNS response message format&quot;&gt;DNS response message format&lt;/a&gt; page, you will find a similar packet captured which is a reponse to the above query and the rest of the bits used are analysed.&lt;br /&gt;&lt;br /&gt;And that just about does it for the &lt;strong&gt;DNS Query message format&lt;/strong&gt;. Next up is the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-response.html&quot; title=&quot;DNS Response message format&quot;&gt;DNS Response message format&lt;/a&gt; page which we are sure you will find just as interesting!&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot;&gt;Next - &lt;a href=&quot;https://www.firewall.cx/networking-topics/protocols/domain-name-system-dns/161-protocols-dns-response.html&quot;&gt;The DNS Protocol - Part 4: DNS Response Message Format&lt;/a&gt;&lt;/p&gt;</content>
		<category term="Domain Name System (DNS)" />
	</entry>
	<entry>
		<title>The DNS Protocol - Part 2: DNS Queries &amp; Resolution Process</title>
		<link rel="alternate" type="text/html" href="https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-resolution.html"/>
		<published>2011-05-16T07:45:37+10:00</published>
		<updated>2011-05-16T07:45:37+10:00</updated>
		<id>https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-resolution.html</id>
		<author>
			<name>Administrator</name>
		</author>
		<summary type="html">&lt;p&gt;This section will help you understand how the DNS queries work on the Internet and your home network. There are two ways to use the domain name system in order to resolve a host or domain name to an IP Address and we're going to look at them here. There is also a detailed example later on this page to help you understand it better.&lt;/p&gt;
&lt;h2&gt;Queries and Resolution&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;As mentioned in the introduction section, there are two ways for a client to use the domain name system to obtain an answer.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;One of these involves the client contacting the name servers (this is also called a &lt;em&gt;non Recursive query&lt;/em&gt;) one at a time until it finds the authority server that contains the information it requires, while the other way is to ask the name server system to perform the complete translation (this is also called a &lt;em&gt;Recursive query&lt;/em&gt;), in which case the client will send the query and get a response that contains the IP Address of the domain it's looking for.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;It's really exciting to see how DNS queries work. While analysing with you the packets that are sent and received from the DNS server, I'm going to show you how the client chooses the method by which it wants its query to be resolved, so you will truly understand how these cool features work ! The DNS Query/Response Message Format pages contain all this packet analysis information, so let's continue and prepare for it !&lt;/p&gt;
&lt;h2&gt;DNS Resolution Example&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;We will now look at what happens when your workstation requests a domain to be resolved. The example that follows will show you the whole procedure step by step, so make sure you take your time to read it and understand it !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;When someone wants to visit the Cisco website (www.cisco.com), they go to their web browser and type &quot;&lt;a href=&quot;http://www.cisco.com&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot; title=&quot;www.cisco.com&quot;&gt;http://www.cisco.com&lt;/a&gt;&quot; or just &quot;www.cisco.com&quot; and, after a few seconds, the website is displayed. But what happens in the background after they type the address and hit enter is pretty much unknown to most users. That's what we are going to find out now !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The picture below shows us what would happen in the above example: (for simplicity we are not illustrating both Primary and Secondary DNS servers, only the Primary)&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-resolution-1.gif&quot; alt=&quot;dns-resolution-1&quot; width=&quot;524&quot; height=&quot;496&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;DNS Recursive Query&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Explanation:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;1. You open your web browser and enter &lt;strong&gt;www.cisco.com&lt;/strong&gt; in the address field. At that point, the computer doesn't know the &lt;strong&gt;IP address&lt;/strong&gt; for &lt;strong&gt;www.cisco.com&lt;/strong&gt;, so it sends a &lt;strong&gt;DNS query&lt;/strong&gt; to your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; (It's querying the ISP's DNS because this has been set through the dial-up properties; if you're on a permanent connection then it's set through your network card's TCP/IP properties).&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;2. Your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; doesn't know the IP address for &lt;strong&gt;www.cisco.com&lt;/strong&gt;, so it will ask one of the &lt;strong&gt;ROOT DNS servers&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;3. The &lt;strong&gt;ROOT DNS server&lt;/strong&gt; checks its database and finds that the &lt;strong&gt;Primary DNS&lt;/strong&gt; for &lt;strong&gt;Cisco.com&lt;/strong&gt; is &lt;strong&gt;198.133.219.25&lt;/strong&gt;. It replies to your ISP's server with this answer.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;4. Your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; now knows the IP address of&amp;nbsp;&lt;strong&gt;Cisco's DNS server&lt;/strong&gt;, so it then sends a &lt;strong&gt;recursive query&lt;/strong&gt; to &lt;strong&gt;Cisco.com's DNS server&lt;/strong&gt; and asking to resolve the fully qualified domain name &lt;strong&gt;www.cisco.com&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;5. Cisco's DNS server checks its database and finds an entry for &lt;strong&gt;www.cisco.com&lt;/strong&gt;. This entry has an &lt;strong&gt;IP address&lt;/strong&gt; of &lt;strong&gt;198.133.219.25&lt;/strong&gt;. Since the IP address of the DNS server and webserver (www) are identical, this means they are likely to be both on the same physical server. Load-balancing mechanisim can also have the same effect, making multiple services and physical machines have the same IP address.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;6. Your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; now knows the &lt;strong&gt;IP address&lt;/strong&gt; for &lt;strong&gt;www.cisco.com&lt;/strong&gt; and sends the result to your computer.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;7. Your computer now knows the IP address of Cisco's website and is able to directly contact it. Naturally, the next step is to send an http request directly to Cisco's webserver and download the webpage.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;We hope you didn't find it too hard to follow. Remember that this query is the most common type. The other type of query (non recursive) follows the same procedure, the difference is that the client does all the running around trying to find the authoritative DNS server for the desired domain, we like to think of it as &quot;self service&quot; :)&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot; align=&quot;right&quot;&gt;Next - &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html&quot; title=&quot;DNS Query Message Format&quot;&gt;The DNS Protocol - Part 3: DNS Query Message Format&lt;/a&gt;&lt;/p&gt;</summary>
		<content type="html">&lt;p&gt;This section will help you understand how the DNS queries work on the Internet and your home network. There are two ways to use the domain name system in order to resolve a host or domain name to an IP Address and we're going to look at them here. There is also a detailed example later on this page to help you understand it better.&lt;/p&gt;
&lt;h2&gt;Queries and Resolution&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;As mentioned in the introduction section, there are two ways for a client to use the domain name system to obtain an answer.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;One of these involves the client contacting the name servers (this is also called a &lt;em&gt;non Recursive query&lt;/em&gt;) one at a time until it finds the authority server that contains the information it requires, while the other way is to ask the name server system to perform the complete translation (this is also called a &lt;em&gt;Recursive query&lt;/em&gt;), in which case the client will send the query and get a response that contains the IP Address of the domain it's looking for.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot; align=&quot;left&quot;&gt;It's really exciting to see how DNS queries work. While analysing with you the packets that are sent and received from the DNS server, I'm going to show you how the client chooses the method by which it wants its query to be resolved, so you will truly understand how these cool features work ! The DNS Query/Response Message Format pages contain all this packet analysis information, so let's continue and prepare for it !&lt;/p&gt;
&lt;h2&gt;DNS Resolution Example&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;We will now look at what happens when your workstation requests a domain to be resolved. The example that follows will show you the whole procedure step by step, so make sure you take your time to read it and understand it !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;When someone wants to visit the Cisco website (www.cisco.com), they go to their web browser and type &quot;&lt;a href=&quot;http://www.cisco.com&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot; title=&quot;www.cisco.com&quot;&gt;http://www.cisco.com&lt;/a&gt;&quot; or just &quot;www.cisco.com&quot; and, after a few seconds, the website is displayed. But what happens in the background after they type the address and hit enter is pretty much unknown to most users. That's what we are going to find out now !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The picture below shows us what would happen in the above example: (for simplicity we are not illustrating both Primary and Secondary DNS servers, only the Primary)&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-resolution-1.gif&quot; alt=&quot;dns-resolution-1&quot; width=&quot;524&quot; height=&quot;496&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;DNS Recursive Query&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Explanation:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;1. You open your web browser and enter &lt;strong&gt;www.cisco.com&lt;/strong&gt; in the address field. At that point, the computer doesn't know the &lt;strong&gt;IP address&lt;/strong&gt; for &lt;strong&gt;www.cisco.com&lt;/strong&gt;, so it sends a &lt;strong&gt;DNS query&lt;/strong&gt; to your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; (It's querying the ISP's DNS because this has been set through the dial-up properties; if you're on a permanent connection then it's set through your network card's TCP/IP properties).&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;2. Your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; doesn't know the IP address for &lt;strong&gt;www.cisco.com&lt;/strong&gt;, so it will ask one of the &lt;strong&gt;ROOT DNS servers&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;3. The &lt;strong&gt;ROOT DNS server&lt;/strong&gt; checks its database and finds that the &lt;strong&gt;Primary DNS&lt;/strong&gt; for &lt;strong&gt;Cisco.com&lt;/strong&gt; is &lt;strong&gt;198.133.219.25&lt;/strong&gt;. It replies to your ISP's server with this answer.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;4. Your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; now knows the IP address of&amp;nbsp;&lt;strong&gt;Cisco's DNS server&lt;/strong&gt;, so it then sends a &lt;strong&gt;recursive query&lt;/strong&gt; to &lt;strong&gt;Cisco.com's DNS server&lt;/strong&gt; and asking to resolve the fully qualified domain name &lt;strong&gt;www.cisco.com&lt;/strong&gt;.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;5. Cisco's DNS server checks its database and finds an entry for &lt;strong&gt;www.cisco.com&lt;/strong&gt;. This entry has an &lt;strong&gt;IP address&lt;/strong&gt; of &lt;strong&gt;198.133.219.25&lt;/strong&gt;. Since the IP address of the DNS server and webserver (www) are identical, this means they are likely to be both on the same physical server. Load-balancing mechanisim can also have the same effect, making multiple services and physical machines have the same IP address.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;6. Your &lt;strong&gt;ISP's DNS server&lt;/strong&gt; now knows the &lt;strong&gt;IP address&lt;/strong&gt; for &lt;strong&gt;www.cisco.com&lt;/strong&gt; and sends the result to your computer.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;7. Your computer now knows the IP address of Cisco's website and is able to directly contact it. Naturally, the next step is to send an http request directly to Cisco's webserver and download the webpage.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;We hope you didn't find it too hard to follow. Remember that this query is the most common type. The other type of query (non recursive) follows the same procedure, the difference is that the client does all the running around trying to find the authoritative DNS server for the desired domain, we like to think of it as &quot;self service&quot; :)&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot; align=&quot;right&quot;&gt;Next - &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-query.html&quot; title=&quot;DNS Query Message Format&quot;&gt;The DNS Protocol - Part 3: DNS Query Message Format&lt;/a&gt;&lt;/p&gt;</content>
		<category term="Domain Name System (DNS)" />
	</entry>
	<entry>
		<title>The DNS Protocol - Part 1: Introduction</title>
		<link rel="alternate" type="text/html" href="https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns.html"/>
		<published>2011-05-16T07:37:41+10:00</published>
		<updated>2011-05-16T07:37:41+10:00</updated>
		<id>https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns.html</id>
		<author>
			<name>Administrator</name>
		</author>
		<summary type="html">&lt;p style=&quot;text-align: justify;&quot;&gt;If you ever wondered where DNS came from, this is your chance to find out ! The quick summary on DNS's history will also help you understand why DNS servers are run mostly on Linux and Unix-type systems. We then get to see the layers of the OSI Model on which DNS works and, towards the end of the page, you will find out how the Domains (and DNS servers) are structured on the Internet to ensure uptime and effectiveness.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The History&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;DNS began in the early days when the Internet was only a small network created by the Department of Defence for research purposes. Host names (simple computer names) of computers were manually entered into a file (called HOSTS) which was located on a central server. Each site/computer that needed to resolve host names had to download this file. But as the number of hosts grew, so did the HOSTS file (Linux, Unix, Windows and NetWare still use such files) until it was far too large for computers to download and it was generating great amounts of traffic ! So they thought ... Stuff this .. let's find a better solution ... and in 1984 the Domain Name System was introduced.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Protocol&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;Domain Name System&lt;/strong&gt; is a 'hierarchically distributed database', which is a fancy way of saying that its layers are arranged in a definite order and that its data is distributed across a wide range of machines (just like the roots of a tree branch out from the main root).&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Most companies today have their own little DNS server to ensure the computers can find each other without problems. If you're using Windows 2000 and Active Directory, then you surely are using DNS for the name resolutions of your computers. Microsoft has created its own version of a &quot;DNS&quot; server, called a WINS server, which stands for Windows Internet Name Service, but this is old technology and uses protocols that are nowhere near as efficient as DNS, so it was natural for Microsoft to move away from WINS and towards DNS, after all, the whole Internet works on DNS :)&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The DNS protocol works when your computer sends out a DNS query to a name server to resolve a domain. For example, you type &quot;www.firewall.cx&quot; in your web browser, this triggers a DNS request, which your computer sends to a DNS server in order to get the website's IP Address ! There is a detailed example on the pages to follow so I won't get into too much detail for the moment.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-protocol-1.gif&quot; alt=&quot;dns-protocol-1&quot; width=&quot;382&quot; height=&quot;328&quot; style=&quot;margin: 5px; float: left;&quot; title=&quot;DNS Protocol in the OSI Model &quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The DNS protocol normally uses the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/tcp-udp-protocol/udp-protocol.html&quot; target=&quot;_blank&quot; title=&quot;UDP protocol&quot;&gt;UDP protocol&lt;/a&gt; as a means of transport because of its small overhead in comparison to &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/tcp-udp-protocol.html&quot; target=&quot;_blank&quot; title=&quot;TCP&quot;&gt;TCP&lt;/a&gt;; the less overhead a protocol has, the faster it is !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In the case where there are constant errors and the computer trying to request a DNS resolution can't get an error free answer, or any answer at all, it will switch to TCP to ensure the data arrives without errors.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This process, though, depends on the operating system you're using. Some operating systems might not allow DNS to use the TCP protocol, thus limiting it to UDP only. It is rare that you will get so many errors that you can't resolve any hostname or domain name to an IP Address.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;DNS protocol&lt;/strong&gt; utilises &lt;strong&gt;Port 53&lt;/strong&gt; for its service. This means that a DNS server listens on Port 53 and expects any client wishing to use the service to use the same port. There are, however, cases where you might need to use a different port, something possible depending on the operating system and DNS server you are running.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In the following pages we'll be looking at the actual DNS packet format, where you are able to see exactly the contents of DNS query, so we won't analyse the packet structure here.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Next we'll take a close look at how the Internet domains and DNS servers are structured to make sure the model works flawlessly and efficiently!&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Internet Domain Name Server Hierarchy&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This interesting section will help you understand how domain names on the Internet are structured and where DNS servers fit in to the picture. When you think about the millions of domain names registered today, you probably think that you have to be superhuman to manage such a structure of DNS servers !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Well that's not that case. The DNS structure has been designed in such a way that no DNS server needs to know about all possible domains, but only those immediately above and below it.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The picture below shows part of the internet &lt;strong&gt;DNS hierarchical structure&lt;/strong&gt;:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-protocol-2.gif&quot; alt=&quot;dns-protocol-2&quot; width=&quot;539&quot; height=&quot;250&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;The DNS Structure Tree&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Let's explain how it works:&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Internic controls the &quot;root&quot; domain, which includes all the top level domains. These are marked in a green oval for clarity. Within the green oval you have the ROOT DNS servers, which know all about the authoritative DNS servers for the domains immediately below them e.g firewall.cx, cisco.com, microsoft.com etc. These ROOT DNS servers can tell you which DNS server takes care of firewall.cx, cisco.com, microsoft.com and the rest.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Each domain, including the ones we are talking about (cisco, firewall, microsoft), have what we call a &quot;Primary DNS&quot; and &quot;Secondary DNS&quot;. The Primary DNS is the one that holds all the information about its domain. The Secondary acts as a backup in case the Primary DNS fails. The process in which a Primary DNS server sends its copy to the Secondary DNS server is called &lt;em&gt;Zone Transfer&lt;/em&gt; and is covered in the DNS Database section.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Today there are hundreds of websites at which you are able to register your own domain and, once you've done that, you have the power to manage it yourself. In the example above, Cisco bought the &quot;Cisco.com&quot; domain and then created your resource records. Some examples of resource records for the Cisco domain in our example are: support , www and routers. These will be analysed in depth on the next pages.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;So here comes the million dollar question: &lt;strong&gt;How do you create subdomains and www's (known as resouce records) ?&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The answer is pretty simple:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;You use a special DNS administration interface (usually web based - provided by the guys with whom you registered your domain) that allows you to create, change and delete the subdomains, www's or whatever resource record you can come up with. When you're making changes to the DNS settings of your domain, you're actually changing the contents of specific files that are located on that server.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;These changes then slowly propagate to the&lt;em&gt; authoritative&lt;/em&gt; DNS servers, which are responsible for your domain area and then the whole Internet will contact these DNS servers when they need to access any section of your domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;For example, if you need to resolve ftp.firewall.cx, your computer will locate and contact the DNS Server responsible for the .CX domains, which will let you know the DNS server that's in charge of the Firewall.cx domain. The DNS server of Firewall.cx in turn will let your computer know the IP Address of ftp.firewall.cx because it holds all the information for the firewall.cx domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;That completes our first DNS section. It's not that hard after all!&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot;&gt;&amp;nbsp;Next - &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-resolution.html&quot; title=&quot;The DNS Protocol - Part 2: DNS Queries &amp;amp; Resolution Process&quot;&gt;The DNS Protocol - Part 2: DNS Queries &amp;amp; Resolution Process&lt;/a&gt;&lt;/p&gt;</summary>
		<content type="html">&lt;p style=&quot;text-align: justify;&quot;&gt;If you ever wondered where DNS came from, this is your chance to find out ! The quick summary on DNS's history will also help you understand why DNS servers are run mostly on Linux and Unix-type systems. We then get to see the layers of the OSI Model on which DNS works and, towards the end of the page, you will find out how the Domains (and DNS servers) are structured on the Internet to ensure uptime and effectiveness.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The History&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;DNS began in the early days when the Internet was only a small network created by the Department of Defence for research purposes. Host names (simple computer names) of computers were manually entered into a file (called HOSTS) which was located on a central server. Each site/computer that needed to resolve host names had to download this file. But as the number of hosts grew, so did the HOSTS file (Linux, Unix, Windows and NetWare still use such files) until it was far too large for computers to download and it was generating great amounts of traffic ! So they thought ... Stuff this .. let's find a better solution ... and in 1984 the Domain Name System was introduced.&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Protocol&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;Domain Name System&lt;/strong&gt; is a 'hierarchically distributed database', which is a fancy way of saying that its layers are arranged in a definite order and that its data is distributed across a wide range of machines (just like the roots of a tree branch out from the main root).&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Most companies today have their own little DNS server to ensure the computers can find each other without problems. If you're using Windows 2000 and Active Directory, then you surely are using DNS for the name resolutions of your computers. Microsoft has created its own version of a &quot;DNS&quot; server, called a WINS server, which stands for Windows Internet Name Service, but this is old technology and uses protocols that are nowhere near as efficient as DNS, so it was natural for Microsoft to move away from WINS and towards DNS, after all, the whole Internet works on DNS :)&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The DNS protocol works when your computer sends out a DNS query to a name server to resolve a domain. For example, you type &quot;www.firewall.cx&quot; in your web browser, this triggers a DNS request, which your computer sends to a DNS server in order to get the website's IP Address ! There is a detailed example on the pages to follow so I won't get into too much detail for the moment.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-protocol-1.gif&quot; alt=&quot;dns-protocol-1&quot; width=&quot;382&quot; height=&quot;328&quot; style=&quot;margin: 5px; float: left;&quot; title=&quot;DNS Protocol in the OSI Model &quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The DNS protocol normally uses the &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/tcp-udp-protocol/udp-protocol.html&quot; target=&quot;_blank&quot; title=&quot;UDP protocol&quot;&gt;UDP protocol&lt;/a&gt; as a means of transport because of its small overhead in comparison to &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/tcp-udp-protocol.html&quot; target=&quot;_blank&quot; title=&quot;TCP&quot;&gt;TCP&lt;/a&gt;; the less overhead a protocol has, the faster it is !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In the case where there are constant errors and the computer trying to request a DNS resolution can't get an error free answer, or any answer at all, it will switch to TCP to ensure the data arrives without errors.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This process, though, depends on the operating system you're using. Some operating systems might not allow DNS to use the TCP protocol, thus limiting it to UDP only. It is rare that you will get so many errors that you can't resolve any hostname or domain name to an IP Address.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The &lt;strong&gt;DNS protocol&lt;/strong&gt; utilises &lt;strong&gt;Port 53&lt;/strong&gt; for its service. This means that a DNS server listens on Port 53 and expects any client wishing to use the service to use the same port. There are, however, cases where you might need to use a different port, something possible depending on the operating system and DNS server you are running.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;In the following pages we'll be looking at the actual DNS packet format, where you are able to see exactly the contents of DNS query, so we won't analyse the packet structure here.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Next we'll take a close look at how the Internet domains and DNS servers are structured to make sure the model works flawlessly and efficiently!&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;The Internet Domain Name Server Hierarchy&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;This interesting section will help you understand how domain names on the Internet are structured and where DNS servers fit in to the picture. When you think about the millions of domain names registered today, you probably think that you have to be superhuman to manage such a structure of DNS servers !&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Well that's not that case. The DNS structure has been designed in such a way that no DNS server needs to know about all possible domains, but only those immediately above and below it.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The picture below shows part of the internet &lt;strong&gt;DNS hierarchical structure&lt;/strong&gt;:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;img src=&quot;https://www.firewall.cx/images/stories/dns-protocol-2.gif&quot; alt=&quot;dns-protocol-2&quot; width=&quot;539&quot; height=&quot;250&quot; style=&quot;display: block; margin-left: auto; margin-right: auto;&quot; title=&quot;The DNS Structure Tree&quot; /&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;strong&gt;Let's explain how it works:&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Internic controls the &quot;root&quot; domain, which includes all the top level domains. These are marked in a green oval for clarity. Within the green oval you have the ROOT DNS servers, which know all about the authoritative DNS servers for the domains immediately below them e.g firewall.cx, cisco.com, microsoft.com etc. These ROOT DNS servers can tell you which DNS server takes care of firewall.cx, cisco.com, microsoft.com and the rest.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Each domain, including the ones we are talking about (cisco, firewall, microsoft), have what we call a &quot;Primary DNS&quot; and &quot;Secondary DNS&quot;. The Primary DNS is the one that holds all the information about its domain. The Secondary acts as a backup in case the Primary DNS fails. The process in which a Primary DNS server sends its copy to the Secondary DNS server is called &lt;em&gt;Zone Transfer&lt;/em&gt; and is covered in the DNS Database section.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;Today there are hundreds of websites at which you are able to register your own domain and, once you've done that, you have the power to manage it yourself. In the example above, Cisco bought the &quot;Cisco.com&quot; domain and then created your resource records. Some examples of resource records for the Cisco domain in our example are: support , www and routers. These will be analysed in depth on the next pages.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;So here comes the million dollar question: &lt;strong&gt;How do you create subdomains and www's (known as resouce records) ?&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;The answer is pretty simple:&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;You use a special DNS administration interface (usually web based - provided by the guys with whom you registered your domain) that allows you to create, change and delete the subdomains, www's or whatever resource record you can come up with. When you're making changes to the DNS settings of your domain, you're actually changing the contents of specific files that are located on that server.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;These changes then slowly propagate to the&lt;em&gt; authoritative&lt;/em&gt; DNS servers, which are responsible for your domain area and then the whole Internet will contact these DNS servers when they need to access any section of your domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;For example, if you need to resolve ftp.firewall.cx, your computer will locate and contact the DNS Server responsible for the .CX domains, which will let you know the DNS server that's in charge of the Firewall.cx domain. The DNS server of Firewall.cx in turn will let your computer know the IP Address of ftp.firewall.cx because it holds all the information for the firewall.cx domain.&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;That completes our first DNS section. It's not that hard after all!&lt;/p&gt;
&lt;p style=&quot;text-align: right;&quot;&gt;&amp;nbsp;Next - &lt;a href=&quot;https://www.firewall.cx/networking/network-protocols/dns-protocol/protocols-dns-resolution.html&quot; title=&quot;The DNS Protocol - Part 2: DNS Queries &amp;amp; Resolution Process&quot;&gt;The DNS Protocol - Part 2: DNS Queries &amp;amp; Resolution Process&lt;/a&gt;&lt;/p&gt;</content>
		<category term="Domain Name System (DNS)" />
	</entry>
</feed>
