Coming soon is a brand new approach to hosts file updates!
Introduction | There are many useful lists of different spam domains that are continuously maintained online. Copying these lists into your hosts file makes it easy to block so many domains that your system won't have to connect to them at all. This method works without installing a browser plug-in and will provide blocking action for any browser (and any other program) on your system. |
In this tutorial, I'll show you how to get Steven Black's Unified Host script up and running in Linux. This script will update your computer's hosts file with the latest known addresses of ad servers, phishing sites, and other spam from multiple sources while providing a nice, clean way to manage your own blacklists/whitelists Lists, one from each list managed by this script.
There are two things to note before putting 30,000 domains into the hosts file. First, these huge lists contain servers that may need to be unblocked in order to make online purchases or some other temporary situation. If you mess with your hosts file, know that something online might go wrong. To solve this problem, I'm going to show you how to use a convenient on/off switch so that you can quickly disable your block list for buying a Himalayan Salt Spray Lamp (it's a plasma lamp). I still think one of the purposes of these lists is to block everything out (kind of annoying, until I thought of making an off switch). If you frequently have issues with a server you need being blocked, just add it to the whitelist file.
The second problem is that performance is slightly affected because the system has to check the entire list every time a domain is called. It's just a small impact, but not so big that I give up blacklisting and let every connection go through. It's up to you how you choose.
The hosts file blocks requests by directing them to 127.0.0.1 or 0.0.0.0 (in other words to a null address). Some say using 0.0.0.0 is faster and less problematic. You can configure the script to use the ip option like "-ip nnn.nnn.nnn.nnn" as the blocking ip, but the default is 0.0.0.0, which is the value I used.
I used to do what Steven Black's script does manually every once in a while, go to each site, copy/paste their list into my hosts file, do a find and replace and replace 127 of them becomes 0 and so on. I knew the whole thing could be automated and it would be a bit silly to do so, but I never took the time to figure it out. Until I found this script, it was now a forgotten chore.
Let's start by downloading a copy of the latest Steven Black code (approximately 150MB) so that we can proceed to the next step. You need to install git, so if you haven't installed it yet, enter the terminal and enter:
sudo apt-get install git
After installation, enter:
There are many useful lists of different spam domains that are maintained online. Copying these lists into your hosts file makes it easy to block so many domains that your system won't have to connect to them at all. This method works without installing a browser plug-in and will provide blocking action for any browser (and any other program) on your system.
In this tutorial, I'll show you how to get Steven Black's Unified Host script up and running in Linux. This script will update your computer's hosts file with the latest known addresses of ad servers, phishing sites, and other spam from multiple sources while providing a nice, clean way to manage your own blacklists/whitelists Lists, one from each list managed by this script.
There are two things to note before putting 30,000 domains into the hosts file. First, these huge lists contain servers that may need to be unblocked in order to make online purchases or some other temporary situation. If you mess with your hosts file, know that something online might go wrong. To solve this problem, I'm going to show you how to use a convenient on/off switch so that you can quickly disable your block list for buying a Himalayan Salt Spray Lamp (it's a plasma lamp). I still think one of the purposes of these lists is to block everything out (kind of annoying, until I thought of making an off switch). If you frequently have issues with a server you need being blocked, just add it to the whitelist file.
The second problem is that performance is slightly affected because the system has to check the entire list every time a domain is called. It's just a small impact, but not so big that I give up blacklisting and let every connection go through. It's up to you how you choose.
The hosts file blocks requests by directing them to 127.0.0.1 or 0.0.0.0 (in other words to a null address). Some say using 0.0.0.0 is faster and less problematic. You can configure the script to use the ip option like -ip nnn.nnn.nnn.nnn as the blocking ip, but the default is 0.0.0.0, which is the value I used.
我曾经将 Steven Black 的脚本做的事每隔一段时间就手动做一遍,进到每一个站点,将他们的列表拷贝/粘贴到我的主机文件中,做一个查找替换将其中的 127 变成 0 等等。我知道整件事情可以自动化,这样做有点傻,但我从来没有花时间解决这个问题。直到我找到这个脚本,现在这事已经是一个被遗忘的杂务。
让我们先下载一份最新的 Steven Black 的代码拷贝(大约 150MB),以便我们可以进行下一步。你需要安装 git,因此如果还没安装,进入到终端输入:
sudo apt-get install git
安装完之后,输入:
mkdir unifiedhosts cd unifiedhosts git clone https://github.com/StevenBlack/hosts.git cd hosts
当你打开了 Steven 的脚本时,让我们来看看有什么选项。该脚本有几个选项和扩展,但扩展我不会在这里提交,但如果你到了这一步并且你有兴趣,readme.md 可以告诉你所有你需要知道的。
你需要安装 python 来运行此脚本,并且与版本有关。要找到你安装的 Python 版本,请输入:
python --version
如果你还没安装 Python:
sudo apt-get install python
对于 Python 2.7,如下所示,输入 python 来执行脚本。对于 Python 3,在命令中的 python 替换成 python3。执行后,该脚本会确保它具有每个列表的最新版本,如果没有,它会抓取一个新的副本。然后,它会写入一个新的主机文件,包括了你的黑名单/白名单中的任何内容。让我们尝试使用 -r 选项来替换我们的当前的主机文件,而 -a 选项可以脚本不会问我们任何问题。回到终端:
python updateHostsFile.py -r -a
该命令将询问你的 root 密码,以便能够写入 /etc/。为了使新更新的列表处于激活状态,某些系统需要清除 DNS 缓存。在同一个硬件设备上,我观察到不同的操作系统表现出非常不同的行为,在没有刷新缓存的情况下不同的服务器变为可访问/不可访问所需的时间长度都不同。我已经看到了从即时更新(Slackware)到重启更新(Windows)的各种情况。有一些命令可以刷新 DNS 缓存,但是它们在每个操作系统甚至每个发行版上都不同,所以如果没有生效,只需要重新启动就行了。
现在,只要将你的个人例外添加到黑名单/白名单中,并且只要你想要更新主机文件,运行该脚本就好。该脚本将根据你的要求调整生成的主机文件,每次运行文件时会自动追加你额外的列表。
最后,我们来创建一个打开/关闭开关,对于打开和关闭功能每个都创建一个脚本,所以回到终端输入下面的内容创建关闭开关(用你自己的文本编辑器替换 leafpad):
leafpad hosts-off.sh
在新文件中输入下面的内容:
#!/bin/sh sudo mv /etc/hosts /etc/hostsDISABLED
接着让它可执行:
chmod +x hosts-off.sh
相似地,对于打开开关:
leafpad hosts-on.sh
在新文件中输入下面的内容:
#!/bin/sh sudo mv /etc/hostsDISABLED /etc/hosts
最后让它可执行:
chmod +x hosts-on.sh
你所需要做的是为每个脚本创建一个快捷方式,标记为 HOSTS-ON 和 HOSTS-OFF,放在你能找到它们的地方。
The above is the detailed content of Coming soon is a brand new approach to hosts file updates!. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

CentOS has been discontinued, alternatives include: 1. Rocky Linux (best compatibility); 2. AlmaLinux (compatible with CentOS); 3. Ubuntu Server (configuration required); 4. Red Hat Enterprise Linux (commercial version, paid license); 5. Oracle Linux (compatible with CentOS and RHEL). When migrating, considerations are: compatibility, availability, support, cost, and community support.

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.
