How to Use the HOSTS file to block website ing

Source: Internet
Author: User

Wen/Ge wenjuan

I first thought of the inconvenience caused by using the Hosts file to access the webpage based on the Cross-network segment of the school: the school teaching network system is divided into four network segments, it includes three student network rooms and one office instructor network segment. The server does not use DNS. In some office hosts, PWS (Personal Web Server) is enabled. Teachers can access the webpage smoothly by entering the Host Name (Host Name) in the same network segment, but they need to access the instructor's Web page in the student data center, the IP address is required.

Hosts is a file used in early Windows to establish the ing between IP addresses and Host names. In this way, you only need to enter the host name when accessing the host on the client. With the introduction of DNS concept and the establishment of Internet-based DNS servers, this file has been gradually forgotten. Because the execution priority of the Hosts file is higher than that of DNS domain name resolution, in order to prevent confusion between Hosts and DNS domain name access, the Hosts is changed to Hosts in Windows 98. sam is to cancel the domain name resolution function of the file. This document uses the Hosts file function.

The Hosts. sam file is located in the C: \ Windows Folder. to use its functions, you must first change it to the Hosts file, that is, remove the extension. Use NotePad to open the Hosts file. The first thing you see is Microsoft's description of this file. This file works according to TCP/IP for Windows standards and requires that each segment contain only one ing relationship, and the IP address should be placed at the beginning of each segment, enter the mapped Host name (Host name) after a space, for example:

127.0.0.1 www.sina.com.cn

# Blocking Sina websites

192.168.0.250 www.stw.net

# Web ing of Web server host names in schools

After entering the two domain names in the browser according to the above method, the problem occurs: xinlang can still be accessed normally, but the webpage is slow (not blocked ), however, the internal website of the school still cannot be accessed correctly. By accident in the MS-DOS Ping the two domain names, but found that the ing has been set up. Strange: Why is the ing not correct in the browser when Ping is enabled in the doscommand line?

There is only one explanation: the Hosts setting is valid and is invalid by the IE browser.

After opening the browser, I studied the Internet Options settings of IE, finally found the crux of the problem, and found a solution.

The client of our school accesses the Internet through an HTTP proxy, so the settings shown in browser 1 are displayed. After "√" is removed before "use proxy server for LAN", the above ing takes effect in IE, and web pages of the campus network across network segments can be accessed through Http: // www.stw.net is accessed, but a new problem occurs. when accessing other Internet webpages in the browser, it is displayed that it cannot be connected. That is, you can access the Intranet and cannot access the Internet. It seems that this method is not feasible. Can I disable the proxy server and use the above ing relationships? With this problem, I opened the [advanced] Option of "LAN (LAN) Settings" and opened the "Proxy Server Settings" dialog box (figure 2 ), add the URLs to be blocked in the Hosts file to the text box corresponding to the "exception" and [OK] and exit. In this case, the Internet can be accessed and blocked.

The above problems cannot be encountered by users who connect to the public network through a single machine, because it does not need to set up a proxy server. for LAN users who require a proxy to connect to the public network and want to shield unhealthy webpages, you need to do this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.