为什么youtube.com的解析IP会直接发送到google.com? [英] Why does the resolved IP of youtube.com direct to google.com?

查看:278
本文介绍了为什么youtube.com的解析IP会直接发送到google.com?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常愚蠢的问题,但我很好奇。

This might be a really stupid question, but I'm curious.

youtube.com的ping显示已解析的IP为74.125.127.93。现在,如果您在浏览器 http://74.125.127.93/ 中访问此IP,您可能希望显示youtube页面向上。相反,搜索引擎会出现。

A ping of youtube.com showed the resolved IP to be 74.125.127.93. Now, if you access this IP in a browser http://74.125.127.93/ you would expect the youtube page to show up. Instead the search engine shows up.

有人可以解释幕后发生的事情吗?
谢谢。

Can someone explain what's going on behind the curtain? Thanks.

推荐答案

因为有很多服务器名称但只有几个IP地址。

Because there are many server names but only a few IP addresses.

让我解释一下。 IPv4允许2 ^ 32(40亿)个不同的IP地址。听起来很多,但大多数都无法使用。 IP地址始终以块的形式分配。最小的块是255个地址(8位 - 1个广播地址),最大的是1600万个地址(2 ^ 24-1)。中型块具有64k地址(16位)。

Let me explain. IPv4 allows 2^32 (4 billion) different IP addresses. Sounds like a lot but most of them can't be used. IP-addresses are always allocated in blocks. The smallest block is 255 addresses (8 bit - 1 address for broadcasts), the biggest one is 16 million addresses (2^24-1). Medium sized blocks have 64k addresses (16 bit).

如果您是ISP,则会获得一组固定的地址。但是当然你总是要求一个比你绝对需要的块更大的块 - 否则你将耗尽地址,这对ISP来说真的很糟糕。你可以要求两个16位的块,但加入这两个块总是很麻烦。

If you're an ISP, you get a fixed set of addresses. But of course you always ask for a block that is larger than what you absolutely need - otherwise you'll run out of addresses and that's really bad for an ISP. You could ask for two 16 bit blocks but joining the two blocks is always a hassle.

上周,我们用完了IPv4块。所以...你有一个64k块,无法获得更多。但是你有150'000个想要运行网络服务器的客户。

Last week, we ran out of IPv4 blocks. So ... you have a 64k block and can't get more. But you have 150'000 customers which want to run a web server.

解决方案:虚拟服务器。你告诉你的DNSxycom是13.242.251.17,aycom也是同一个地址和bycom。

The solution: virtual servers. You tell your DNS "x.y.com" is 13.242.251.17 and "a.y.com" is the same address and "b.y.com", too.

当客户提出请求时,它将执行始终返回相同IP的DNS查询。然后它向刚刚获得的IP发送HTTP请求。诀窍是HTTP请求包含服务器名称。因此,即使所有请求都转到相同的IP地址,Web服务器仍然可以确定您真正想要的是谁。

When a client makes a request, it will do a DNS query which always returns the same IP. Then it sends a HTTP request to the IP it just got. The trick is that the HTTP request contains the server name. So even though all the requests go to the same IP address, the web server can still figure out who you really want.

只要您给它命名即可。如果您使用IP,则会获得默认服务,即Google搜索引擎。

As long as you give it the name. If you use the IP instead, you get the default service which is the Google search engine.

使用 telnet ,你可以自己试试。以 telnet 74.125.127.93 80 启动它,然后输入:

With telnet, you can try this yourself. Start it with telnet 74.125.127.93 80 and then type:

GET http://www.google.com/index.html HTTP/1.1

点击两次。您将获得您所在国家/地区的Google主页的重定向。现在输入:

Hit enter twice. You will get a redirect for the Google homepage of your country. Now type:

GET http://www.youtube.com/ HTTP/1.1

点击两次。这一次,YouTube主页将被退回。

Hit enter twice. This time, the YouTube homepage will be returned.

这篇关于为什么youtube.com的解析IP会直接发送到google.com?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