dd-wrt 去广告_如何在DD-WRT上使用Pixelserv删除广告

dd-wrt 去广告

dd-wrt 去广告

Sorry for the surprise wheezywaiter.

There are numerous ways to block advertisements in your browser, but what if you could block them on the router? Here’s how to use the DD-WRT firmware and deliberate “DNS poisoning” to block ads for every device on your network.

有很多方法可以阻止浏览器中的广告,但是如果可以阻止它们在路由器上怎么办? 以下是使用DD-WRT固件并故意进行“ DNS中毒”以阻止网络上每个设备的广告的方法。

总览 (Overview)

Update: Guide updated to reflect the feedback provided by commenters and updated the anti-ads pack with the newer pixel-server executable and a changelog.

更新 :指南已更新,以反映评论者提供的反馈,并使用更新的像素服务器可执行文件和变更日志更新了反广告包

The first question on everyone’s mind right now is “why not just use ad-block?”

现在每个人都想到的第一个问题是“为什么不仅仅使用广告块 ?”

For a lot of people there simply isn’t a reason, especially with chrome’s new ability to replicate the extensions you use to every computer you are running chrome on.

对于很多人来说,根本没有理由,尤其是chrome的新功能可以将您使用的扩展复制到运行chrome的每台计算机上。

The answer lies somewhere between the reduced overhead of not having to teach all of the users on your network about ad-block (I’m talking to you mom, sis, granny and office secretary) and the convenience of not being bothered with it on every computer you setup. That is assuming that there are going to be some computers on your network that you’re not going to configure your personal environment on (for example “core servers” or VM’s).

答案介于减少的开销之间,这种开销减少了不必教您网络上的所有用户有关广告屏蔽的问题 (我正在和您妈妈,姐姐,奶奶和办公室秘书聊天),而不必为此烦恼您设置的每台计算机。 假设您的网络上将有一些计算机不打算在其上配置个人环境(例如“核心服务器”或VM)。

Note: Even though i use the method below on my home router, I found ad-block to be an excellent addition to it, and I do recommend using both methods in conjunction. also if you don’t have a DD-WRT router using ad-block is more them enough. In fact, I like the program so much, I donated to its developer and i encourage everyone to do so, to keep it’s development going.

注意 :尽管我在家用路由器上使用以下方法,但我发现ad-block是对它的出色补充,并且我建议同时使用这两种方法。 如果您没有使用ad-block的DD-WRT路由器,也足够了。 实际上,我非常喜欢该程序,我捐赠给了它的开发人员,并鼓励每个人都这样做,以保持其发展。

它是如何工作的? (How does it work?)

Essentially this works by deliberately poisoning our DNS to return a specific IP for domains in the an unapproved list. This unapproved list will contain domain names of sites that are responsible exclusively for delivering advertisement content, so we won’t miss them much.

从本质上讲,这是通过故意使我们的DNS中毒来为未经批准的列表中的域返回特定IP来实现的。 此未批准列表将包含专门负责投放广告内容的站点的域名,因此我们不会错过太多。

We will setup a secondary HTTP server on the router to serve a transparent one pixel image, as the answer for any URL request. In conjunction with the DNS “wrong” resolve, this will cause the network clients to request the content from our internal pixel-server and get a blank image in response.

我们将在路由器上设置辅助HTTP服务器,以提供透明的一个像素图像,作为任何URL请求的答案。 结合DNS“错误”解决,这将导致网络客户端从我们的内部像素服务器请求内容,并获得空白图像作为响应。

To generate the unapproved list, we will create one personal list in conjunction to two dynamically downloaded lists. the dynamic lists are the MVPS host file and the Yoyo domain list, together they hold a very extensive list of advertisement sites. By leveraging these lists, we are left with the responsibility of just adding the delta of sites that are not already in one of them, in our personal list.

