惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
爱范儿
爱范儿
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
Jina AI
Jina AI
Project Zero
Project Zero
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
月光博客
月光博客
雷峰网
雷峰网
G
Google Developers Blog
V
V2EX
T
Tor Project blog
罗磊的独立博客
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy International News Feed
S
Securelist
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
小众软件
小众软件
Scott Helme
Scott Helme
I
Intezer
T
Threat Research - Cisco Blogs
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
C
CERT Recently Published Vulnerability Notes
Security Archives - TechRepublic
Security Archives - TechRepublic
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
L
Lohrmann on Cybersecurity
T
Troy Hunt's Blog
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Latest news
Latest news
AWS News Blog
AWS News Blog
Apple Machine Learning Research
Apple Machine Learning Research

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Debugging DNS leaks: why your VPN isn't hiding what you think it is
Alan West · 2026-05-18 · via DEV Community

Last month I was setting up a hardened dev environment for a client doing security research. They wanted all traffic from their workstation tunneled through a VPN, no exceptions. Simple, right? Install WireGuard, flip the toggle, done.

Then I ran a leak test and watched their real ISP-assigned DNS server pop up on the report. The traffic was tunneled. The DNS queries weren't. We'd been working under a false sense of privacy for a week.

This is one of those bugs that doesn't crash anything, doesn't throw an error, and silently undermines the entire reason you set up the VPN in the first place. Let's walk through what's actually happening and how to fix it for good.

The frustrating problem

You've done everything right. You're connected to a VPN. curl ifconfig.me returns the VPN's exit IP. Your routing table looks clean. And yet, when you visit a DNS leak test site, your ISP's resolver shows up in the results.

Worse: in some cases your VPN tunnel is fine for HTTP and HTTPS, but DNS is going out of band. Every domain you visit is still visible to your ISP, your coffee shop's network, or whoever else is between you and the resolver you didn't mean to use.

If you're running this setup on a fleet of dev boxes or CI runners that talk to internal services, the consequences get worse. Internal hostnames can leak to public resolvers. Hostnames are often as sensitive as the queries themselves.

Root cause: DNS is not part of your VPN tunnel by default

Here's the thing most VPN tutorials gloss over. A VPN tunnel routes IP packets. DNS resolution happens at the OS level, often before the packet routing decision, using whatever resolver was configured by your DHCP lease, your /etc/resolv.conf, or your systemd-resolved stub.

There are usually three culprits:

  • systemd-resolved keeps per-link DNS configurations and may continue using the original interface's DNS even when traffic is routed elsewhere.
  • Browsers with DNS-over-HTTPS (Firefox, Chrome) bypass the OS resolver entirely and talk directly to a hardcoded DoH endpoint over HTTPS — which is tunneled through the VPN, but goes to a third party you may not trust.
  • Applications using their own resolvers — Go binaries with GODEBUG=netdns=go, some container runtimes, and language-specific resolver libraries can ignore system settings.

The VPN sees the encrypted DoH request and dutifully tunnels it. The OS resolver sends its plaintext UDP/53 query out the wrong interface. Both paths can coexist on the same machine, which is what makes this so confusing to debug.

Step 1: Confirm the leak

Before fixing anything, prove it's actually leaking. The cheapest reliable test is tcpdump on the physical interface (not the VPN interface) while you trigger a lookup.

# In one terminal, watch DNS on your physical NIC
sudo tcpdump -i wlan0 -n 'udp port 53 or tcp port 53'

# In another terminal, trigger a fresh lookup
# Use a unique domain so cached answers don't hide the issue
dig $(uuidgen | tr A-Z a-z).example.com

Enter fullscreen mode Exit fullscreen mode

If anything shows up on the first terminal, you're leaking. If the only DNS traffic appears on your VPN interface (wg0, tun0, etc.), you're clean.

You can also check what resolver your system thinks it's using:

# systemd-resolved status, per-interface
resolvectl status

# Classic view
cat /etc/resolv.conf

# What's actually being asked, in real time
sudo resolvectl monitor

Enter fullscreen mode Exit fullscreen mode

