Creating and using a CNAME record in DNS

Now that we are familiar with moving around a little bit inside the DNS management tool, we are going to create and test another type of record. This one is called a CNAME, and it is easiest to think of this one as an alias record. Rather than taking a DNS name and pointing it at an IP address, as we do with a host record, with a CNAME, we are going to take a DNS name and point it at another DNS name! Why would this be necessary? If you are hosting multiple services on a single server but want those services to be contacted by using different names, CNAME records can be your best friend.

Getting ready

We are going to make use of the same environment that we used to create our A records in the Creating an A or AAAA record in DNS recipe. There is a DC/DNS server online where we are going to create our records. Also running is WEB1, a server where we are hosting a website as well as some file shares. We will also use a Windows 10 client to test out our CNAME records after they have been created.

How to do it…

To create and test a CNAME record, perform the following instructions:

  1. WEB1 is hosting a website and a file share. Currently, the only DNS record that exists for WEB1 is the primary A record, so users have to type in the WEB1 name to access both the website and the file shares. Our goal is to create aliases for these services by using CNAME records in DNS. First, we log into the DNS server and launch DNS Manager.
  2. Once inside DNS Manager, expand Forward Lookup Zones and then your domain name so that we can see the list of DNS records that exist already.
  3. Now right-click on your domain and select New Alias (CNAME)….
  4. We would like our users to be able to browse the website by typing in http://intranet. So in our CNAME record, we want the Alias name to be INTRANET and the FQDN for target host to be WEB1.MYDOMAIN.LOCAL, which is the server where the website is being hosted.

    How to do it…

  5. We also want our file shares to be accessible by using \FILESERVERSHARE, so that the actual name of the server hosting this share is not visible to the users. Create another CNAME record with the Alias name field as FILESERVER, and the FQDN for target host field as WEB1.MYDOMAIN.LOCAL.
  6. Log into the test client machine and give it a try. Users are now able to open up Internet Explorer and successfully browse to http://intranet. They are also able to open File Explorer and access \fileservershare.

How it works…

We have a server in our environment called WEB1. There is a website running on this server. It is also hosting a file share called SHARE. By creating a couple of quick CNAME records inside DNS, we are able to give users the ability to use some intuitive names to access these resources. By following the preceding instructions, we have masked the actual server name from the users, making knowledge of that name unnecessary. Masking internal hostnames of servers is also considered a security best practice in many organizations.

See also

  • The Creating an A or AAAA record in DNS recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.24.36