Fundamentals 5 min read

Why Can’t You Access Zhihu by IP? The Role of CDN and SNI Explained

The article explains why accessing Zhihu with its raw IP address is blocked while domain access works, covering CDN sharing, the importance of hostnames, and how the TLS SNI extension lets servers identify the intended website before establishing a connection.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Why Can’t You Access Zhihu by IP? The Role of CDN and SNI Explained

After pinging Zhihu’s domain to obtain its IP address, the author tried to open the site directly via the IP in a browser and was denied access, whereas accessing Baidu by IP worked without issue.

Because IPv4 addresses are limited, many websites share a single CDN server, meaning multiple domain names can resolve to the same IP.

What is a CDN? A CDN (Content Delivery Network) is essentially a cache server that stores website resources at locations closer to users, reducing latency by delivering the nearest copy of the requested content.

When a user accesses Zhihu via its domain name, the CDN can read the requested hostname and return the correct resources for that site.

However, when the same IP address is used directly, the CDN sees only the IP, which may correspond to many different domains. Because it cannot determine which site the client wants, the CDN simply rejects the request.

Some readers wonder why DNS resolution to an IP does not produce the same result. The key is that after DNS translates the domain to an IP, the client still sends the original hostname during the TLS handshake using the SNI (Server Name Indication) extension.

During the handshake, the CDN examines the SNI field to discover which domain the client intended to reach, allowing it to serve the appropriate content even though the underlying connection uses the same IP address.

Brief introduction to SNI: SNI (Server Name Indication) is a TLS extension that lets a client indicate the desired hostname before the encrypted connection is established, enabling a single server (or IP) to host multiple HTTPS sites.

For a more detailed explanation, see the original article: https://blog.csdn.net/firefile/article/details/80532161

Finally, the author notes that Baidu’s CDN appears to be dedicated to a single domain, which is why both its IP and domain work without restriction.

print_r('点个好看吧!');
var_dump('点个好看吧!');
NSLog(@"点个好看吧!");
System.out.println("点个好看吧!");
console.log("点个好看吧!");
print("点个好看吧!");
printf("点个好看吧!");
cout << "点个好看吧!" << endl;
Console.WriteLine("点个好看吧!");
fmt.Println("点个好看吧!");
Response.Write("点个好看吧!");
alert("点个好看吧!");
echo "点个好看吧!"
CDNNetworkingDNSIP addressSNIweb-access
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.