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..94df86a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5983,9 +5983,9 @@ fd@~0.0.2: integrity sha512-iAHrIslQb3U68OcMSP0kkNWabp7sSN6d2TBSb2JO3gcLJVDd4owr/hKM4SFJovFOUeeXeItjYgouEDTMWiVAnA== figgy-pudding@^3.5.1: - version "3.5.1" - resolved "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790" - integrity sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w== + version "3.5.2" + resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" + integrity sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw== figures@^1.3.5: version "1.7.0" @@ -9895,14 +9895,7 @@ minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: safe-buffer "^5.1.2" yallist "^3.0.0" -minipass@^3.0.0: - version "3.1.1" - resolved "https://registry.npmjs.org/minipass/-/minipass-3.1.1.tgz#7607ce778472a185ad6d89082aa2070f79cedcd5" - integrity sha512-UFqVihv6PQgwj8/yTGvl9kPz7xIAY+R5z6XYjRInD3Gk3qx6QGSD6zEcpeG4Dy/lQnv1J6zv8ejV90hyYIKf3w== - dependencies: - yallist "^4.0.0" - -minipass@^3.1.1: +minipass@^3.0.0, minipass@^3.1.1: version "3.1.3" resolved "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz#7d42ff1f39635482e15f9cdb53184deebd5815fd" integrity sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg== @@ -13604,9 +13597,9 @@ sshpk@^1.7.0: tweetnacl "~0.14.0" ssri@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" - integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA== + version "6.0.2" + resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5" + integrity sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q== dependencies: figgy-pudding "^3.5.1"