zoukankan      html  css  js  c++  java
  • 如何通过计算机名访问一台主机?

        这并不是一个新的文章,但前段时间由于工作需要遇到了这样的问题。
        我们架设了一个网站,由于某些原因,只能通过计算机名(主机名)访问这个站点,而不能通过IP地址访问。
    而有些时候,我们局域网内的用户是可以访问的,但又有一部分用户不能访问。为此,我查阅了一些资料,发现了这个解决办法。原来在C:\windows\system32\drivers\etc目录下,有一个名为hosts的文件。其内容如下:
     1# Copyright (c) 1993-1999 Microsoft Corp.
     2#
     3# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
     4#
     5# This file contains the mappings of IP addresses to host names. Each
     6# entry should be kept on an individual line. The IP address should
     7# be placed in the first column followed by the corresponding host name.
     8# The IP address and the host name should be separated by at least one
     9# space.
    10#
    11# Additionally, comments (such as these) may be inserted on individual
    12# lines or following the machine name denoted by a '#' symbol.
    13#
    14# For example:
    15#
    16#      102.54.94.97     rhino.acme.com          # source server
    17#       38.25.63.10     x.acme.com              # x client host
    18
    19127.0.0.1       localhost

        我们看到,在最后一行的127.0.0.1 localhost.
    前面是IP地址,后面就是对应这个IP的主机名。因此,现在我们访问127.0.0.1和localhost都是访问的本地主机。
        现在,我们在之后增加一行:
    1211.143.112.*   techserver

        现在我们就可以通过主机名techserver访问IP地址为211.143.112.*的主机了。
  • 相关阅读:
    Cannot set property 'branchdata' of undefined
    关闭Vue Eslint语法检查
    Webpack前世今生
    SpringCloud 之 Netflix Hystrix 服务监控
    Spring Cloud 之 Netflix Hystrix 服务容错
    Java设计模式之建造者模式(Builder Pattern)
    Java设计模式之工厂模式(Factory Pattern)
    数据库表的字段有默认值,如何修改或者去掉这个默认值
    前端基础进阶(十五):详解 ES6 Modules
    JS基础知识题(中)作用域、闭包
  • 原文地址:https://www.cnblogs.com/saptechnique/p/993349.html
Copyright © 2011-2022 走看看