为了生成未批准的列表,我们将创建一个个人列表以及两个动态下载的列表。 动态列表是MVPS主机文件和Yoyo域列表 ,它们一起包含非常广泛的广告站点列表。 通过利用这些列表,我们有责任在我们的个人列表中仅添加其中一个站点中尚未存在的站点增量。

We will also setup a “whitelist” for domains we don’t want to be blocked for any reason.

我们还将为不希望由于任何原因被阻止的域设置一个“白名单”。

先决条件和假设 (Prerequisites and assumptions)

  • Patience young one, this is a long read.

    耐心的年轻人,这是一本长篇小说。
  • This procedure was created and tested on DD-WRT (v24pre-sp2 10/12/10 mini r15437), as such you should already have this version or later installed on your router to use it. More information is over on the DD-WRT site.

    此过程已在DD-WRT(v24pre-sp2 10/12/10 mini r15437 )上创建并测试,因此您应该已经在路由器上安装了此版本或更高版本才能使用它。 有关详细信息,请访问DD-WRT网站

  • For ease of explanations sake, it is assumed the router has been restored to it’s “factory defaults” or that the settings used have not changed from their “out of the box” presets since then.

    为了便于说明起见,假定路由器已恢复为“出厂默认设置”,或者从那时起所使用的设置未更改其“出厂设置”的预设。
  • The client computer is using the router as the DNS server (this is the default).

    客户端计算机将路由器用作DNS服务器(这是默认设置)。
  • Space for JFFS (when in doubt, I recommend using the mini version of DD-WRT).

    JFFS的空间(如有疑问,建议使用DD-WRT的迷你版)。

  • It is assumed that your network is *already set and that it’s a class C (one that has a subnet of 255.255.255.0) as the last IP on that class C network (x.y.z.254)  will be assigned for the pixel-server program.

    假定您的网络已经设置*并且是C类(子网为255.255.255.0),因为该C类网络(xyz 254 )上的最后一个IP将被分配给像素服务器程序。

  • The willingness to install winSCP.

    愿意安装winSCP

*The script will not be able to adjust the block lists after the first run until the next refresh cycle (3 days).

*脚本在第一次运行后将无法调整阻止列表,直到下一个刷新周期(3天)。

学分 (Credits)

Update: Special thanks to “mstombs” for the great piece of  C code without his work all this wouldn’t be possible, “Oki” for compiling the Atheros compatible version and quote ;-) and “Nate” for helping with the QA-ing.

更新 :特别感谢“ mstombs”提供了大量的C代码,而没有他的全部工作,这一切都是不可能的;“ Oki”是用于编译与Atheros兼容的版本并引用;-);“ Nate”是用于帮助QA- ing。

While there was a lot of work to perfect this procedure on my end, the inspiration for it was ignited by the guys over at the DD-WRT forum and some of the foundations of this guide can be found at “ad-blocking with DD-WRT revisited (simple)”, “pixelserv without Perl, without any jffs/cifs/usb free“ and “Flexion.Org Wiki on DNSmasq“ as well as others.

尽管我有很多工作可以完善此程序,但在DD-WRT论坛上,正是这些人激发了它的灵感,并且该指南的某些基础可以在“ 使用DD-重新审视了WRT(简单) ,“ 没有Perl,没有任何jffs / cifs / usb free的 pixelserv ”,“ DNSmasq上的Flexion.Org Wiki ”以及其他内容。

让我们** (Lets get cracking)

Enable SSH for SCP access

启用S​​SH进行SCP访问

By enabling SSH, we in turn give ourselves the ability to connect to the router using the SCP protocol. with that enabled, we can then use the winSCP program to visually navigate the folder structure of the router (as we will see later).

通过启用SSH,我们又使自己能够使用SCP协议连接到路由器。 启用该功能后,我们便可以使用winSCP程序直观地浏览路由器的文件夹结构(我们将在后面看到)。

To do this, using the webGUI, go to the “Services” tab. Find the “Secure shell” section and click the “Enable” radio button for the SSHd setting.

