Local DNS Override — Mirror a Production Domain Locally
Use a hosts file DNS override to resolve product-domain.local to production IPs for testing, QA, and red teaming

📚 Get Practical Development Guides
Join developers getting comprehensive guides, code examples, optimization tips, and time-saving prompts to accelerate their development workflow.
Local DNS override to mirror a production domain
This technique makes a local machine resolve an alternate hostname to a real production server. It helps with red teaming, testing client behavior, and working around tooling that blocks direct interaction with production URLs.
Goal
Access a production service using an alternate hostname on your local machine.
Example: product-domain.local resolves to the same server as product-domain.com.
Step 1: Resolve the real IP
Find the production IP address.
dig product-domain.com
Example result:
34.54.184.215
Step 2: Override DNS locally
Edit the hosts file.
sudo nano /etc/hosts
Add:
34.54.184.215 product-domain.local
Save and exit.
Step 3: Access the service https://product-domain.local
Expected behavior
The server responds normally
HTTPS shows a certificate warning because the certificate is issued for product-domain.com and the hostname is product-domain.local
This is expected and confirms the override works.
Important notes
This affects only your local machine
DNS resolution is overridden; traffic still goes to the same server
TLS hostname validation requires either accepting the warning or using HTTP
External production DNS records remain unchanged
Why this works
DNS decides where traffic goes TLS decides whether the hostname is trusted
DNS can be overridden locally TLS requires control over certificates to present a trusted hostname