Note that there are two reasons this might not work like you want it to. You may be aware of these, but I mention them just in case.
First, it won't affect a web browser, for example, that already has the current, "real" IP address resolved. So, it won't always take effect right away.
Second, it requires you to add an entry for every host name on a domain; just adding websitename.com will not block www.websitename.com, for example.
hosts add another.dev 192.168.1.1 # Remote host
hosts add test.local # 127.0.0.1 used by default
hosts set myhost.dev # new comment
hosts rem *.local
hosts enable local*
hosts disable localhost
使用...以及许多其他...
帮助
Usage:
hosts - run hosts command interpreter
hosts <command> <params> - execute hosts command
Commands:
add <host> <aliases> <addr> # <comment> - add new host
set <host|mask> <addr> # <comment> - set ip and comment for host
rem <host|mask> - remove host
on <host|mask> - enable host
off <host|mask> - disable host
view [all] <mask> - display enabled and visible, or all hosts
hide <host|mask> - hide host from 'hosts view'
show <host|mask> - show host in 'hosts view'
print - display raw hosts file
format - format host rows
clean - format and remove all comments
rollback - rollback last operation
backup - backup hosts file
restore - restore hosts file from backup
recreate - empty hosts file
open - open hosts file in notepad
Use Hosts Commander. It's simple and powerful. You can download it here.
Examples of using
hosts add another.dev 192.168.1.1 # Remote host
hosts add test.local # 127.0.0.1 used by default
hosts set myhost.dev # new comment
hosts rem *.local
hosts enable local*
hosts disable localhost
...and many others...
Help
Usage:
hosts - run hosts command interpreter
hosts <command> <params> - execute hosts command
Commands:
add <host> <aliases> <addr> # <comment> - add new host
set <host|mask> <addr> # <comment> - set ip and comment for host
rem <host|mask> - remove host
on <host|mask> - enable host
off <host|mask> - disable host
view [all] <mask> - display enabled and visible, or all hosts
hide <host|mask> - hide host from 'hosts view'
show <host|mask> - show host in 'hosts view'
print - display raw hosts file
format - format host rows
clean - format and remove all comments
rollback - rollback last operation
backup - backup hosts file
restore - restore hosts file from backup
recreate - empty hosts file
open - open hosts file in notepad
发布评论
评论(2)
echo 0.0.0.0 websitename.com >>> %WINDIR%\System32\Drivers\Etc\Hosts
>>
将echo
的输出附加到文件中。请注意,有两个原因可能导致此方法无法按您希望的方式工作。您可能知道这些,但我提及它们以防万一。
首先,它不会影响网络浏览器,例如已经解析了当前“真实”IP 地址的网络浏览器。因此,它并不总是立即生效。
其次,它要求您为域中的每个主机名添加一个条目;例如,仅添加
websitename.com
将不会阻止www.websitename.com
。echo 0.0.0.0 websitename.com >> %WINDIR%\System32\Drivers\Etc\Hosts
the
>>
appends the output ofecho
to the file.Note that there are two reasons this might not work like you want it to. You may be aware of these, but I mention them just in case.
First, it won't affect a web browser, for example, that already has the current, "real" IP address resolved. So, it won't always take effect right away.
Second, it requires you to add an entry for every host name on a domain; just adding
websitename.com
will not blockwww.websitename.com
, for example.使用Hosts Commander。它简单而强大。您可以在此处下载。
的示例
使用...以及许多其他...
帮助
Use Hosts Commander. It's simple and powerful. You can download it here.
Examples of using
...and many others...
Help