为此,请使用webGUI转到“服务”选项卡。 找到“安全外壳”部分,然后单击“启用”单选按钮以进行SSHd设置。

enable ssh

Once that’s done, the webGUI should look as below and you can click on “Save” (don’t apply yet).

完成后,webGUI应如下所示,您可以单击“保存”( 尚不适用)。

enable ssh1

Enable JFFS

启用JFFS

In order to make this setup in a way that would be stable, reproducible and *be a “good internet citizen”, we will use JFFS to store as much of the configurations as possible. There are other ways to do this without enabling JFFS, if you cant due to space limitations, but they are not covered here.

为了使该设置稳定 ,可重复并且成为“良好的互联网公民”,我们将使用JFFS来存储尽可能多的配置。 如果由于空间限制您不能启用JFFS,还有其他方法可以不启用JFFS,但是这里不介绍它们。

*other methods have your router download the pixel-server executable and dynamic lists every time the script is run. as this puts a strain on the servers holding the lists and executable and this costs money to someone, this method tries to avoid it if possible.

*其他方法会让您的路由器在每次运行脚本时下载像素服务器可执行文件和动态列表。 由于这会给保存列表和可执行文件的服务器造成压力,并给某人造成金钱损失,因此,这种方法会尽可能避免这种情况。

If you don’t already know what is JFFS, this explanation, taken from DD-WRT’s wiki entry about JFFS should clear things up:

如果您还不知道什么是JFFS,那么从DD-WRT的有关 JFFS 的Wiki条目中获得的解释应该可以使您清楚:

The Journaling Flash File System (JFFS) allows you to have a writable Linux File System on a DD-WRT enabled router. It is used to store user programs like Ipkg and data into otherwise inaccessible flash memory. This allows you to save custom configuration files, host custom Web pages stored on the router and many other things not capable without JFFS.

The Journaling Flash File System (JFFS) allows you to have a writable Linux File System on a DD-WRT enabled router. It is used to store user programs like Ipkg and data into otherwise inaccessible flash memory. This allows you to save custom configuration files, host custom Web pages stored on the router and many other things not capable without JFFS.

To enable JFFS on your router, go to the “Administration” tab and find the JFFS section. the picture below shows where you would find this section within the “Administration” tab.

要在路由器上启用JFFS,请转到“管理”标签,然后找到“ JFFS”部分。 下图显示了在“管理”选项卡中此部分的位置。

enable ssh2

In the JFFS2 Support section, click the “Enable” radio buttons for the “JFFS2” and (when it appears) the “Clean JFFS2” settings. Once selected, click on “Save”.

在“ JFFS2支持”部分中,单击“ JFFS2”和“清洁JFFS2”设置的“启用”单选按钮。 选择后,单击“保存”。

enable ssh3

When the settings have been saved, still on the “Administration” tab, reboot the router by using the “Reboot Router” button. This will apply the settings and perform the needed “format” of the JFFS “partition”.

保存设置后,仍在“管理”选项卡上,使用“重新启动路由器”按钮重新启动路由器。 这将应用设置并执行JFFS“分区”的所需“格式”。

reboot

When the webGUI comes back from the reboot to the “Administration” tab, wait for an additional half a minute and refresh the page.

当webGUI从重新引导返回到“管理”选项卡时,请再等待半分钟并刷新页面。

enable ssh5

If successful, you should see that your JFFS mount has some free space as in the picture.

如果成功,您应该看到JFFS挂载具有一些可用空间,如图所示。

Pixel server setup

像素服务器设置

Download and extract the anti ads pack for dd-wrt zip archive which contains the pixel-server executable (we are not taking credit, only avoiding “hot linking”), the ad-blocking script (written by yours truly) and the personal-domain-list created by “Mithridates Vii Eupator” and I.

