๐Ÿ“˜ Day 43: DNS, DHCP, NAT & Firewall Basics

Ritesh SinghRitesh Singh
3 min read

Welcome to Day 43 of my Networking & Security journey! ๐Ÿš€ Today, I explored four core networking concepts that power the internet and practiced firewall configuration hands-on.


๐ŸŒ 1. DNS (Domain Name System)

  • Definition: DNS translates human-readable domain names (e.g., google.com) into IP addresses (e.g., 142.250.182.78) so computers can communicate.

  • How it works:

    1. You type example.com in a browser.

    2. A DNS resolver queries a DNS server.

    3. The server responds with the correct IP address.

    4. Your browser connects to that IP.

๐Ÿ”‘ Types of DNS Records:

  • A Record: Maps a domain โ†’ IPv4 address.

  • AAAA Record: Maps a domain โ†’ IPv6 address.

  • CNAME: Alias for another domain.

  • MX Record: Mail exchange (used for email).

๐Ÿ’ก Analogy: Think of DNS as the phonebook of the internet.


๐Ÿ“ก 2. DHCP (Dynamic Host Configuration Protocol)

  • Definition: A network protocol that automatically assigns IP addresses and other network settings to devices.

  • Why itโ€™s needed: Without DHCP, every device would need to be manually configured.

  • How it works (DORA Process):

    1. Discover โ†’ Client broadcasts to find DHCP server.

    2. Offer โ†’ DHCP server replies with an available IP.

    3. Request โ†’ Client requests the offered IP.

    4. Acknowledge โ†’ DHCP server confirms the assignment.

๐Ÿ’ก Analogy: Imagine entering a parking lot where the guard (DHCP server) assigns you an empty parking spot (IP address).


๐ŸŒ 3. NAT (Network Address Translation)

  • Definition: NAT allows multiple devices in a private network (e.g., 192.168.x.x) to share a single public IP when accessing the internet.

  • Types of NAT:

    • Static NAT: One private โ†” One public IP.

    • Dynamic NAT: Many private โ†” Many public IPs (from a pool).

    • PAT (Port Address Translation): Many private โ†” One public IP (most common, e.g., your home Wi-Fi).

๐Ÿ’ก Real-life Example: Your home Wi-Fi has multiple devices, but the ISP sees only one public IP.


๐Ÿ”ฅ 4. Firewalls

A firewall is a security system that monitors and controls incoming and outgoing traffic based on defined rules.

  • Types of Firewalls:

    • Hardware Firewall: Dedicated device (e.g., routers with firewall).

    • Software Firewall: Installed on operating systems (Linux ufw, iptables).

๐Ÿ’ก Analogy: Think of a firewall as a security guard who checks ID cards before letting people (packets) enter a building (network).


๐Ÿ›  Hands-on Practice

Using ufw (Uncomplicated Firewall)

# Enable UFW
sudo ufw enable

# Check status
sudo ufw status verbose

# Allow SSH (port 22)
sudo ufw allow 22

# Allow HTTP (port 80)
sudo ufw allow 80/tcp

# Deny a specific port (e.g., 23 - Telnet)
sudo ufw deny 23

# Delete a rule
sudo ufw delete allow 80/tcp

Using iptables (Advanced Firewall Rules)

View existing rules

sudo iptables -L -v

Allow incoming HTTP traffic (port 80)

sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT

Block incoming traffic from a specific IP

sudo iptables -A INPUT -s 192.168.1.100 -j DROP

Allow SSH from a specific subnet

sudo iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 22 -j ACCEPT

Drop all incoming connections by default

sudo iptables -P INPUT DROP

Save iptables rules (Debian/Ubuntu)

sudo sh -c "iptables-save > /etc/iptables/rules.v4"


๐Ÿ‘จโ€๐Ÿ’ป Author

Ritesh Singh
๐ŸŒ LinkedIn | ๐Ÿ“ Hashnode | GitHub

#100DaysOfDevOps #CICD #GitHubActions #DevOps #Beginner #100DaysOfDevOps #Networking #Security #Linux #CloudComputing #Firewalls #DNS #DHCP #NAT

0
Subscribe to my newsletter

Read articles from Ritesh Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ritesh Singh
Ritesh Singh

Hi, Iโ€™m Ritesh ๐Ÿ‘‹ Iโ€™m on a mission to become a DevOps Engineer โ€” and Iโ€™m learning in public every single day.With a full-time commitment of 8โ€“10 hours daily, Iโ€™m building skills in: โœ… Linuxโœ… Git & GitHubโœ… Docker & Kubernetesโœ… AWS EC2, S3โœ… Jenkins, GitHub Actionsโœ… Terraform, Prometheus, Grafana I post daily blogs on Hashnode, push projects to GitHub, and stay active on LinkedIn and Twitter/X. Letโ€™s connect, collaborate, and grow together ๐Ÿš€ #100DaysOfDevOps #LearningInPublic #DevOps