diff --git a/gatsby-config.js b/gatsby-config.js index 6051b8e..d76d163 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -129,10 +129,6 @@ module.exports = { }, 'gatsby-transformer-sharp', 'gatsby-plugin-sharp', - { - resolve: 'gatsby-plugin-google-analytics', - options: { trackingId: 'UA-147229191-1' }, - }, { resolve: 'gatsby-plugin-google-fonts', options: { diff --git a/src/pages/articles/dns/auth.png b/src/pages/articles/dns/auth.png new file mode 100644 index 0000000..327da2e Binary files /dev/null and b/src/pages/articles/dns/auth.png differ diff --git a/src/pages/articles/dns/index.md b/src/pages/articles/dns/index.md new file mode 100644 index 0000000..45d469c --- /dev/null +++ b/src/pages/articles/dns/index.md @@ -0,0 +1,75 @@ +--- +title: A refresher on the Domain Name System (DNS) +date: '2021-02-18T22:01:39.990Z' +layout: post +draft: false +category: 'Software Development' +path: '/posts/dns' +description: "Learn about the internet's phonebook, the Domain Name System (DNS), DNS Resolution, DNS caching and DNS resolver queries" +tags: + - 'Web development' + - 'Software Development' +--- + +![Sorting](./phonebook.jpg) + +# Domain Name System (DNS) +Accessing web pages on the internet is easy. You simply type a domain name (google.com), and the page magically appears in your browser 😄. +This is great for us, but not so much for your browser. It has to translate the domain name to an IP address in order to retrieve +the page over the internet. The middleman which translates domain names to IP addresses is called the DNS. + +The process of resolving URL to IP addresses is simple but to understand it we need to take a look at a number of things +[DNS Recursive Resolver](#DNS-Recursive-Resolver), [Root Name Servers](#Root-Name-Servers), [Top Level Domain Name Servers](#TLD-Name-Servers), +[Authoritative Name Servers](#Authoritative-Name-Server), [DNS Caching](#DNS-Caching), [DNS Queries](#DNS-Queries) + +### DNS Recursive Resolver +This is also known as the DNS recursor. It receives queries from applications such as your web browser and operating system and is responsible for either +resolving the query from its own caches or making additional requests to other DNS servers in the DNS hierarchy. +It starts the DNS lookup process if there is no record in its cache. + +### Root Name Servers +Root name servers as the name suggests is at the root of the Domain Name System hierarchy. Root name servers store and maintains in its database, information +that allows it to point to more specific locations like the generic top-level domains (com, .org, .net, .edu), +country code top-level domains (.us, .uk) and [Internationalized Domain Name](https://www.icann.org/resources/pages/idn-2012-02-25-en) which is quite uncommon. +It is the first step in translating human-readable URLs to IP addresses. +Root servers fulfil requests by responding with a list of name server details of [TLD Name Servers](#TLD-Name-Servers), the most suitable for the domain name requested by +looking at the url extension. + +![Root server for mrgregory.dev](./root.png) + +There are 13 well-known IP addresses for the root servers but under +these 13 are 100s of servers which resolve client queries. Look at root servers, operator, locations and their IP addresses [here](https://root-servers.org/). + +### TLD Name Servers +The role of a TLD name server is simple but very important. It holds information about domain names with the same extension. +Examples are `.com`, `.net` TLD name servers. Root name servers redirect a DNS recursor here based on the domain name extension. +A TLD server responds with a list of authoritative name servers for the requested domain. For my website `mrgregory.dev`, here are examples of authoritative name servers from some **.dev** TLD servers + +![List of TLD name servers for mrgregory.dev](./tld.png) + +### Authoritative Name Servers +This is at the bottom of the hierarchy, and is often the last step in DNS' quest to resolve a domain to an IP address. +Here is where information about the domain name is found and returned to the DNS recursor. Depending on whether the domain name has +an alias (CNAME record), an authoritative server responds to the DNS recursive resolver with the CNAME record containing an alias domain which triggers another DNS lookup. +If not, an A record containing an IP address is returned to the recursor. Note in the image below, we have an IP address from the list authoritative name servers provided by the TLD +name server. + +![List of authoritative name server](./auth.png) + +### DNS Caching +Caching is an important part of DNS resolution. DNS is fast ⏩ but caching makes it even faster ⏩⏩. Caching happens in several places in a typical DNS lookup. +Operating Systems cache DNS records, web browsers, DNS Recursive Resolvers, and at each step during a DNS lookup. Records are cached with a TTL (time to live). +When the TTL expires, the record is removed. This allows your browser or OS to quickly retrieve records of previously looked up domain names without having to do +a complete DNS lookup process. + + +### DNS Queries +I will keep this section brief. One or more of these types of queries are used to keep DNS lookups optimised. **Recursive Query**, **Non-Recursive Query** or +**Iterative Query** are the types we need to know. __Recursive queries__ are made to recursive name servers and __iterative or non-recursive queries__ are made to iterative +name servers. Root name servers, TLD servers and authoritative name servers are iterative by nature. For recursive queries, each server in the chain does a request by itself to another server in an +attempt to resolve the query. For iterative queries, each server responds to the DNS client (DNS Recursor) with a list of servers that could potentially resolve the query, the recursor then +follows up with a new request to the server(s). + +### Fun resources +[Ultra tools](https://www.ultratools.com/dnsTools) provides lots of cool tools to visualize DNS lookups and more. Check it out ! Until next time 👋🏽 + diff --git a/src/pages/articles/dns/phonebook.jpg b/src/pages/articles/dns/phonebook.jpg new file mode 100644 index 0000000..98e0b91 Binary files /dev/null and b/src/pages/articles/dns/phonebook.jpg differ diff --git a/src/pages/articles/dns/root.png b/src/pages/articles/dns/root.png new file mode 100644 index 0000000..8394972 Binary files /dev/null and b/src/pages/articles/dns/root.png differ diff --git a/src/pages/articles/dns/tld.png b/src/pages/articles/dns/tld.png new file mode 100644 index 0000000..f704001 Binary files /dev/null and b/src/pages/articles/dns/tld.png differ diff --git a/src/pages/articles/zshrc-nvm/index.md b/src/pages/articles/zshrc-nvm/index.md index 3f934c4..2a6d207 100644 --- a/src/pages/articles/zshrc-nvm/index.md +++ b/src/pages/articles/zshrc-nvm/index.md @@ -14,8 +14,8 @@ tags: I have been a zsh user for a while now, for those who do not know zsh, it is a unix shell and command language based on bash with improvements. Recently, I found myself with a very slow terminal. It took a good 3 to 5 seconds to launch a new terminal session in any directory, which got -increasingly annoying. The major culprit was a bash script I nicked of stackoverflow 😅 (you know you do it too). I decided to remove that piece of -code, write my own (hopefully a simple and improved version of it). +increasingly annoying. The major culprit was a bash script I nicked of stackoverflow 😅 (you know you do it too) to switch node versions automatically. +I decided to remove that piece of code, write my own (hopefully a simpler and improved version). ### Let's modify the zsh profile @@ -23,7 +23,6 @@ code, write my own (hopefully a simple and improved version of it). open ~/.zshrc ``` To begin, open your zshrc file located here `~/.zshrc` (this is platform dependent), in your favourite editor. - We will be tapping into zsh hook functions to make this work, specifically `chpwd`, which is executed whenever the current working directory is changed. diff --git a/yarn.lock b/yarn.lock index 32296e2..5e61cd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15619,9 +15619,9 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== y18n@^3.2.1: - version "3.2.1" - resolved "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" - integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= + version "3.2.2" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696" + integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ== y18n@^4.0.0: version "4.0.0"