今天遇到一个关于DNS的特有意思的事,公司同事原先电脑是直接连在公司内网上的,之前因为测试的需要要连接在路由器上,我们都知道网络默认网关在装换网络时会造成不必要的麻烦的,例如本来公司网络都是192.168.0.1的网段,你通过路由的时候,路由本身的网段会自动设置为这个网段或是必须通过手动设置将路由的网段设置为0网段。这样路由才可以上网。说了这么多总之,你要使得你的电脑能够上网,那你就得将路由的上行网段设置为0(针对我现在的情况)。
今天他把路由去掉重新上网时,直接将猫口连接在公司内网,无论是设置自动获取ip或是使用静态ip竟然无法上网,我通过更改360测试,发现是DNS的异常引起的,便使用DNS的命令:cmd---ipconfig/displaydns ipconfig/flushdns
ipconfig/registernds等命令修复,重启。竟然还是连不了网。郁闷的同时,我猜想这应该不是DNS本身出的问题,可能是网段出现了异常,然后折射到了DNS上,使用360测试工具的时候才会报这个问题。我便抱着试试的心态,将其电脑的ip网段改为192.168.1.1的网段。网络竟然连接上了。
关于DNS异常的处理:两个办法:
1、使用cmd命令:点击左下角win的图标,输入cmd,打开Windows命令处理器;输入ipconfig/displaydns,查看DNS状态,执行命令 ipconfig/flushdns清除DNS信息,执行命令ipconfig/registernds重新启动DNS
2、打开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