• Home
BuildWithMatija
Get In Touch
  1. Home
  2. Blog
  3. Tools
  4. Local DNS Override — Mirror a Production Domain Locally

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

16th January 2026·Updated on:27th January 2026·MŽMatija Žiberna·
Tools
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

📄View markdown version
0

Frequently Asked Questions

Comments

Leave a Comment

Your email will not be published

Stay updated! Get our weekly digest with the latest learnings on NextJS, React, AI, and web development tips delivered straight to your inbox.

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.

On this page:
Build With Matija Logo

Build with Matija

Matija Žiberna

Full Stack Developer specializing in Next.js and TypeScript. Co-founder of We Hate Copy Pasting, building solutions for D2C brands.

Quick Links

About
  • Projects
  • Commands
  • Blog
  • Contact
  • Get in Touch

    Have a project in mind? Let's discuss how we can help your business grow.

    Contact me →
    © 2026BuildWithMatija•Crafting digital experiences with code•All rights reserved