下载并解压缩dd-wrt ​​zip存档反广告包,其中包含像素服务器可执行文件(我们不会功劳,只是避免“热链接”),广告屏蔽脚本(由您本人真正编写)和个人广告- “ Mithridates Vii Eupator”和I创建的域列表。

It is time to get the files into the JFFS mount on the router. to do this, install winSCP (it is a “next –> next –> finish” type of a setup) and open it.

是时候将文件放入路由器上的JFFS挂载了。 为此,请安装winSCP (它是安装程序的“下一个–>下一个–>完成”类型)并打开它。

In the main window, fill in the information like this:

在主窗口中,填写以下信息:

Host name: your router’s IP (default is 192.168.1.1)

主机名:路由器的IP(默认为192.168.1.1)

Port number: leave unchanged at 22

端口号:保持不变为22

User name: root (even if you changed the username for the webGUI, the SSH user will always be *root* )

用户名: root (即使您更改了webGUI的用户名, SSH用户也将始终是* root * )

Private key file: leave blank (this is only necessary when you create a key-pair based authentication which we haven’t)

私钥文件:留空(仅在创建基于**对的身份验证时才需要,而我们没有)

File protocol: SCP

文件协议:SCP

winscp1

We also need to disable “Lookup user group” as shown below (thanks mstombs for pointing this out) because winSCP is expecting a full blown Linux on the other side which DD-WRT’s developers, despite all of there excellent work, were unable to provide (mainly because there simply isn’t enough space). If you leave this checked, you will encounter scary messages when you connect and save edited files.

我们还需要如下所示禁用“ Lookup user group”(感谢mstombs指出这一点),因为winSCP期望DD-WRT的开发人员在另一端拥有一个成熟Linux,尽管他们在这方面做得很出色,但却无法提供(主要是因为根本没有足够的空间)。 如果不选中此选项,则在连接并保存编辑的文件时会遇到可怕的消息

Select Advance, and then uncheck “Lookup user groups”.

选择高级,然后取消选中“查找用户组”。

While it is optional, you may opt to save the settings now for later use. If you do choose to save the settings which is recommended, it is also recommended (despite the outright cries from the “security paranoid” asylum that we are desecrating the very existence of SSH) that you save the password.

虽然它是可选的,但您可以选择立即保存设置以供以后使用。 如果您确实选择保存建议的设置,那么也建议您保存密码(尽管“安全偏执狂”庇护的呼声很高,因为我们认为SSH确实存在)。

winscp2

Then your main window will look like in the picture, and all you’ll have to do to connect to the router is double click the entry.

然后您的主窗口将如图所示,并且只需双击该条目即可连接到路由器。

winscp3

As this is the first time you will be connecting to the router, winSCP will ask if you are willing to trust the fingerprint of the other side. Click “Yes” to continue.

由于这是您第一次连接到路由器,因此winSCP会询问您是否愿意信任另一侧的指纹。 单击“是”继续。

winscp4

DD-WRT’s developers have implemented a Banner welcome message with some info about the firmware you have installed. once red, click on the “Never show this banner again” checkbox and “Continue”.

DD-WRT的开发人员已实施横幅欢迎消息,其中包含有关已安装固件的一些信息。 一旦变成红色,请单击“不再显示此横幅”复选框,然后单击“继续”。

winscp5

Once connected, navigate your way to the top level folder (A.K.A. root “/”) and then go back down to “/jffs” as that is the only permanently writable place on the router’s filesystem (“/tmp” doesn’t survive reboots and the rest are read-only).

连接后,导航至顶级文件夹(AKA根目录“ /”),然后返回至“ / jffs”,因为这是路由器文件系统上唯一可永久写入的位置(“ / tmp”在重启后无法生存)其余均为只读)。

winscp7

Create a new folder, by hitting F7 or right clicking a blank spot, hover over “New” and click “Directory”.

按下F7或右键单击空白处,创建一个新文件夹,将鼠标悬停在“新建”上,然后单击“目录”。

winscp8

