如何防止hosts文件被修改

  • 格式:docx
  • 大小:14.94 KB
  • 文档页数:2

如何防止hosts文件被修改

如何防止hosts文件被修改

开始==》运行==》输入cmd后回车==》复制代码框内容到CMD窗口,回车执行。

禁止修改HOSTS文件:

attrib +r +a +s +h %windir%\system32\drivers\etc\hosts

echo y|cacls %windir%\system32\drivers\etc\hosts /g

everyone:r

允许修改HOSTS文件:

echo y|cacls %windir%\system32\drivers\etc\hosts /g

everyone:f

attrib -r -a -s -h %windir%\system32\drivers\etc\hosts

host 文件默认内容如下:

# Copyright (c) 1993-1999 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 # source server

# 38.25.63.10 # x client host

127.0.0.1 localhost