Asuswrt Merlin AdGuard Home (分享器擋廣告)

文章目錄

注意

系統刷機有一定的風險, 可能導致手機無法開機和失去保固, 資料還會被清空, 執行前請先三思!!!

Asuswrt-Merlin 是甚麼

Asuswrt-Merlin 是個 Asus router 的 3rd party fireware, 提供了不少增強的功能, 也有很多 addon 可以使用. 刷機的方法可參考官方文件: https://github.com/RMerl/asuswrt-merlin.ng/wiki/Installation (不過寫的滿簡單的, 建議 google 一下其他人寫的介紹)

Asuswrt-Merlin 上的擋廣告方案

要在 Asuswrt-Merlin 上面擋廣告, 主要應該是這兩個 addon:

  1. Diversion: 這個好多年了, 可參考我之前寫的心得 https://dennys.github.io/tw/doc/router/asuswrt-merlin-diversion/
  2. Pi-hole: 這個我沒試過, google 了一下, 網路上有不少文件可參考.
  3. AdGuard Home: 他和 Diversion 類似, 也是透過 DNS 的方法來擋掉廣告, 這次我要試的是這個.

AdGuard Home 是甚麼

是個可安裝在 Asuswrt Merlin 上的 AD block 軟體, 他的原理是直接在 Hub 上面裝一個 DNS server, 然後當你的 client 要查某一個 domain 的時候, 他如果發現這個 domain 在他的黑名單裡面, 就把他擋掉.

安裝步驟