The monitor subcommand is underrated — it shows every query the stub resolver processes, including which interface it was sent over.

Step 2: Force DNS through the tunnel

The fix depends on your VPN client, but the principle is the same: every DNS query must travel inside the encrypted tunnel and hit a resolver on the other side.

For a WireGuard config, this is one line:

[Interface]
PrivateKey = <your-private-key>
Address = 10.0.0.2/24
# Use a resolver that lives on the VPN side
DNS = 10.0.0.1

[Peer]
PublicKey = <peer-public-key>
Endpoint = vpn.example.com:51820
# Route everything, including DNS
AllowedIPs = 0.0.0.0/0, ::/0

Enter fullscreen mode Exit fullscreen mode

The DNS = line tells wg-quick to update /etc/resolv.conf (or talk to systemd-resolved) so queries go to a server reachable only through the tunnel. The AllowedIPs = 0.0.0.0/0 part ensures the packet to that resolver actually enters the tunnel — without it, your route table might still send the DNS query out the default gateway.

For OpenVPN, the equivalent push options usually come from the server side, but you can force them locally:

# In your client config
dhcp-option DNS 10.8.0.1
block-outside-dns       # Windows-only, blocks leaks aggressively
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

Enter fullscreen mode Exit fullscreen mode

On macOS and Linux, that update-resolv-conf script is the one that actually modifies the system resolver. It's worth reading — it's a useful template for understanding how DNS gets injected at runtime.

Step 3: Tame the browsers and runtimes

This is the step most people skip. Even with a perfect VPN config, Firefox and Chrome can still bypass your OS resolver if DoH is enabled.

For Firefox, set this in about:config:

network.trr.mode = 5   // Off by user choice; do not use DoH

Enter fullscreen mode Exit fullscreen mode

Mode 5 disables DoH entirely. If you want DoH but routed through your VPN's resolver, use mode 3 and set network.trr.uri to your tunnel-side endpoint. The Mozilla TRR docs explain the modes in detail.

For Go programs, force the system resolver:

// Force cgo-based resolution which respects /etc/resolv.conf changes
// done by the VPN client. The pure-Go resolver has caching that
// can outlast a VPN session change.
import _ "net"

// Or via environment
// GODEBUG=netdns=cgo+2

Enter fullscreen mode Exit fullscreen mode

The +2 gives you debug output showing which resolver path was actually taken — invaluable when you're not sure if your fix landed.

Step 4: Block the leak path entirely

Belt and suspenders. Add firewall rules that drop any DNS traffic not going through the tunnel. This way, if a misconfigured app tries to bypass, it fails loudly instead of leaking silently.

# nftables: block UDP/53 and TCP/53 on the physical interface
sudo nft add table inet vpn_guard
sudo nft add chain inet vpn_guard output { type filter hook output priority 0 \; }
sudo nft add rule inet vpn_guard output oifname wlan0 udp dport 53 drop
sudo nft add rule inet vpn_guard output oifname wlan0 tcp dport 53 drop

Enter fullscreen mode Exit fullscreen mode

If an app tries to leak, it gets a connection refused instead of a successful query to your ISP. That's a much better failure mode — you'll notice it immediately.

Prevention tips for future projects

  • Test the leak path every time you change network config. Don't trust that the previous setup still works after a kernel update or VPN client upgrade.
  • Prefer kill-switch behavior — drop all non-VPN traffic at the firewall when the tunnel is down. Most modern VPN clients support this; if yours doesn't, use nftables.
  • Standardize DNS at the tunnel exit. Run an unbound or dnsmasq instance on the VPN server so you control the resolver path end to end.
  • Audit application-layer resolvers. Browsers, container runtimes, and language standard libraries each have their own DNS quirks. Document them per project.
  • Run a periodic automated leak test. A daily cron job that runs dig against a unique subdomain and checks your authoritative server's logs for the source IP works well.

DNS leaks are the kind of bug that hides in plain sight. The fix isn't hard once you know where to look, but the surface area is bigger than most people realize. If you're going to put the work into setting up a VPN, spend the extra hour making sure your name resolution actually respects it.