# How to Check for a Claude Code DNS Leak: Test the Browser and the Terminal Separately

> The exit IP is in the United States, but the DNS resolver is a domestic ISP — the most common and most easily overlooked contradiction in Claude environments. This article explains when a Claude Code DNS leak happens, and how to test for it separately in the browser and in the terminal.

- Source: https://ipnet.coffee/en/news/claude-code-dns-leak-test
- Published: 2026-11-19
- Updated: 2026-11-24
- Publisher: ipnet.coffee

The exit IP says the United States, but the DNS resolver is a domestic ISP — that is the most typical picture of a Claude Code DNS leak, and the most frequent kind of contradiction in Claude environment self-checks. A check that only looks at the exit IP shows everything is fine, while DNS tells a different story.

What makes it worse is that the browser and the terminal can send DNS in completely different directions. A browser test showing no leak does not mean Claude Code is clean too.

## What exactly is a Claude Code DNS leak?

Before visiting a domain, a device has to ask a DNS resolver "which IP does this domain map to". For how DNS works, see [Cloudflare's DNS explainer](https://www.cloudflare.com/learning/dns/what-is-dns/). If that question is sent outside the proxy tunnel, then the resolver — and anyone along the path who can see the query — knows your real network location and what you are visiting, even if the HTTPS traffic afterwards really does go out through the proxy.

DNS leak detection works like this: your device is made to resolve a batch of randomly generated subdomains that only the tester's own authoritative DNS can answer. Whichever resolver ends up asking is the resolver you are actually using. Its location is then compared with your exit IP.

## Why is it the most easily overlooked item in risk control?

Of the signals a platform can see, the exit IP is the most conspicuous one, and the only one everyone bothers to check. But the DNS resolver's location is exposed too, and it is independent evidence from the exit IP:

| Exit IP | DNS resolver | Conclusion |
|---|---|---|
| United States | Domestic ISP | The two pieces of evidence contradict each other |
| United States | United States | The two pieces of evidence agree |
| United States | Public DNS, node in Asia | An in-between state, generally not a leak, but still not ideal where regional consistency matters |

A contradiction is more trouble than "not clean". A datacenter IP where all signals point to the same place is far easier to troubleshoot than a residential IP paired with a domestic resolver.

## When does a Claude Code DNS leak happen?

Many guides do not make this clear: where DNS goes depends on how you route Claude Code through the proxy:

- **Using the HTTPS_PROXY environment variable**: Claude Code hands the domain straight to the proxy via HTTP CONNECT, and the proxy resolves it (for the CONNECT method see [MDN's HTTP CONNECT docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT)). Claude Code's own API requests generally are not resolved locally. But the subprocesses it spawns — MCP servers, git, npm — will resolve locally and connect directly if they do not read those variables.
- **TUN mode + fake-ip**: the program locally gets a placeholder address starting with 198.18, and the real resolution is done at the proxy side. This is the least leak-prone setup.
- **TUN mode + redir-host (or real-ip)**: the system first resolves the domain to a real IP locally, then hands it to the proxy. If the local resolver is the ISP's DNS, the query leaks.
- **System proxy mode, with no variables set in the terminal**: Claude Code connects directly — this is no longer a DNS leak issue, the whole connection is not going through the proxy. Start with [troubleshooting Claude Code not using the proxy](https://ipnet.coffee/en/news/claude-code-system-proxy-vs-tun).
- **IPv6 DNS**: the network hands out an IPv6 DNS server while the proxy only captures IPv4, so some queries go out locally.

## Step 1: How to test on the browser side

Open the [DNS leak test](https://ipnet.coffee/en/dns). The quick test does 1 round of 6 resolutions and returns in seconds; the deep test does 5 rounds of 30 resolutions and can sample multiple exits behind public DNS. **When troubleshooting, go straight to the deep test.**

There are three kinds of results:

- **Same region**: the resolver and the exit IP are in the same country. Ideal.
- **Public DNS**: the resolver belongs to Google, Cloudflare or another public DNS, and the node is not in the exit's country. Public DNS uses anycast to assign the nearest node, so this generally is not a leak; but for work that demands regional consistency, switch to a DNS in the same region as the exit.
- **Suspected leak**: your local ISP's resolver shows up and it is not in the same country as the exit. That means DNS queries are not going through the proxy, and the ISP can see which domains you visit.

The middle one is the most easily misread. Seeing "public DNS" is no reason to panic; seeing your ISP's name is the real problem.

## Step 2: How to test on the terminal side

The browser result only represents the browser. The terminal has to be tested separately, and in **the very terminal where you launch Claude Code**.

**Confirm the exit first**:

```bash
curl https://ipnet.coffee
```

The response is this terminal's actual exit IP, country and ASN.

**Then check which resolver the terminal uses.** The domain whoami.akamai.net returns the IP of the resolver that asked it:

```bash
nslookup whoami.akamai.net
```

On macOS / Linux you can also use dig:

```bash
dig +short whoami.akamai.net
```

Look up the returned IP in [IP deep score](https://ipnet.coffee/en/ip):

- It belongs to a domestic ISP: the terminal's DNS queries go out locally, so there is a leak.
- It belongs to public DNS, or to a provider in the same region as the exit: normal.
- It is an address starting with 198.18: you are on TUN fake-ip mode, the local side gets a placeholder and the real resolution happens at the proxy — that is good.

Note that nslookup and dig themselves do not read HTTPS_PROXY; they test "this machine's system DNS path", that is, how subprocesses that do not honor the proxy variables will resolve. For the Claude Code main process, if you are using HTTPS_PROXY, its domains are handled by the proxy, and the exit check in step one is what matters.

## How to fix it

- **Prefer TUN + fake-ip**: in Clash / Mihomo set enhanced-mode: fake-ip in the dns section, and use resolvers reached through the proxy for nameserver. Add printers, NAS, local dev domains and the like to fake-ip-filter.
- **v2rayN**: route port 53 to the proxy outbound and enable traffic sniffing.
- **Check the system and the router**: ISP DNS entered manually on the NIC or router makes queries in redir-host mode go out locally.
- **Handle IPv6**: let the proxy take over IPv6, or disable IPv6 on that NIC.
- **Browser secure DNS (DoH)**: if it is on, make sure its connections also go through the proxy; otherwise turn it off and let the proxy client handle it uniformly.

After changing anything, **restart the browser and the terminal** before testing — DNS caches linger for a while after a config change.

## Which common practices lead you to misjudge?

- **Testing with the proxy off, then assuming the proxy is broken**: first confirm curl https://ipnet.coffee shows the proxy exit.
- **Comparing phone results with computer results**: different devices and different networks have completely different DNS paths; test on the same device at the same time.
- **Treating one "no leak found" as a permanent conclusion**: DNS behavior changes most easily after switching from Wi-Fi to a hotspot, a client upgrade, or a subscription refresh — retest each time.
- **Looking at DNS alone**: DNS is just one of many signals. Check exit IP type, WebRTC and timezone together — you can simply run the [Claude environment check](https://ipnet.coffee/en/claude).

For a systematic walkthrough of the whole setup, from rules to exit to acceptance, see [the full Claude Code proxy configuration guide](https://ipnet.coffee/en/news/claude-code-proxy-setup-guide).

If DNS is aligned and the environment is stable but the account is still asked to verify or gets suspended, the problem is not at the network layer. For those two cases see [Claude identity verification persona: what happens during review](https://ipnet.coffee/en/news/claude-persona-identity-verification) and [claude account suspended appeal: process, materials and sticking points](https://ipnet.coffee/en/news/claude-account-suspended-appeal-guide).

## FAQ

### Will a Claude Code DNS leak get my account banned?

Not directly. A DNS leak is one of many environment signals; on its own it usually just means "one more contradiction to explain", and it is not the same kind of judgment as a ban. But it makes verification and rate limiting more likely to appear.

### If the browser shows no leak, is Claude Code also clean?

Not necessarily. The browser may be using DoH itself, masking the real resolution, while subprocesses spawned by Claude Code in the terminal (git, npm, MCP servers) do not necessarily read HTTPS_PROXY and will resolve via system DNS. Test the two separately.

### Does a "public DNS" result count as a leak?

Generally no. Public DNS uses anycast to assign the nearest node, so a node outside the exit country is normal. What is really worth worrying about is your local ISP's name appearing in the results, in a different country from the exit.

### What does an nslookup result starting with 198.18 mean?

You are on TUN fake-ip mode: the local side gets a placeholder and the real resolution happens at the proxy. That is good, not an error.

### Why restart before testing after a config change?

DNS caches linger for a while after a config change, and both the browser and the system may keep using old results. Testing without restarting easily leads to the wrong conclusion that "the change did not work".
