修改window本地hosts文件,修改域名指向
如何修改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
在最后新增如下内容:
127.0.0.1 www.163.com
表示域名“www.163.com”指向的ip为127.0.0.1,即本地。修改后文件内容如下:
# 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
127.0.0.1 www.163.com
修改后用浏览器访问“www.163.com”会被解析到127.0.0.1,导致无法显示该网页。
为了进一步验证,使用tomcat在本地启动一个Web服务。tomcat版本为:apache-tomcat-8.5.4,其他版本应该操作类似。
下载解压tomcat后,运行apache-tomcat-8.5.4\bin\startup.bat,待tomcat启动成功,本地就有了一个Web服务了。
这时再访问"www.163.com:8080",就可以看到有页面内容了:
为什么要加上8080呢,因为这是端口号,tomcat开启的Web服务默认使用8080端口,而浏览器中默认的是80端口,所以必需要显示指明。也可以修改tomcat安装目录下的config/server.xml中的8080为80,这样就不用在访问时显式指定端口了。
这就是通过修改hosts文件来使域名指向某个IP的方式了,如果需要添加多条配置,直接再新增一行内容就行了。
修改window本地hosts文件,修改域名指向的更多相关文章
- 修改Window的hosts文件提示“该文件被其他程序占用”解决方案
1.打开C:\Windows\System32\drivers\etc中的hosts 2.右键——>属性——>安全 3.在修改保存就可以了
- 【计算机网络】windows修改本机hosts文件
hosts 文件所在的位置 C:/windows/system32/drivers/etc/hosts 修改后不必重启立即生效的方法 命令行下运行: ipconfig /displaydns 显示所有 ...
- 如何修改本地hosts文件?
1.window7修改本地hosts文件 # window7系统hosts文件位置 C:\Windows\System32\drivers\etc 2.linux # linux系统hosts文件位置 ...
- 修改容器的hosts文件
修改容器的hosts文件 1.介绍 docker容器中的hosts文件虽然在宿主机磁盘上/var/lib/docker/containers/xxx/hosts中,但是修改该文件是无效的,需要通过其他 ...
- k8s修改pod的hosts文件
1.在1.7版本后使用HostAliases修改pod的hosts文件.该文件由kubelet管理 在deployment的yaml文件中添加在pod template 的spec里面即可: apiV ...
- SUSE系列---修改IP和hosts文件
有些时候我们需要修改linux系统的IP,此时我们要注意,修改IP之后,如果我们如果不修改hosts文件,那么可能我们一些服务会无法使用:下面分别记录修改IP和hosts文件的方法: 修改IP: 打开 ...
- svn 从文件上次修改以来没有任何文件修改或加入。
现象:代码已经被修改过了,但是再往svn上提交代码时仍然提示: 从文件上次修改以来没有任何文件修改或加入. 解决办法: 1.找打存放代码的文件夹,右键——TortoiseSVN——clean up(清 ...
- Ubuntu16.04/windows7修改本地hosts文件
1. 从github上下载最新的hosts文件:https://serve.netsh.org/pub/ipv4-hosts/ ubuntu16.04: 第二步:Ctrl+Alt+T 打开ubuntu ...
- hosts文件修改之后立刻刷新
最近因为项目的需要,总是修改hosts文件,每次修改之后都要重启浏览器,总结下刷新的方式 window下,hosts文件位置:C:\windows\system32\drivers\etc\hosts ...
随机推荐
- maven使用笔记--在父pom中声明过的jar可以被继承,使子项目不用写版本号由父pom控制
将dependencies放到dependencyManagement中,如下: [html] view plaincopy <dependencyManagement> <depe ...
- SCCM2012 R2实战系列之十:解决WDS服务无法启动问题(错误1067:进程意外终止)
在操作系统分发(OSD)之前需要开启PXE服务,然后会自动在SCCM服务器安装Windows Deployment Service. 但是之前在一次项目过程当中发现启用PXE服务后WDS无法启动,本以 ...
- jQuery动态创建DOM节点
var SKU=$("#SKU"); // 通过ID查找到指定表格 var oTable=SKU[0]; // 获取第一个表格 // 获取正文tbody元素 var tBodies ...
- c#线程间传递参数
线程操作主要用到Thread类,他是定义在System.Threading.dll下.使用时需要添加这一个引用.该类提供给我们四个重载的构造函数(以下引自msdn). Thread (P ...
- 为什么使能RPS/RFS, 或者RSS/网卡多队列后,QPS反而下降?
http://laoar.github.io/blog/2017/05/07/rps/ TL;DR RPS 即receive side steering,利用网卡的多队列特性,将每个核分别跟网卡的一个 ...
- Android最新版支付宝支付集成
上次集成支付宝支付已经很久了,今天写东西用到了支付宝支付,就大致写一下流程: 去蚂蚁金服下载最新版的Android&IOS端SDK 全部文档 -- 资源下载 -- App支付客户端 下载后解压 ...
- spring启动找不到spring.liveBeansView.mbeanDomain配置
做项目时,启动tomcat报错 JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with m ...
- spring security demo
直接上代码. 这个类似于配置一个shiro.xml redis.xml boot 里面xml用注解取代. 启动类 验证启用: 退出: end. spring 官网 start.spring.io
- 关于php中的exec命令
这个命令 一般是被禁用的 一些特殊需求的时刻 可以启用 比如 调用系统上的一些数据或者命令 $command ='/www/wwwroot/t.6328.net/Public/cfile/test' ...
- 温故而知新-robots.txt语法教程
用几个最常见的情况,直接举例说明: 1. 允许所有SE收录本站:robots.txt为空就可以,什么都不要写. 2. 禁止所有SE收录网站的某些目录: User-agent: * Disall ...