Name the new directory “dns”. we create this directory in order to keep things in the jffs directory organized for future use and because we are mostly changing how the DNS service works.

将新目录命名为“ dns”。 我们创建此目录是为了使jffs目录中的内容井井有条,以备将来使用,因为我们主要是在更改DNS服务的工作方式。

Copy the “pixelserv” and “disable-adds.sh” files from the anti-ads-pack-for-dd-wrt zip archive, by selecting them (use the “insert” key), hitting “F5” and then “Copy”.

从anti-ads-pack-for-dd-wrt ​​zip存档中复制“ pixelserv”和“ disable-adds.sh”文件,方法是选择它们(使用“插入”键),依次单击“ F5”和“复制” ”。

winscp9

Note: If your router is Atheros based (you can check this on the DD-WRT wiki) you will need to use the pixelserv_AR71xx provided by Oki and included in the pack and rename it to “pixelserv” before continuing.

注意:如果您的路由器基于Atheros(您可以在DD-WRT Wiki上进行检查),则需要使用Oki提供并包含在包装中的pixelserv_AR71xx,并将其重命名为“ pixelserv”,然后再继续。

Once the files are on the router, we need to make them executable by selecting them (again use “insert”) right click then “properties”.

一旦文件放在路由器上,我们需要通过选择它们(再次使用“插入”),然后单击“属性”使它们可执行。

winscp10a

On the properties window click on the “X” for the “Owner” row. that will give the files execution permissions.

在属性窗口中,单击“所有者”行的“ X”。 这将赋予文件执行权限。

Router settings

路由器设定

winscp11

Now that the stage is set, we can tell the router to run the ad-blocking script at startup. To do this, in the webGUI go to the “Administration” tab and then the “Commands” tab.

现在已经设置好阶段,我们可以告诉路由器在启动时运行广告拦截脚本。 为此,在webGUI中转到“管理”选项卡,然后转到“命令”选项卡。

In the “Commands” text box write the location of the script as “/jffs/dns/disable_adds.sh”, as in the picture and then click on “Save Startup”.

如图所示,在“命令”文本框中,将脚本的位置写为“ /jffs/dns/disable_adds.sh”,然后单击“保存启动”。

winscp12

If successful, you should see the script has become part of the router’s startup as in the picture above.

如果成功,您应该看到脚本已成为路由器启动的一部分,如上图所示。

Setting up the Personal blocked domains list (Optional)

设置“个人阻止域”列表(可选)

This list enables you to add domains to the unapproved lists, if you find that the two dynamic lists don’t catch something. To do this, there are two options, and they work in conjunction so you may use both according to what is more convenient for you.

如果发现两个动态列表没有发现任何问题,则可以使用此列表将域添加到未批准列表中。 为此,有两个选项,它们可以协同工作,因此您可以根据更方便的方式使用这两个选项。

Note: The syntax is important, As we are actually creating configuration directives that the DNSMasq daemon (the process that is responsible for DNS-name to IP translations) will use directly. As such, incorrect syntax here will cause the service to crash and leave the router unable to resolve IP addresses for domain names (you have been admonished).

注意 : 语法很重要 ,因为实际上我们正在创建DNSMasq守护程序(负责将DNS名称转换为IP的过程)将直接使用的配置指令。 因此,此处不正确的语法将导致服务崩溃,并使路由器无法解析域名的IP地址(您已被告诫)。

In order to find the offending domain names to block you may want to use our “Find the Secret Messages in Web Site Headers” guide as a primer. The steps to finding the names of the advertisement domains are practically the same, only that in this case you are looking for an address instead of a message.

为了找到要阻止的有害域名,您可能需要使用我们的“ 在网站标题中查找秘密消息 ”指南作为入门。 查找广告域名称的步骤实际上是相同的,只是在这种情况下,您要查找地址而不是消息。

The first and admittedly more accessible way is to put the list into the “DNSMasq” configuration box in the wegGUI. This is because to add to this list one can simply access the webGUI instead of having to go “under the hood” to make changes.

