美文网首页
修改映射地址

修改映射地址

作者: 我弟是个程序员 | 来源:发表于2017-09-12 23:29 被阅读0次

    有时候,当我们在虚拟机上的Linux上部署了服务后,需要给Linux对应的ip设置一个域名便于访问,这个时候就可以来操作

    找到 C:\Windows\System32\drivers\etc 目录下的hosts文件,在最后一行添加你要映射的地址和域名,如这样:

    # Copyright (c) 1993-2009 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    
    # localhost name resolution is handled within DNS itself.
    #   127.0.0.1       localhost
    #   ::1             localhost
    
    192.168.0.107   develop.sqlb.org
    
    

    本人遇到了一个特别坑的问题,就是当我修改了域名后,怎么也访问不到对应的服务,可能是DNS域名解析到了一个已经缓存的地址,就跳转了。网上说可以这么操作来清除DNS缓存,如下:

    ipconfig /flushdns
    

    但我试了,并没有什么暖用。这时候,我们可以使用ping操作,

    ping develop.sqlb.org
    

    发现,能过ping通,说明我的设置操作是正确的。
    哎,这个时候,我不得不修改成了另一域名再去访问,结果当然是成功了。

    相关文章

      网友评论

          本文标题:修改映射地址

          本文链接:https://www.haomeiwen.com/subject/cpwhsxtx.html