修改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 ...
随机推荐
- UE4 材质Lerp节点解疑
转自:http://www.manew.com/thread-46268-1-1.html 1.A是一个灰色,B是一个红色,Alpha是一个颜色图 A到B是0到1,也就是黑到白,所以,alpha图,黑 ...
- [TFS]TFS强制删除离职人员签出锁定项的方法
步骤: 1.连接到TFS数据库服务器的tfsversioncontrol库: 2.查tbl_workspace表,找出那哥们的工作目录, 如select * from tbl_workspace wh ...
- Unix.Trojan.DDoS_XOR-1木马症状及清理办法
父进程名称: crond 进程名称: bash 进程路径: /usr/bin/bash 进程id: 20,517 命令行参数: /bin/sh /etc/cron.hourly/cron.sh 事件说 ...
- ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly.
Sqoop导入mysql表中的数据到hive,出现如下错误: ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.Hi ...
- gulp 编译es6 react 教程 案例 配置
1.gulp基本配置: var gulp = require('gulp'), watch = require('gulp-watch'), babel = require('gulp-babel') ...
- Java - 33 Java Applet基础
Java Applet基础 applet是一种Java程序.它一般运行在支持Java的Web浏览器内.因为它有完整的Java API支持,所以applet是一个全功能的Java应用程序. 如下所示是独 ...
- Linux性能优化 第七章 性能工具:网络
7.1 网络I/O介绍 Linux和其他主流操作系统中的网络流量被抽象为一系列的硬件和软件层次. 链路层,也就是最低的一层,包含网络硬件,如以太网设备.在传送网络流量时,这一层并不区分流量类型,而仅仅 ...
- TCP/IP_网络基础知识
今天看到k8s的网络,顿感网络知识不是特别扎实,立马回头补一下Tcp-ip知识,顺便记录下学习的过程: 计算机与网络发展的7个阶段: 批处理时代(计算机按照顺序处理,50年代)->分时系统时代( ...
- 零基础学习python_字符串(14-15课)
今天回顾下我之前学习python的第一个对象——字符串,这个对象真蛋疼,因为方法是最多的,也是最常见的类型,没有之一... 内容有点多,我就搜了下网上的资料,转载下这个看起来还不错的网址吧:http: ...
- 1、eclipse
1.安装java 32位 jdk-7u79-windows-i586-20151024.rar http://www.oracle.com/technetwork/java/javase/downlo ...