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
- You type a website into your browser:
www.example.com
- Your computer asks a DNS server:
“Hey, what is the IP address for www.example.com?”
- The DNS server replies with the IP:
93.184.216.34
- 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
- Your device connects to a network.
- It sends a request: “I need an IP address.”
- The DHCP server responds with an available IP and other network settings.
- 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
- You connect your laptop to Wi-Fi.
- DHCP gives your laptop IP
192.168.1.15, subnet mask255.255.255.0, and DNS8.8.8.8. - You type
www.example.comin your browser. - Your computer asks the DNS server (8.8.8.8) for the IP.
- DNS replies
93.184.216.34. - Your browser connects to
93.184.216.34and loads the website.
All of this happens automatically in a few milliseconds.
# 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