DNS, DHCP | Cyber Security Tutorial - Learn with VOKS
Back Next

DNS, DHCP


What Is DNS?

DNS stands for:

Domain Name System

DNS is like a phone book for the internet.

  • Humans remember names like google.com
  • Computers communicate using IP addresses like 142.250.190.78

DNS translates human-friendly domain names into IP addresses so your computer can reach websites.

How DNS Works

  1. You type a website into your browser:
www.example.com
  1. Your computer asks a DNS server:

“Hey, what is the IP address for www.example.com?”

  1. The DNS server replies with the IP:
93.184.216.34
  1. Your computer connects to that IP to load the website.

DNS allows you to use names instead of numbers.

Testing DNS

On Linux/macOS:

nslookup www.google.com

On Windows:

nslookup www.google.com

You’ll see the IP address of the website.

What Is DHCP?

DHCP stands for:

Dynamic Host Configuration Protocol

DHCP automatically gives devices on a network:

  • IP address
  • Subnet mask
  • Gateway
  • DNS servers

Without DHCP, you would have to manually assign an IP to every device. That would be slow and error-prone.

How DHCP Works

  1. Your device connects to a network.
  2. It sends a request: “I need an IP address.”
  3. The DHCP server responds with an available IP and other network settings.
  4. Your device configures itself automatically.

Example:

  • Device asks for IP
  • DHCP assigns 192.168.1.20
  • Device can now communicate on the network

Checking Your IP Assigned by DHCP

On Linux/macOS:

ip addr

or

ifconfig

On Windows:

ipconfig

You’ll see your IPv4 address, subnet mask, and default gateway — all assigned by DHCP.

Difference Between DNS and DHCP

| Feature         | DNS                                                      | DHCP                                      |
|-----------------|----------------------------------------------------------|-------------------------------------------|
| Purpose         | Translates domain names to IP addresses                  | Assigns IP addresses and network settings |
| Works With      | Domain names, IP addresses                               | Devices connecting to a network           |
| Human-Friendly? | Yes, you type names                                      | Mostly invisible to users                 |
| Example         | [www.google.com](http://www.google.com) → 142.250.190.78 | Device gets 192.168.1.20 automatically    |


Why Both Are Important

  • DHCP makes it easy for devices to join networks automatically.
  • DNS makes it easy for humans to browse the internet without remembering IP numbers.

Together, they allow devices to connect seamlessly and access websites.

Simple Testing Commands

Check your IP (assigned by DHCP)

Linux/macOS:

ip addr

Windows:

ipconfig

Check DNS resolution

Linux/macOS:

nslookup www.google.com
dig www.google.com

Windows:

nslookup www.google.com

Ping a website to verify connectivity

Linux/macOS:

ping www.google.com

Windows:

ping www.google.com

Example Scenario

  1. You connect your laptop to Wi-Fi.
  2. DHCP gives your laptop IP 192.168.1.15, subnet mask 255.255.255.0, and DNS 8.8.8.8.
  3. You type www.example.com in your browser.
  4. Your computer asks the DNS server (8.8.8.8) for the IP.
  5. DNS replies 93.184.216.34.
  6. Your browser connects to 93.184.216.34 and loads the website.

All of this happens automatically in a few milliseconds.

Example Code:
# Linux/macOS - Check IP assigned by DHCP
ip addr
ifconfig

# Check DNS resolution
nslookup www.google.com
dig www.google.com

# Test connectivity
ping www.google.com

:: Windows - Check IP assigned by DHCP
ipconfig

:: Check DNS resolution
nslookup www.google.com

:: Test connectivity
ping www.google.com
Cyber Security
Introduction Types of Cyber Threats Cyber Security Domains CIA Triad (Confidentiality Integrity Availability) Career paths in Cyber Security Certifications Ethics and Responsible Disclosure Laws and Regulation (e.g. GDPR, NDPR) What is an OS? Types: Window, Linus, macOS Command-line vs GUI OS Internals Overview (filesystems, processes, permissions) Windows command prompt basics Linux Bash Basics File System Navigation Basic Scripting IP Addressing DNS, DHCP Mac Address OSI VS TCP/IP Models Ports and Protocols (TCP, UDP) Common Protocols (HTTPS, FTP, SSH, etc.) Packet structure Firewalls, IDS/IPS, VPNs Common attacks: MITM, Sniffing Secure Network Practices How the Web works HTTP vs HTTPS URLs, Headers, Cookies Client-Server Architecture Introduction To Web Security OWASP Top 10 Overview Common Threats (XSS, SQLi, CSRF) Inpute validation and authentication flow Basic Exploitation demo (e.g. XSS) Burp Suite Introduction Using a Browser For Testing Password security MFA-Antivirus Cyber Hygeine Practice Intro To Tools: Nmap, Wireshark, Netstat
All Courses
Advance AI Bootstrap C C++ Computer Vision Content Writing CSS Cyber Security Data Analysis Deep Learning Email Marketing Excel Figma HTML Java Script Machine Learning MySQLi Node JS PHP Power Bi Python Python for AI Python for Analysis React React Native SEO SMM SQL