第一种也是公认的更易访问的方法是将列表放入wegGUI的“ DNSMasq”配置框中。 这是因为要将其添加到此列表中,就可以简单地访问webGUI,而不必“深入了解”进行更改。

Go to the “Services” tab, find the “DNSMasq” section and there find the “Additional DNSMasq Options” text-box.

转到“服务”选项卡,找到“ DNSMasq”部分,然后找到“其他DNSMasq选项”文本框。

In this text-box enter the lists of domains that you want to be blocked with the syntax “address=/domain-name-to-block/pixel-server-ip” as shown in the picture below:

在此文本框中,输入要使用语法“地址= /域名到阻止/像素服务器-ip”被阻止的域的列表,如下图所示:

dnsmasq03

Where in this example the “192.168.1.254” is the IP that’s generated for the pixel-server based on the “network address” of your LAN. If your network address is something other then 192.168.1.x you will have to adjust the address for the pixel-server accordingly.

在此示例中,“ 192.168.1.254”是根据您局域网的“网络地址”为像素服务器生成的IP。 如果您的网络地址不是192.168.1.x,则必须相应调整像素服务器的地址。

When finished, click on “Save” at the bottom of the page (don’t apply yet).

完成后,单击页面底部的“保存”(尚不适用)。

The second option is to compound the list of domains that you want to block, to the “personal-ads-list.conf” file that myself and and “Mithridates Vii Eupator” have assembled. This file is part of the zip-archive you downloaded earlier and it’s a great start for both methods.

第二个选项是将您要阻止的域列表复合到本人和“ Mithridates Vii Eupator”已组装的“ personal-ads-list.conf”文件中。 该文件是您先前下载的zip归档文件的一部分,并且是这两种方法的良好起点。

In order to use it,  if necessary, use your favorite text editor to adjust the IP of the pixel-server (the same constraints as above apply here). Then simply copy it to the “/jffs/dns” directory as you have the other files. Once it’s in there you can use winSCP to edit it and add domains.

为了使用它,如有必要,请使用您喜欢的文本编辑器来调整像素服务器的IP(此处适用与上述相同的约束)。 然后,只要拥有其他文件,只需将其复制到“ / jffs / dns”目录即可。 进入该目录后,您可以使用winSCP对其进行编辑并添加域。

Setting up the whitelist

设置白名单

This is the list of domains that will be omitted from the dynamic “hosts” and “domains” lists.

这是动态“主机”和“域”列表中将省略的域列表。

This is necessary because simply blocking some domains causes sites using them to malfunction. the most noteworthy example is “google-analytics.com”.

这是必要的,因为仅阻止某些域会使使用它们的站点出现故障。 最值得注意的例子是“ google-analytics.com”。

If we block it’s domain, it will not change the fact that sites that use it, have your browser download a JavaScript that runs on events such as leaving a page. This means that for such a site your browser will try to “call home” by contacting the google domain, will not understand the reply and you will have to wait until the script times out to continue to the next page. That’s hardly a pleasant surfing experience and that is why any domain containing “google-analytics” and “googleadservices” is *hardcodedly exempt from filtering.

如果我们阻止它的域,那么它不会改变使用它的网站,让您的浏览器下载一个在事件(例如离开页面)上运行JavaScript的事实。 这意味着对于这样的网站,您的浏览器将尝试通过与google域联系来“致电给我”,将无法理解回复,因此您必须等到脚本超时才能继续下一页。 这几乎不是一种令人愉快的冲浪体验,因此,所有包含“ google-analytics”和“ googleadservices”的域都被*硬编码免于过滤。

This list is created for you with the above mention domains, when the script is run for the first time, under the “/jffs/dns” directory.

首次运行脚本时,会在“ / jffs / dns”目录下为您创建具有上述域的列表。

winscp13

