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!

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Learning Linux is not difficult. 1.Linux is an open source operating system based on Unix and is widely used in servers, embedded systems and personal computers. 2. Understanding file system and permission management is the key. The file system is hierarchical, and permissions include reading, writing and execution. 3. Package management systems such as apt and dnf make software management convenient. 4. Process management is implemented through ps and top commands. 5. Start learning from basic commands such as mkdir, cd, touch and nano, and then try advanced usage such as shell scripts and text processing. 6. Common errors such as permission problems can be solved through sudo and chmod. 7. Performance optimization suggestions include using htop to monitor resources, cleaning unnecessary files, and using sy

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.