AdGuard Home 本身就支援 Arm-based Linux, 所以可以直接下載他的執行檔來使用. 不過現在有人做了一個 Asuswrt-Merlin-AdGuardHome-Installer (AMAGHI), 可以讓他的安裝過程簡化許多, 就像其他 Addon 一樣.

  1. 這邊假設 Asuswrt-Merlin 已經刷機, 然後 amtm 和 jffs 都已經弄好了.

  2. 執行 amtm, 然後執行 ag, 他就會進入安裝 AdGuard 的畫面, 然後詢問你是否確定要繼續, 輸入 1 就會繼續了.

     1Enter option  ag
     2_____________________________________________
     3
     4This installs AdGuardHome - Asuswrt-Merlin-AdGuardHome-Installer
     5on your router.
     6
     7Author: SomeWhereOverTheRainBow
     8https://www.snbforums.com/threads/new-release-asuswrt-merlin-adguardhome-installer.76506/#post-733310
     9_____________________________________________
    10
    11Continue? [1=Yes e=Exit] 1
    
  3. 接這就照著系統的問題回答就好, 基本上就是 next -> next. 安裝完成後, AdGuard Home 就會執行起來.

     1#################################################################################################################
     2# █████╗ ███████╗██╗   ██╗███████╗██╗    ██╗██████╗ ████████╗   ███╗   ███╗███████╗██████╗ ██╗     ██╗███╗   ██╗#
     3#██╔══██╗██╔════╝██║   ██║██╔════╝██║    ██║██╔══██╗╚══██╔══╝   ████╗ ████║██╔════╝██╔══██╗██║     ██║████╗  ██║#
     4#███████║███████╗██║   ██║███████╗██║ █╗ ██║██████╔╝   ██║█████╗██╔████╔██║█████╗  ██████╔╝██║     ██║██╔██╗ ██║#
     5#██╔══██║╚════██║██║   ██║╚════██║██║███╗██║██╔══██╗   ██║╚════╝██║╚██╔╝██║██╔══╝  ██╔══██╗██║     ██║██║╚██╗██║#
     6#██║  ██║███████║╚██████╔╝███████║╚███╔███╔╝██║  ██║   ██║      ██║ ╚═╝ ██║███████╗██║  ██║███████╗██║██║ ╚████║#
     7#╚═╝  ╚═╝╚══════╝ ╚═════╝ ╚══════╝ ╚══╝╚══╝ ╚═╝  ╚═╝   ╚═╝      ╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚══════╝╚═╝╚═╝  ╚═══╝#
     8# █████╗ ██████╗  ██████╗ ██╗   ██╗ █████╗ ██████╗ ██████╗ ██╗  ██╗ ██████╗ ███╗   ███╗███████╗                 #
     9#██╔══██╗██╔══██╗██╔════╝ ██║   ██║██╔══██╗██╔══██╗██╔══██╗██║  ██║██╔═══██╗████╗ ████║██╔════╝                 #
    10#███████║██║  ██║██║  ███╗██║   ██║███████║██████╔╝██║  ██║███████║██║   ██║██╔████╔██║█████╗                   #
    11#██╔══██║██║  ██║██║   ██║██║   ██║██╔══██║██╔══██╗██║  ██║██╔══██║██║   ██║██║╚██╔╝██║██╔══╝                   #
    12#██║  ██║██████╔╝╚██████╔╝╚██████╔╝██║  ██║██║  ██║██████╔╝██║  ██║╚██████╔╝██║ ╚═╝ ██║███████╗                 #
    13#╚═╝  ╚═╝╚═════╝  ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═════╝ ╚═╝  ╚═╝ ╚═════╝ ╚═╝     ╚═╝╚══════╝                 #
    14#██╗███╗   ██╗███████╗████████╗ █████╗ ██╗     ██╗     ███████╗██████╗     Author:                              #
    15#██║████╗  ██║██╔════╝╚══██╔══╝██╔══██╗██║     ██║     ██╔════╝██╔══██╗          SomeWhereOverTheRainBow        #
    16#██║██╔██╗ ██║███████╗   ██║   ███████║██║     ██║     █████╗  ██████╔╝    Contributors:                        #
    17#██║██║╚██╗██║╚════██║   ██║   ██╔══██║██║     ██║     ██╔══╝  ██╔══██╗          JackYaz,gspannu,thelonelycoder #
    18#██║██║ ╚████║███████║   ██║   ██║  ██║███████╗███████╗███████╗██║  ██║    v1.5.8                               #
    19#╚═╝╚═╝  ╚═══╝╚══════╝   ╚═╝   ╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝╚═╝  ╚═╝                                         #
    20#################################################################################################################
    21Info:  Detected RT-AC66U_B1 router.
    22Info:  Detected Linux platform.
    23Info:  Detected ARMv7 architecture.
    24Info:  JFFS custom scripts and configs are already enabled.
    25Info:  DNS Environment is Ready.
    26Info:  Choose what you want to do:
    271) Install/Update AdGuardHome
    282) Uninstall
    29q) Quit
    30=>  Please enter the number that designates your selection:, [1-2/q]: 1
    31Info:  This operation will install AdGuardHome and related files (<6MB)
    32Info:  to ENTWARE, no other data will be changed.
    33Info:  Also some start scripts will be installed/modified as required.
    34=>  Do you want to install AdGuardHome to ENTWARE? [y/n]: y
    35Info:  Downloading installer
    36Info:  Choose which build of AdGuardHome to install:
    371) Release
    382) Beta
    393) Edge
    40=>  Select your mode, [1-3]: 1
    41Info:  Downloading AdGuardHome_linux_armv5.tar.gz
    42Info:  Downloading AdGuardHome.sh
    43Info:  Downloading S99AdGuardHome
    44Info:  Downloading rc.func.AdGuardHome
    45grep: /jffs/scripts/init-start: No such file or directory
    46grep: /jffs/scripts/init-start: No such file or directory
    47Info:  Creating init-start file
    48Info:  Configure init-start file
    49Info:  Configure services-stop file
    50Info:  Configure dnsmasq.postconf file
    51Info:  Configure service-event-end file
    52Info:  Before setting up AdGuardHome, please choose your right timezone!
    53Info:  Downloading tzdata-2021e-1-arm.pkg.tar.bz2
    54Info:  Available timezones/locations:
    55
    56... (這邊太多我就不貼上來了)
    57
    58=>  Select your timezone/location, [1-595]: 314
    59Info:  Taipei selected
    60Info:  Configuring AdGuardHome...
    61=>  Do you want to redirect all DNS resolutions on your network through to AdGuardHome? [y/n]: y
    62Info:  You can choose to keep any custom dnsfilter values by only redirect non-custom traffic or send all traffic through to AdGuardHome.
    63=>  Do you want to redirect only NON-CUSTOM DNS resolutions on your network through to AdGuardHome? [y/n]: y
    64Info:  DNSFilter is set to control DNS through to AdGuardHome, while leaving any Custom Rules and Values.
    65=>  Do you want to run AdGuardHome as a local caching DNS service which includes router traffic? [y/n]: y
    66Info:  Requesting entries for AdGuardHome initial configuration...
    67Info:  Set the Username and Password which will be encrypted to the yaml file.
    68=>  Please enter AdGuardHome username: admin
    69=>  Please enter AdGuardHome password:
    70=>  Please reenter AdGuardHome password:
    71
    72Info:  Set the DNS server(s) for initializing AdGuardHome
    73Info:  and router services (e.g. ntp) at boot
    74=>  Default is 9.9.9.9:  =>  2nd Default is 8.8.8.8:
    75Info:  Writing AdGuardHome configuration...
    76Info:  Checking AdGuardHome configuration...
    77Info:  Starting AdGuardHome...
    

特別注意

  1. 因為 AdGuard Home 是使用 DNS 來 block AD, 因此 WAN 的地方可以指定 DNS

  2. 但 LAN 的地方必須清空, client 的 DNS 必須是 192.168.1.1. 因為所有連到這台 router 的電腦或手機, 他們的 DNS server 都必須是 192.168.1.1, 這樣 Diversion 才會有作用.

  3. 在 Windows 可用 ipconfig /all 檢查 DNS 是否有設定正確

AdGuard Home 使用方法

  1. 連到 http://192.168.1.1:14711/ (假設你的分享器 IP 是 192.168.1.1), 使用安裝過程輸入的帳號密碼進去, 進去後就會看到預設的 dashboard.

  2. 實際去開一些會有廣告的網頁, 選擇回到 AdGuard 選擇查詢紀錄, 就可以看到實際上查了那些 domain, 那些被封鎖了.

  3. 對使用者來講, 效果和 Diversion 類似, 會看到如下畫面.

其他

如果你需要的是只針對某些 IP 擋掉某些服務 (e.g. YouTube), 可參考 Asuswrt Merlin AdGuard Home - 針對 IP 擋某些服務

Posts in this Series