DNS显性+隐性URL转发原理

凉白开 系统管理449,7006字数 1756阅读5分51秒阅读模式

前言

公司的服务器清一色电信,顶级域名解析到服务器上然后跳转到www.ttlsa.com,但是领导反映铁通用户访问顶级域名ttlsa.com不行.对中国的网络除了吐槽还能做什么,顶级域名既然做不了CDN,那把铁通用户使用DNS转发来跳转。以前也挺好奇这个DNS怎么就可以做起url转发了,没道理,他只是把域名解析成IP地址而已。今天专门想了下这个问题,并且也上网查证了下,和我的想法一致.文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

来,我这有个空闲域名域名heytool.com,在dnspod上.文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

 文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

解析顶级域名heytool.com(显性)文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

dns

显性URL解析

 文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

查看DNS解析情况文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

dns

显性URL解析dig-dns

发现被cname到了dnspod-free.mydnspod.net,他对应的两个IP是54.248.82.230,54.248.143.107.看到这里,大家应该已经恍然大悟,原来是这样子。文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

访问测试文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

dns

显性URL解析dig-访问

过程大家可能看不到,可以自己试试看,我这边已经跳转到了www.heytool.com了。文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

浏览器看不到,我这用curl获取下头部文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

# curl -I http://heytool.com
HTTP/1.1 301 Moved Permanently # 301重定向,很和谐
Date: Tue, 27 Aug 2013 08:24:21 GMT 
Cache-Control: max-age=120
Expires: Tue, 27 Aug 2013 08:26:21 GMT
Server: DNSPod URL V2.0 # DNSPod的服务器
Location: http://www.heytool.com # 跳转到www.heytool.com
Content-Length: 0
Connection: close

隐性URL转发文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

dns

隐性URL解析

DNSpod的隐性URL转发还要额外购买,接下来和大家说下大致流程以及对比显性和隐性URL转发有什么不同。文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

显性/隐性URL转发流程文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

解析
1、域名管理员解析heytool.com,选择隐性或者显性url转发,记录值写上http://www.heytool.com或者你想要跳转的地方
2、dns提供商将heytool.com解析到他们的服务器上,并且这台服务器上配置了虚拟主机heytool.com
2.1 显性URL跳转:配置里将所有到这的请求跳转到www.heytool.com.
2.2 隐性URL转发:站点里面的index.html面加上iframe,在里面嵌套www.heytool.com.所以不管你怎么点链接,url地址栏都不会变化.除非你的连接是打开新页面文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

访问
1. 用户在浏览器中输入heytool.com
2. 浏览器做DNS解析,返回54.248.82.230(延续我的例子),浏览器访问54.248.82.230上的heytool.com
2.1 显性URL转发:服务器将你跳转到www.heytool.com
2.2 隐性URL转发:服务器返回一个嵌套www.heytool.com地址的index.html文件,浏览器再次去访问www.heytool.com,并且内容嵌套在index.html里,所以用户就看不到有任何跳转.(不推荐)文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

 文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

为什么要使用URL转发
广大小站长门解析需要,技术是透明的,对不懂技术的小白们来说太简单了.我想肯定还有更多原因.文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

为什么URL转发的IP是国外的
个人认为这符合我们国情,两个字"备案"文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

总结
所谓URL转发,仅仅是DNS服务商提供了一台web服务器专门用来跳转或者返回一个含有iframe的页面而已.文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

转载请注明出处:https://www.ttlsa.com/html/2637.html文章源自运维生存时间-https://www.ttlsa.com/system/dns-url/

weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
凉白开
  • 本文由 发表于 27/08/2013 10:21:44
  • 转载请务必保留本文链接:https://www.ttlsa.com/system/dns-url/
评论  4  访客  4
    • 要哄
      要哄 9

      原来是这样,图文并茂,懂了。

      • 爱笑眼睛
        爱笑眼睛 0

        嗯 对的。 一直都是这样的。 说的很详细,赞!

        • 阿土土H2F
          阿土土H2F 1
          • 默北
            默北 6

            学习了

          评论已关闭!