To use the whitelist, open the file with winSCP and **perpend to the list the domains you want excluded, while being careful to not leave any blank lines (leaving a blank line will delete all the domains from all of the lists).

要使用白名单,请打开文件,将winSCP和** 附加到要排除的域列表中,同时注意不要留空行(留空行将删除所有列表中的所有域)。

winscp14a

*While the script creates the whitelist with the domains within it on the first run, it does NOT insists on their presents for future runs. so if you feel that google should be blocked despite the aforementioned problems, you can remove the domains from the whitelist.

*虽然脚本在第一次运行时创建了包含域的白名单,但它并没有坚持要求其将来的运行。 因此,如果您认为尽管有上述问题,谷歌仍应被阻止,则可以从白名单中删除域。

**You must enter the new domains you want at the start of the list. This is because of a bug with how bash interprets new lines… sorry i don’t have a work around for that yet.

**您必须在列表的开头输入所需的新域。 这是因为bash解释新行的方式有一个错误……抱歉,我还没有解决办法。

Execution

执行

This is it, it is finally time to invoke the script and see the results by simply restarting the router.

就是这样,终于可以通过简单地重启路由器来调用脚本并查看结果了。

To do this from the webGUI,Under the “Administration” tab go back to “Management” , at the bottom of the page click on “Reboot router” and wait for the router to come back up.

要从webGUI中执行此操作,请在“管理”选项卡下返回“管理”,在页面底部单击“重新启动路由器”,然后等待路由器重新启动。

It may take a couple of minutes for the script to perform its duties for the first time.

脚本第一次执行可能需要花费几分钟。

On WRT54Gx type of routers, you will know when the script has finished executing because it will blink the Cisco orange LED on the front of the router (other routers should have a similar “tell tail” sign).

在WRT54Gx类型的路由器上,您将知道脚本何时完成执行,因为它将使 路由器正面的Cisco橙色LED闪烁 (其他路由器也应具有类似的“ tell tail”符号)。

Update: This part was *removed after it was discovered to be a non-hardware agnostic feature.

更新:*这部分被发现是非硬件不可知的功能,然后被删除。

As we are trying to see the absence of elements on the web, I recommend simply surfing to a couple of sites to see the affect.

当我们试图看到网络上没有元素时,我建议仅浏览几个站点以查看其影响。

However if you want to make sure the procedure was successful the first debug step in the troubleshooting section is a great place to start with.

但是,如果要确保过程成功,那么在故障排除部分中的第一步调试是一个很好的起点。

*It’s actually commented out so you can restore it if your sure it will not cause problems on your setup.

*它实际上已被注释掉,因此,如果确定它不会对您的设置造成问题,则可以将其还原。

请享用!
微笑
(Enjoy! )



故障排除 (Troubleshooting)

If you run into problems there are a couple of things that you can do to check what went wrong.

