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..c73cccd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2961,10 +2961,10 @@ bmp-js@^0.1.0: resolved "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz#e05a63f796a6c1ff25f4771ec7adadc148c07233" integrity sha1-4Fpj95amwf8l9Hcex62twUjAcjM= -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: - version "4.11.9" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" - integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== +bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.11.9: + version "4.12.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== body-parser@1.19.0, body-parser@^1.19.0: version "1.19.0" @@ -3044,7 +3044,7 @@ braces@^3.0.1, braces@~3.0.2: dependencies: fill-range "^7.0.1" -brorand@^1.0.1: +brorand@^1.0.1, brorand@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= @@ -5010,17 +5010,17 @@ electron-to-chromium@^1.3.634: integrity sha512-bwl6/U6xb3d3CNufQU9QeO1L32ueouFwW4bWANSwdXR7LVqyLzWjNbynoKNfuC38QFB5Qn7O0l2KLqBkcXnC3Q== elliptic@^6.0.0: - version "6.5.3" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" - integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw== + version "6.5.4" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== dependencies: - bn.js "^4.4.0" - brorand "^1.0.1" + bn.js "^4.11.9" + brorand "^1.1.0" hash.js "^1.0.0" - hmac-drbg "^1.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" "emoji-regex@>=6.0.0 <=6.1.1": version "6.1.1" @@ -7734,7 +7734,7 @@ highlight.js@^8.1.0: resolved "https://registry.npmjs.org/highlight.js/-/highlight.js-8.9.1.tgz#b8a9c5493212a9392f0222b649c9611497ebfb88" integrity sha1-uKnFSTISqTkvAiK2SclhFJfr+4g= -hmac-drbg@^1.0.0: +hmac-drbg@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= @@ -9827,7 +9827,7 @@ minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== -minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: +minimalistic-crypto-utils@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=