Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

DNS for Developers

DZone's Guide to

DNS for Developers

DNS is the backbone of the internet and, as such, I believe every developer should know something about the basics and not just leave it for the sysadmin to sort out.

· Web Dev Zone ·
Free Resource

Learn how Crafter’s Git-based content management system is reinventing modern digital experiences. Download this white paper now. 

What Is DNS?

DNS, or Domain Name System, is what translates domain names to IP addresses and vice versa.

Wait, What Is an IP Address and What Are Domain Names?

You do realize this is a developer blog? An IP address is a unique address on the internet and a domain name is a user-friendly label for one or more of these.

An example might be google.com, which, for me, resolves to 216.58.204.14

How it Works

When your browser makes a request to google.com, it makes a request to your ISP's DNS Servers. This resolves google.com to 216.58.204.14

In more detail, your ISP's DNS server will forward the DNS query to another DNS server and will cache the results for a set amount of time. This is the TTL or Time To Live. Next time the ISP DNS Server will be able to reply directly without needing to forward requests.

This forwarding and caching are what makes making a DNS change not instantaneous. The TTL needs to be reached so that no results are still being fetched from the cache of DNS servers across the globe.

DNS Records

Now we know roughly how DNS works let's look at the most common type of records

A

A (Host) records are the most simple records which translate domain names to IPs, e.g., www.google.com to 216.58.204.14

CNAME

A CNAME (Canonical Name) record is different to an A record in that it maps a domain name to another domain name when no A record exists.

For example, www.google.com to somethingelse.google.com

Typically, Azure makes use of CNAMEs for many of its services especially adding a custom domain name.

MX

MX stands for Mail Exchange and is used for configuring email.

Name Server

Every domain has a number of Name Servers which tells you what servers control the DNS settings for that domain. If you change your Name Servers then the new Name Servers will be where you can change your DNS settings.

If you want to use a service like DNSimple instead of 123reg or where ever you registered your domain then all you need to do is change your Name Servers.

AAAA

Like A records, but for ipv6.

What Next?

Want to put some different DNS records into practice? Buy a domain name and publish some content to it. Check out my previous post about programmatically adding records. Want an SSL certificate? Get a wildcard one and then you can apply it to any subdomain you add to your domain.

If you have a new website you want to publish, consider which of the following is better:

  • https://www.example.com/newsite

  • https://newsite.example.com

I much prefer the second option, it looks cleaner, there is no potential conflict with the parent site, and no subfolder issues between production and development.

Crafter CMS is a modern Git-based platform for building innovative websites and content-rich digital experiences. Download this white paper now.

Topics:
dns ,dns caching ,ip address ,web dev ,web servers

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}