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

·Updated on:·Matija Žiberna·
Local DNS Override — Mirror a Production Domain Locally

📚 Get Practical Development Guides

Join developers getting comprehensive guides, code examples, optimization tips, and time-saving prompts to accelerate their development workflow.

No spam. Unsubscribe anytime.

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

0

Frequently Asked Questions

Comments

Leave a Comment

Your email will not be published

10-2000 characters

• Comments are automatically approved and will appear immediately

• Your name and email will be saved for future comments

• Be respectful and constructive in your feedback

• No spam, self-promotion, or off-topic content

Matija Žiberna
Matija Žiberna
Full-stack developer, co-founder

I'm Matija Žiberna, a self-taught full-stack developer and co-founder passionate about building products, writing clean code, and figuring out how to turn ideas into businesses. I write about web development with Next.js, lessons from entrepreneurship, and the journey of learning by doing. My goal is to provide value through code—whether it's through tools, content, or real-world software.