A hostname is the human-readable name assigned to a device (or host) on a network — a more memorable alternative to using its IP address.
Think of It Like:
Hostname = Contact name in your phone IP address = Phone number
You don’t remember everyone’s phone number. Similarly, you use hostnames like google.com or backend-service instead of IPs like 142.250.182.206.
Types of Hostnames
1. Domain Names (FQDN)
- Fully Qualified Domain Name
- Example: www.example.com
- www → subdomain
- example → domain
- .com → TLD (top-level domain)
2. Local Hostnames
- Set within a local network or system
- Examples:
localhost→ refers to127.0.0.1my-pc.local→ your laptop’s local name on LAN
How Hostnames Work
- You type www.google.com
- The system uses DNS (Domain Name System) to resolve it to an IP address.
- It sends a request to that IP over the internet.
Hostname in System Design
| Use Case | Description |
|---|---|
| Service discovery | Apps use hostnames like auth-service instead of hardcoded IPs. |
| DNS-based routing | Hostnames route traffic to different services (e.g., api.example.com, shop.example.com). |
| Kubernetes | Pods/services get auto-generated hostnames. |
| Load balancing | DNS-based load balancers use hostnames to distribute traffic. |
| SSL/TLS | Certificates are tied to hostnames, not IPs. |
Example: /etc/hosts file
127.0.0.1 localhost
192.168.1.10 my-laptop
You can use this to override hostname resolution manually.
Important Points
- A hostname maps to an IP — not the other way around.
- A hostname can map to multiple IPs (for redundancy/load balancing).
- You can assign a hostname to a static or dynamic IP (via dynamic DNS).