如果您遇到问题,可以执行以下几项操作来检查出了什么问题。

  1. Test that the advertisement domain is resolved to the pixelserv IP.

    测试广告域是否解析为pixelserv IP。

    You can do this by issuing the nslookup command against the “offending” domain. For example the “ad-emea.dubleclick.com” is part of the blocked hosts from the personal list. By issuing “nslookup ad-emea.dubleclick.com” in a command prompt, the result should look like:

    您可以通过对“有问题的”域发出nslookup命令来做到这一点。 例如,“ ad-emea.dubleclick.com”是个人列表中被阻止主机的一部分。 通过在命令提示符下发出“ nslookup ad-emea.dubleclick.com”,结果应类似于:

    nslookup01a

    Where a normal unblocked answer would look like:

    正常的无障碍答案如下所示:

    nslookup02

  2. Do over.

    过来

    To make sure that nothing with your router’s setup is clashing with the ad-block configuration, restore the router to “Factory Defaults” and try again.  Once your successful add your custom changes in the hope that they don’t clash again.

    为确保路由器的设置与ad-block配置没有冲突,请将路由器恢复为“出厂默认值”,然后重试。 成功添加您的自定义更改后,希望它们不会再发生冲突。

  3. Make sure your client is using the router as the DNS.

    确保您的客户端使用路由器作为DNS。

    Especially when using a v*n or a network that is more complex then the normal router to computer setup, it is possible that your client computer is simply not using the router as its DNS. It is very easy to see in the command above what is the DNS server the client is using, If the IP is not the same as the router, you have found the problem.

    尤其是当使用v*n或比通常的路由器到计算机设置更为复杂的网络时,您的客户端计算机可能根本就没有将路由器用作其DNS。 在上面的命令中很容易看到客户端使用的是什么DNS服务器。如果IP与路由器不相同,则说明您已找到问题。

  4. Clear your personal machines DNS cache.

    清除您的个人计算机DNS缓存。

    This is because otherwise you may still see the ads to the site your testing with, simply because your computer already knows how to get the advertisement content on its own without consulting the DNS for it. On windows this would be “ipconfig /flushdns”.

    这是因为否则,您可能仍会在测试所用的网站上看到广告,这仅仅是因为您的计算机已经知道如何自行获取广告内容而无需咨询DNS。 在Windows上,这将是“ ipconfig / flushdns”。

  5. Close the browser.

    关闭浏览器。

    Sometimes the browser holds the information cached, so clearing the DNS cache as shown above doesn’t help.

    有时浏览器会保存已缓存的信息,因此如上所示清除DNS缓存无济于事。

  6. When in doubt reboot.

    如有疑问,请重新启动。

    Sometimes the caches can persist and the best way to get rid of them is to reboot. Start with the router and if the problem persists, the client computer.

    有时,缓存可以保留,摆脱缓存的最佳方法是重新启动。 从路由器启动,如果问题仍然存在,则为客户端计算机。

  7. Use syslog.

    使用syslog

    You can activate the router’s syslog daemon and then look at the messages to see if the script encounters any problems, by examining its messages. Also the script adds some command aliases to make debugging easier.

    您可以通过检查路由器的消息来**路由器的syslog守护程序,然后查看消息以查看脚本是否遇到任何问题。 该脚本还添加了一些命令别名,以使调试更加容易。

    To do this go to the “Services” tab and enable the syslog daemon as in the picture below:

    为此,请转到“服务”选项卡并启用syslog守护程序,如下图所示:

    syslog-enable
    Note: The “Remote Server” is used when you have a listening syslog server on another machine (like with kiwi) if you don’t have one, simply leave it blank.

    注意:如果您在另一台计算机上拥有监听syslog服务器(例如 kiwi ),则 使用“远程服务器”( 如果没有),只需将其留空即可。

    Once enabled, you can see the debug messages by looking at the

    启用后,您可以通过查看

    /var/logs/messages file in a terminal.

    终端中的 / var / logs / messages文件。

    *To see ALL messages from boot-up you can use “more /var/log/messages”.

    *要查看启动中的所有消息,您可以使用“更多/ var / log / messages”。

    *To see just the messages from the script in the log use the “clog” alias.

    *要仅在日志中查看脚本中的消息,请使用“ clog”别名。

    *To see the messages as they come in, in real time, use ”tail -f /var/log/messages” or by its alias “tlog”.

    *要实时查看消息,请使用“ tail -f / var / log / messages”或其别名“ tlog”。

  8. Understand the script.

    了解脚本。

    Even though I have made

    即使我做了

    this YouTube video for an older version of this guide and the script,  it still holds a lot of truths and explanations that are applicable to how the new and improved version works.

    该YouTube视频 (本指南的较旧版本和脚本)仍包含许多真理和解释,适用于新版本和改进版本的工作方式。



愿the神们对你有利
微笑
(May the router gods be in your favor )

翻译自: https://www.howtogeek.com/51477/how-to-remove-advertisements-with-pixelserv-on-dd-wrt/

dd-wrt 去广告