Tag: hagezi

  • The fix that let phishing names through

    The fix that let phishing names through

    In English

    On a Saturday in October I fixed four broken entries in my router’s DNS allowlist. A little over two weeks later I found that the fixed entries let through names on the threat feed built to look like the sites I meant to allow: a payment site’s domain followed by .https. and an unrelated domain, or a shop’s name with a hyphen where the dot should be. My router’s own tester passed them.

    The same evening I had cut my blocklists from eighteen to ten; an LG TV list the next day made it eleven. Seven of them were covered by the rest of the set. One list I kept, Abuse.ch ThreatFox, stopped downloading when abuse.ch began to give out its host file only with a key. It downloads again since I put a free key in its address. And the ads inside YouTube and Instagram on my phone came through throughout, which no blocklist was going to change.

    I then rewrote the allowlist entries. This post is about both clean-ups: what OPNsense does with an allowlist entry, how to check yours, and what eighteen overlapping lists added up to. I did the work with Claude over two sessions, one for each clean-up; the ThreatFox key went in during a third. It read the router through my browser; every change on the router was mine to approve. I approved the bare-name fix, so approval was no safeguard against that mistake.

    New to the command line? How to read the boxes

    PS> means: type this in PowerShell on Windows (Start menu → type powershell → Enter). $ means: type this in a terminal on Linux or a Mac, or on the Pi after you have logged in with ssh. Do not type the $ or PS> itself.

    Each line that starts with $ or PS> is one command. Click that $ to copy just that line, paste it, press Enter, and wait for it to finish before the next. A box with a Copy button at the top holds one command (or one file), so copy it whole. A dashed box shows what you should see back; you do not type it.

    The allowlist

    My blocklist policy’s allowlist had 26 entries. On the day of the first clean-up four of them looked broken. Three had been pasted from the browser’s address bar as full addresses, in the form https://example.org/. The fourth had one space before the first letter of the name. I replaced all four with bare names such as example.in. I did not look at how the other 22 were written, and the router’s configuration history no longer goes back far enough to check. If they were bare names, as the router’s own Allow button writes them, the gap was there before my fix, and the fix extended it to the three entries that had matched nothing.

    The router’s log showed a fifth, an entry written as *.ntp.org, since removed. Each nightly update had logged “skip invalid whitelist exclude pattern” for it. A leading * is not valid in Python’s regular expressions, so the router dropped the entry every night and said so only in the log. The form that does what was meant is (.*\.)?ntp\.org\.?$.

    Later Claude read the code that applies the allowlist, in OPNsense 26.7. The leading space had done no harm: the code strips spaces from each entry. The bare names were the problem.

    OPNsense treats each entry as a regular expression, case-insensitive, and checks it against the start of the name a device asks for. Nothing ties it to the end of the name, and an unescaped dot matches any character. So a bare example.com allows example.com but not www.example.com. It also allows any name that begins with those characters, with any character in place of each dot: example.com.evil.net, example-com.evil.net, example.community.

    The threat feed carries names of exactly that shape: a well-known site’s name followed by .https. and an unrelated domain, or the site’s name with a hyphen for the dot. On the feed as I downloaded it for this check, seven of my 26 entries matched 43 such names; one entry matched 20. On my router’s tester, each of the five such names I tried passed, while the same name with www. in front, blocked by the same list entry, was blocked. A name I made up from an allowed site and a domain the threat feed blocks passed too. By the matching code, every bare entry allows any name that begins with it, whether or not a list blocks that name.

    OPNsense’s own Allow button, in Reporting → Unbound DNS, saves the bare name in the same way. Entries added from there behave the same way.

    The fix is to allow the exact name, anchored at both ends:

    ^www\.example\.com\.?$

    The backslashes make the dots literal, and $ ties the pattern to the end of the name. \.? allows the trailing dot the name carries on one of the two paths the code checks (see the deep dive). ^ repeats what the code already does, so leaving it out would work too; I keep it so the pattern reads the same anywhere. The steps to check and rewrite your own entries are in the deep dives under “How to check yours”.

    To allow a domain with all its subdomains, (.*\.)?example\.com\.?$ works, but it also allows hosts the list blocks under that domain on purpose. On one of my entries, Pro++ blocks five hosts under the domain, with names such as advertising and sponsored-ads, and does not block the domain itself or its www. name. A subdomain-wide allow would let them back.

    I ran OPNsense’s own parsing code and its matching call on a few names:

    Allowlist entry Name asked for Allowed?
    https://example.org/ example.org no
    example.in example.in yes
    example.in www.example.in no
    example.in example.in.example.net yes
    example.in example-info.de yes
    ^www\.example\.in\.?$ www.example.in yes
    ^www\.example\.in\.?$ advertising.example.in no
    ^www\.example\.in\.?$ www.example.in.example.net no

    I rewrote all 26 entries in that exact, anchored form and applied the change. Every name that had passed the tester was blocked afterwards. The one entry whose own name is on a list still passes, as intended. The exact names in the other 25 were not blocked by any list, so those entries did no work for the names they spell; their only effect was the prefix gap. I anchored them instead of deleting them, because a list can add a name later. If you have entries like that, deleting them is a fair choice.

    Deep dive: the code, and what my tests do and do not show

    The blocklist dialog has one “Allowlist Domains” field. Its help text says it takes domains, that regular expressions may be used, and that it applies only to matches in that policy. In 26.7:

    • src/opnsense/service/templates/OPNsense/Unbound/core/blocklists.conf writes the field as excludes.patterns, comma-separated.
    • src/opnsense/scripts/unbound/blocklists/default_bl.py splits that value on commas, calls strip() on each entry, drops any entry that does not compile as a regular expression (with the “skip invalid” log line), and joins the rest, with a built-in .*localhost$ entry, into one pattern with |.
    • src/opnsense/scripts/unbound-dnsbl/lib/__init__.py compiles the pattern case-insensitively.
    • src/opnsense/scripts/unbound-dnsbl/lib/dnsbl.py tests it with r.match(domain) after a blocklist hit. Python’s match is anchored at the start of the name, not at the end. The name is lower-cased and its trailing dot removed first.
    • When a CNAME target is blocked, the same function also tests the original name (r.match(orig)), so an allowlisted name still resolves through a blocked alias. That original name comes from Unbound with its trailing dot, www.example.com., and is not cleaned. A pattern ending in a bare $ fails there; \.?$ passes on both paths.
    • src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php, updateBlocklistAction, is what the Allow button in Reporting calls. It removes a trailing dot (rtrim($domain, '.')) and saves the name as it is, unescaped and unanchored.

    OPNsense’s manual describes an allowlist entry as excluding blocklist items that contain the pattern. The code is narrower at the start, since it matches only from the first character, and just as open at the end. Under either reading, anchoring the end is left to the person writing the entry. I compared the same five files in the newest 26.7 release and in the development branch: the allowlist code is unchanged.

    What the tests show: how the parser and the matching calls in the 26.7 source treat these entries, run outside a router, with the CNAME case simulated by adding the trailing dot; and, on my router, the tester’s verdict for each phishing name I tried, beside a control that differs only in not beginning with an allowlisted name, before and after the rewrite. The tester runs the same matching code on the lists the router has loaded, but only for a direct lookup, so it cannot show the CNAME path. The count of 43 names comes from the published lists, not from the router; all 43 are on TIF.

    How to check yours

    Four checks, all read-only until the last one:

    1. Read the resolver log for lists that failed to download and allowlist entries that were skipped.
    2. In the blocklist tester, try a name that should be blocked and one that should pass, to see that the lists are loaded.
    3. For each allowlist entry, test the entry followed by a domain your lists block, then the same name with www. in front. If the first passes and the second is blocked, the entry is open.
    4. Rewrite each open entry anchored, apply, and test again.

    The click-by-click steps for checks 1 to 3 and for the rewrite are in the two deep dives below. They start from the sign-in page and say what each step changes.

    Deep dive: step by step, checking your allowlist

    Before you start. You need a browser on a computer in your network, and the address and login of your router’s settings page. Steps 1 to 8 only read: they change nothing on the router, so you can stop at any point without undoing anything. Allow about ten minutes, plus about ten seconds for each test, because the tester loads the whole blocklist every time.

    1. Open a browser and enter the address you use to sign in to OPNsense. Sign in. You should see the Lobby page. If the page does not load, check that the computer is on your home network and that you used the same address as for any other change to the router.
    2. In the menu on the left, click Services, then Unbound DNS, then Log File. You should see a table with the columns Date, Severity, Process and Line. Above it are a search box, a severity box (set to Warning) and a time box (set to Last day).
    3. Click the search box, type blocklist and press Enter. Two kinds of line matter. “unable to download blocklist” means a list failed to load and contributes nothing. “skip invalid whitelist exclude pattern” means OPNsense dropped an allowlist entry. If the table is empty, nothing at Warning level was logged in the last day. Open the severity box and tick Informational as well to see the “blocklist loaded” lines; open the time box to look further back.
    4. In the same menu click Blocklists, then the Tester tab at the top of the page. You should see a Domain box, a Source box and a Test button. Leave Source empty; the test then runs as the router itself. Source takes a device’s address, and matters only if you have a policy that applies to certain devices.
    5. Type googleads.g.doubleclick.net in Domain and click Test. Wait about ten seconds. The result should be Block. Then test www.youtube.com; it should be Pass. If the first name passes, no list is loaded, or the name is on your own allowlist: go back to step 3 and read the errors, and if you have allowlisted that name, pick another name your lists block. The tester does not follow CNAMEs. A CNAME is a name that points to another name; the tester checks only the name you type.
    6. Click the Blocklists tab. At the right end of your policy’s row, click the pencil (Edit). A window titled Edit Blocklist opens. Allowlist Domains shows your entries, one tag each. Read them, then click Cancel. Nothing is saved.
    7. For each entry, test the entry followed by a domain your lists block. A name my lists block is googleads.g.doubleclick.net, the one from step 5. If yours do not block it, pick a name they do. So for an entry example.com, type example.com.googleads.g.doubleclick.net and click Test. Then test the same name with www. in front, www.example.com.googleads.g.doubleclick.net. If you load TIF, you can use a name from that list instead. An entry that already starts with ^ and ends with $ is anchored; skip it.
    8. Read the two results together. If the first passes and the second is blocked, the entry is open: it lets through every name that begins with it. Rewrite it anchored. A name that no list blocks passes whatever the allowlist says, so confirm in the tester that the name is blocked before you read a Pass as a fault.
    Deep dive: step by step, rewriting your allowlist

    Before you start. This changes your router’s filtering. Allow fifteen minutes. A mistake here most often shows as one allowed site failing to load. The rest of your internet should keep working. The router applies the change in about a minute (43 seconds on mine) and does not restart Unbound; the log shows the lists loading into the running process. Step 3 saves a copy of your old entries, and step 8 puts them back.

    1. Open the router’s settings page and sign in. Click Services, then Unbound DNS, then Blocklists.
    2. At the right end of your policy’s row, click the pencil (Edit). The Edit Blocklist window opens. Under Allowlist Domains, click Text, the small link under the box. The tags turn into a plain box with one entry per line, and a Back link appears. If you have more than one policy, each has its own allowlist; do this for each.
    3. Make the undo copy. Click inside the box, press Ctrl + A, then Ctrl + C. Open Notepad (Start menu, type notepad, press Enter), press Ctrl + V, and save the file as allowlist-before.txt in a folder you will find again. The file should hold one entry per line.
    4. Rewrite each line in the box. This is for plain names; an entry that is already a pattern, such as one containing (.*\.)?, stays as it is. Write the exact name your devices ask for. Put a \ before every dot, ^ at the start and \.?$ at the end:

      • example.in becomes ^example\.in\.?$
      • www.example.com becomes ^www\.example\.com\.?$

      Keep one entry per line, with no spaces and no commas. A name with www. and the same name without it are two names and need two lines. If you are not sure which one a device asks for, look in Reporting, Unbound DNS, or put both on the list.

    5. Click Back. The lines return as tags. Check that every tag has the new form. Click Save. The window closes.

    6. Click Apply, the orange button under the table. Wait about a minute.
    7. Check the result. Open Services, Unbound DNS, Log File, search for blocklist, and tick Informational in the severity box. You should see “updating blocklist”, then “blocklist loaded. length is” and a number, and no “skip invalid” line. Then repeat the tester steps from above: the lookalike names should now be Block. An entry that allows a name a list blocks (on mine, one for a Google ad host) should still be Pass.
    8. If a site stops loading after the change, undo it. Open allowlist-before.txt in Notepad, press Ctrl + A, then Ctrl + C. In the router, repeat steps 1 and 2, click inside the box, press Ctrl + A, then Ctrl + V to paste the old entries over the new ones, click Back, Save and Apply. A site that needs a name you did not list is blocked until you add that exact name.
    Deep dive: testing an allowlist change from a computer

    Before you start. This is for a Windows PC in the same network as the router. It asks the router’s DNS for one name and clears the PC’s own DNS cache; it changes nothing else. It takes two minutes. On a Mac or Linux the idea is the same (nslookup name router-address), but the cache-clearing command differs.

    1. Click the Start menu, type powershell and press Enter. A window opens with a prompt that starts with PS.
    2. Find the router’s address. Type this and press Enter:

      ipconfig

      Look for Default Gateway under the adapter you are using. That address is your router; the steps below call it <router-ip>. If your router sits behind another router, the default gateway may be that other device; use the address of the box that runs your DNS blocklists. If the line is empty, you are looking at an adapter that is not connected; scroll to the next one.

    3. After you click Apply on the router and wait a minute, clear the PC’s cache. Blocked answers carry a one-hour lifetime, so without this the PC may keep an old answer:

      ipconfig /flushdns
    4. Ask the router for the name, replacing <router-ip> with the address from step 2. The final dot after the name stops Windows trying its search suffixes first:

      nslookup www.example.com. <router-ip>

      A blocked name answers 0.0.0.0, or “Non-existent domain” if Return NXDOMAIN is ticked on the policy. A name that is allowed answers with its real address. The first two lines show your router; the rest is the answer.

    What eighteen lists added up to

    In the router’s resolver log, from its first entry until the first clean-up, every full nightly update was set to load the same eighteen lists (ThreatFox among them, see below):

    • Hagezi Normal, plus the Mini versions of Pro, Pro++ and Ultimate
    • Threat Intelligence Feeds (TIF) in all three sizes: full, Medium and Mini
    • Gambling in all three sizes
    • Fake, Pop-Up Ads, Badware Hoster, DynDNS, Anti Piracy and “Safesearch not supported”
    • OISD NSFW and Abuse.ch ThreatFox

    Hagezi, who maintains most of these, gives these rules for combining his lists in his FAQ:

    1. The five Multi lists — Light, Normal, Pro, Pro++ and Ultimate — build on each other. Each contains the one below it. You pick one.
    2. The size-optimised versions (Mini, and Medium for TIF and Gambling) are alternatives to their full list. They do not go on top of it.
    3. TIF is the exception. It covers malware, cryptojacking, scams, spam and phishing and is meant to run alongside whichever tier you pick.

    The Pro, Pro++, Ultimate and Gambling Minis keep only the names that also appear on lists of the most-visited domains. TIF Mini and Gambling Mini are cut from the Medium list. Hagezi describes the Minis as made for blockers on devices with limited memory.

    Deep dive: which tier for whom, and what Ultimate costs

    Hagezi’s FAQ matches the tiers to the person who will deal with breakage:

    Tier For Risk of breakage (Hagezi’s rating)
    Light a blocker that cannot handle big lists, or a setting where even Normal is too much minimal
    Normal unattended setups with no admin to unblock things low
    Pro someone can unblock things; his default recommendation, with TIF low to moderate
    Pro++ experienced users with an admin moderate
    Ultimate very experienced users with an admin available high

    Each tier also carries a share of the native tracker lists: the telemetry built into TVs, phones and operating systems. Pro++ blocks nearly all of it; Ultimate blocks all of it. The README lists what Ultimate costs: some Facebook and Messenger functions, WhatsApp extras such as avatars and video effects, Windows Spotlight and Xbox achievement history, and location trackers some sites rely on, which can bring wrong regional settings and more CAPTCHAs.

    My set broke the first two rules. I downloaded the lists once for this check and compared them name by name, to see which entries one list already blocks in another. I do not have the copies the router loaded earlier, and I did not measure ThreatFox, so seventeen lists were measured.

    Seven of the seventeen were covered by the rest of the set, apart from each list’s one marker entry: Pro Mini, Pro++ Mini, TIF Medium, TIF Mini, Gambling Medium, Gambling Mini and Fake. Dropping all seven together would have lost 15 names that TIF Medium and Mini carry and the full TIF does not. Pop-Up Ads added 37 names of its 48,277 to the rest of the set (against Pro++ alone it adds three, below). DynDNS and Anti Piracy were different: on those lists they carried about 1,200 and about 55,000 names that no other list in the set did, and I dropped them by choice, not as duplicates.

    The four tier lists together held 233,710 names, all but Hagezi’s four marker entries in Ultimate. Against Pro++ on its own, they missed 31,411 Pro++ entries, the ones not on the most-visited lists. In their place they carried 25,040 entries that only Ultimate blocks (25,041 with the Ultimate Mini marker), all from the most-visited lists. Hagezi rates Ultimate’s risk of breakage high. I kept no record of breakage from them and did not test for it, but by Hagezi’s rating the mix took on Ultimate’s risk and lacked Pro++’s coverage.

    Deep dive: how I measured, and why a plain comparison gets it wrong

    OPNsense uses Hagezi’s wildcard format, where a line such as *.example.com blocks example.com and every name under it. So an entry in list A is already blocked by list B if B holds the entry or any of its parent domains.

    A plain text comparison misses that. comm reports 3,294 Pro++ Mini entries that are “not in” Ultimate Mini. All but one of them are covered, because Ultimate Mini blocks a parent domain instead. It has one line for the whole of omtrdc.net, an Adobe tracking domain, where Pro++ Mini lists 998 of its hosts one by one. The one left over is Hagezi’s marker entry, explained below.

    The four tier lists, measured the same way:

    Normal + Pro Mini + Pro++ Mini + Ultimate Mini
    Unique names 233,710
    Of those, also in Ultimate all but 4 (Hagezi’s marker entries)
    Pro++ entries missing from the mix 31,411 of 223,551
    Names in the mix that only Ultimate blocks 25,040

    The check I used walks up the parent domains. It is a Python 3 script with nothing to install beyond Python itself. The script comes first; the steps after it say how to save and run it.

    #!/usr/bin/env python3
    """hagezi_overlap.py - how much of blocklist A is already blocked by blocklist B.
    
    Reads two Hagezi lists in the wildcard format (the /wildcard/ files, the format
    OPNsense uses). A line "*.example.com" blocks example.com and every name under
    it, so an entry of A counts as covered when the entry itself, or one of its
    parent domains, is in B. A plain text comparison (comm, diff) misses that and
    reports too many differences.
    
    Usage:  python3 hagezi_overlap.py A.txt B.txt
    Author: Vivek Sanghi. Licence: CC BY-NC-SA 4.0, as the blog.
    """
    import re
    import sys
    
    WILDCARD = re.compile(r"^\*\.[a-z0-9_-]+(\.[a-z0-9_-]+)+$")
    
    
    def load(path):
        names = set()
        try:
            f = open(path, encoding="utf-8-sig")
        except OSError as e:
            sys.exit(f"{path}: cannot open ({e.strerror})")
        with f:
            for number, line in enumerate(f, 1):
                line = line.strip().lower()
                if not line or line.startswith("#"):
                    continue
                if not WILDCARD.match(line):
                    sys.exit(f"{path}, line {number}: not a wildcard-format line "
                             "('*.example.com'). Download the /wildcard/ version of the list.")
                names.add(line[2:])
        if not names:
            sys.exit(f"{path}: no entries found; check the download")
        return names
    
    
    def covered(name, blocked):
        while True:
            if name in blocked:
                return True
            if "." not in name:
                return False
            name = name.split(".", 1)[1]
    
    
    def main():
        if len(sys.argv) != 3:
            sys.exit("usage: hagezi_overlap.py A.txt B.txt")
        a, b = load(sys.argv[1]), load(sys.argv[2])
        missing = sorted(n for n in a if not covered(n, b))
        print(f"{sys.argv[1]}: {len(a):,} entries; {len(a) - len(missing):,} already "
              f"blocked by {sys.argv[2]}; {len(missing):,} not")
        for n in missing[:10]:
            print(f"  not covered: {n}")
        if len(missing) > 10:
            print(f"  ... and {len(missing) - 10:,} more")
    
    
    if __name__ == "__main__":
        main()
    

    Before you start. This is for a Windows PC. You need Python 3 (step 3 checks). The steps create one folder in your user folder, download two list files of a few megabytes into it, and read them; they change nothing else. Allow ten minutes. To undo, delete the folder in File Explorer. On a Mac or Linux, use Terminal, python3 instead of py, and curl instead of curl.exe.

    1. Click the Start menu, type powershell and press Enter. A window opens with a prompt that starts with PS.
    2. Make a folder and move into it. Each line takes a moment; run them one at a time:

      mkdir hagezi-check
      cd hagezi-check

      The prompt should now end with hagezi-check. If the first line says the folder already exists, pick another name and use it in both lines.

    3. Check that Python is installed:

      py --version

      You should see a line such as Python 3.12.4. If PowerShell says it does not recognise py, install Python 3 from python.org (tick “Add python.exe to PATH” in the installer), close PowerShell and start again at step 1.

    4. Create the script file. This opens Notepad:

      notepad hagezi_overlap.py

      Notepad asks whether to create a new file; click Yes. Paste the script from the box above (click Copy on the box, then Ctrl + V in Notepad), press Ctrl + S, and close Notepad. If Notepad opens without asking, save with File, Save as, type hagezi_overlap.py in quotation marks as the file name, make sure the folder is hagezi-check, and click Save.

    5. Download two lists into the folder. On Windows, type curl.exe, not curl, in PowerShell. Run the lines one at a time:

      curl.exe -o pro.plus.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/pro.plus.mini.txt
      curl.exe -o ultimate.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/ultimate.mini.txt

      Each takes a few seconds and prints a progress table. If a line ends with an error, check the connection and run that line again.

    6. Run the check:

      py hagezi_overlap.py pro.plus.mini.txt ultimate.mini.txt
    7. On the lists I downloaded for this check it printed:

      pro.plus.mini.txt: 98,704 entries; 98,703 already blocked by ultimate.mini.txt; 1 not
        not covered: h4g3z1-pro-plus-mini.web.app

      Your numbers will differ, because the lists change daily. If you see a message instead of numbers, the script stopped on purpose: read the message, since it names the file and the line.

    The one name left over in each comparison is a marker Hagezi puts in every list (h4g3z1-<list>.web.app), so you can tell which list is loaded. If a download fails, or the file is in another format, the script stops and says so instead of reporting a number.

    What else it gave, on the same lists:

    List A List B Entries of A already blocked by B
    Normal (171,454) Pro++ all but the marker
    Pro++ (223,551) Ultimate all but the marker
    Pro Mini (86,842) Ultimate Mini all but the marker
    TIF Mini (212,777) TIF Medium all but the marker
    Gambling Mini (118,888) Gambling Medium all but the marker
    Fake (17,622) Pro++ all but the marker
    Pop-Up Ads (48,277) Pro++ all but 4 (the marker and 3 others)
    Badware Hoster (1,088) Pro++ 966
    Ultimate Mini (120,458) Pro++ 95,417

    The script was tested on these lists and on a missing file, an empty file, a comments-only file, a failed download, a web page, and lists in the adblock, hosts and plain-domain formats.

    The count of names loaded did not follow my changes. On the day of the first clean-up the router loaded 2,840,117 names before it and 3,188,234 after it, with ten lists instead of eighteen: between two downloads that day, TIF had grown by 426,519 entries. With no change on my side, the count then moved from 2,739,044 to 3,229,041 in four days. On the list sizes I downloaded for this check, about two-thirds of the names were on TIF and about 7 per cent on Pro++.

    Deep dive: the router’s figures, with their caveats

    Names loaded, from the router’s log (“blocklist loaded. length is …”, the number of unique names):

    When Lists Names loaded
    First clean-up day, before the eighteen 2,840,117
    First clean-up day, after the new set 3,188,234
    Five days later same set 2,739,044
    Nine days later same set 3,229,041
    Eighteen days later same set 3,198,953

    Share of queries blocked, from Reporting → Unbound DNS:

    Window Queries Blocked
    First clean-up day, as read that day not recorded 12.9 per cent
    A window of about 38 hours, read later 110,248 8,600 (7.80 per cent)

    The two percentages cover different lists, different days and whatever the network happened to be doing. They are not a before and after.

    What I tick now

    My router’s settings show:

    • Hagezi Pro++ (full)
    • TIF (full)
    • Gambling (full)
    • Fake, Pop-Up Ads, Badware Hoster and “Safesearch not supported”
    • OISD NSFW
    • two Hagezi lists by URL: encrypted-DNS servers and LG TV trackers
    • Abuse.ch ThreatFox, by URL, with a free key (below)

    I chose Pro++ over Hagezi’s recommended Pro for device trackers, since Pro++ is where he blocks nearly all of them.

    Two of these are duplicates. Hagezi’s cheat sheet marks Fake and Pop-Up Ads as inside Pro++. For Fake the measurement agrees, and it can come off with no change to what is blocked. Pop-Up Ads has three names, on the lists I downloaded, that none of Pro++, TIF, Gambling, Hoster or Fake carries; dropping it costs those three. I did not compare ThreatFox or the two URL lists. Fake and Pop-Up Ads are both still ticked.

    ThreatFox stopped downloading and now downloads again. Each update had logged “unable to download blocklist … and no cache available”. The address OPNsense’s built-in entry used for it answers “410 Gone”, and abuse.ch’s export page asks for an Auth-Key before it gives out the host file. A later 26.7 release removed the built-in entry for that reason and points users to “URLs of Blocklists”. abuse.ch issues the key free through its authentication portal. I added the list by URL with the key in the address. abuse.ch’s export page asks for the key in the URL, and OPNsense’s downloader sends no headers. The steps below show the form of the address. The update that added it logged “blocklist download” with 28,889 lines for it, 28,869 of them names, and no error; the other lists loaded from cache in that update. By the router’s own count of loaded names, it rose from 2,765,172 to 2,782,246. So 17,074 of the 28,869 were not already loaded under that exact name, and about 11,800 were. The count compares names literally, so a name whose parent domain another list already blocks counts as new. Hagezi does not name ThreatFox as a source.

    The key works like a password. The router stores it in its configuration, and each update writes the address, key included, to the resolver log. Keep it out of screenshots, shared logs, configuration backups and any remote log server that leave your hands. If it has leaked, get a new key from the same portal and change the address.

    Deep dive: adding ThreatFox with a key

    Before you start. This adds one list to your policy. Allow ten minutes. Nothing is deleted. To undo it, remove the address from the same box and apply again.

    1. In a browser, open https://auth.abuse.ch, create an account if you have none, and get an Auth-Key. The key is free. Copy it into a text file only until step 4, where you paste it once, then delete the file.
    2. Log in to the router. Click Services, then Unbound DNS, then Blocklists.
    3. At the right end of your policy’s row, click the pencil (Edit). A window titled Edit Blocklist opens.
    4. Click inside URLs of Blocklists and type the address below, with your key in place of YOUR_KEY and no spaces. Press Enter so it becomes a tag of its own (a tag is one entry shown as a small box in the field):

      https://threatfox-api.abuse.ch/v2/files/exports/YOUR_KEY/hostfile.txt

      The key sits between exports/ and /hostfile.txt.

    5. Click Save, then Apply. The router downloads the lists again; allow a minute or two.

    6. Click Services, Unbound DNS, Log File, search for download, and tick Informational in the severity box. You should see “blocklist download:” and a number of lines for the ThreatFox address. If the line says “unable to download”, check the key and the address for a stray space.
    7. Do not share that screen: the line shows the address with your key.
    Deep dive: Badware Hoster and the two lists added by URL

    Badware Hoster is a standalone Hagezi list, and 966 of its 1,088 entries are already in Pro++. The rest blocks whole hosting providers that keep turning up in threat feeds. Hagezi warns that legitimate sites on those hosts are blocked with them, and leaves unblocking them to whoever runs the list.

    The two lists added by URL are Hagezi’s, in the wildcard format:

    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/doh.txt
    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/native.lgwebos.txt

    The first lists encrypted-DNS servers by name, part of stopping devices from going around the router. The second lists LG webOS ad and tracking servers. Each has its own story, for separate posts.

    The built-in Hagezi tick-boxes in OPNsense 26.7 download from Hagezi’s mirror, hagezi-mirror.dnsbunker.org, as the log shows. Hagezi says that mirror publishes a new build roughly every four to eight hours; the jsDelivr copies update once a day.

    What DNS cannot block

    In-app YouTube and Instagram ads come from the same domains as the videos and posts, so blocking them by name would block the content. Hagezi’s FAQ makes the general point: some ads load from the same domains as the content, and a content blocker in the browser, or an app-level blocker on a phone, is the layer that catches them. I accepted the in-app ads.

    A DNS blocklist also filters only the devices that ask the router; devices with their own encrypted or hard-coded DNS go around it. That is a separate post.

    How this was done

    Claude read the documentation and the lists, compared them, and read my router through my logged-in browser session: settings, the resolver log and the tester. I decided what to change. In the allowlist session the only change on the router was the allowlist rewrite.

    The model got things wrong. The bare-name allowlist fix came out of the first session, and in one of the sessions it also told me the nightly blocklist update flushes Unbound’s cache. The router’s log showed the update loading the lists into the running Unbound, with no restart. The manual says applying blocklist settings does not restart Unbound, and the source loads the new list into the running process. The flush setting applies only when Unbound stops.

    A model with a logged-in session on a router is a risk of its own. The resolver log it reads holds names that any website can make a device look up, and a name can carry text written to steer a model. In the allowlist session I kept it to reading, apart from the allowlist change. That is an instruction to the model, not a control; a read-only OPNsense user would be one. The resolver log also holds the ThreatFox address with its key, so a session that reads the log sees the key. If you let a model read that log, replace the key afterwards.

    In the first session I also changed five Unbound settings and one cron job. The router shows all six as set.

    Deep dive: each setting, and how to undo DNS over TLS
    Setting (page) Before After
    Flush DNS Cache during reload (General) on off
    Prefetch Support (Advanced) off on
    Serve Expired Responses (Advanced) off on; TTL for Expired Responses 86,400 s
    Use System Nameservers (Query Forwarding) on off
    DNS over TLS forwarders none Cloudflare and Quad9
    Blocklist update job (System → Settings → Cron) a slot shared with other jobs a slot of its own

    Prefetch refreshes popular entries before they expire. The manual puts the cost at about 10 per cent more DNS traffic.

    Serve Expired Responses answers from cache with an expired record instead of making the device wait. When it is on, more fields appear. “TTL for Expired Responses” limits how long after expiry a stale answer may be served; I set 86,400 seconds, the low end of the manual’s suggested 86,400 to 259,200.

    One interaction I have not tested: with cache flushing off and stale answers allowed, a name that a list newly blocks may go on being answered from Unbound’s cache for a while. If a block does not take effect at once, that is the first thing I would look at.

    Use System Nameservers. The manual says the system nameservers are preferred over any catch-all entry in Query Forwarding and DNS over TLS. Turning it off lets the DNS over TLS entries carry the queries. The four entries, under Services → Unbound DNS → DNS over TLS:

    Server IP Port Verify CN
    1.1.1.1 853 cloudflare-dns.com
    1.0.0.1 853 cloudflare-dns.com
    9.9.9.9 853 dns.quad9.net
    149.112.112.112 853 dns.quad9.net

    The router’s own queries to these servers leave encrypted. A firewall rule that rejects port 853 from the LAN, to stop devices using their own encrypted DNS, does not touch them, because they leave from the router itself.

    The update time moved to a slot of its own so the update no longer shares a time with other scheduled jobs.

    To undo the DNS over TLS change:

    Before you start. This changes your router’s DNS settings and takes five minutes. DNS keeps working through the settings that remain. Note the four entries first (the table above); you need them to put the change back.

    1. Open the router’s settings page and sign in. You should see the Lobby page.
    2. Click Services, then Unbound DNS, then DNS over TLS. A table lists the entries.
    3. At the right end of the first row, click the pencil (Edit). A window titled Edit server opens. Untick Enabled and click Save. Do the same for each of the other rows.
    4. At the top of the same page, tick Use System Nameservers. The same box appears under Query Forwarding; it is one setting.
    5. Click Apply at the bottom of the page. Unbound reloads in a few seconds.
    6. Check: from a device on the network, open any website you have not visited today. It should load. If System, Settings, General has no nameservers, Unbound resolves from the root servers itself instead of forwarding; add your provider’s servers there if you want them used.
    7. To put the change back, tick Enabled on each entry again, untick Use System Nameservers, and click Apply.

    Sources

    वह fix जिसने phishing नाम निकल जाने दिए

    अंग्रेज़ी मूल से अनुवादित। Commands, code और technical terms अंग्रेज़ी में ही रखे गए हैं।

    अक्टूबर के एक शनिवार को मैंने अपने router की DNS allowlist की चार टूटी हुई एंट्री ठीक कीं। दो हफ़्ते से कुछ ज़्यादा बाद मुझे पता चला कि ठीक की गई उन एंट्री ने threat feed के ऐसे नाम निकल जाने दिए, जो उन्हीं साइटों जैसे दिखने के लिए बनाए गए थे जिन्हें मैं allow करना चाहता था: किसी भुगतान वाली साइट का domain, उसके बाद .https. और कोई असंबंधित domain, या किसी दुकान का नाम जिसमें dot की जगह hyphen हो। मेरे router के अपने tester ने इन्हें पास कर दिया।

    उसी शाम मैंने अपनी blocklist अठारह से घटाकर दस कर दी थीं; अगले दिन LG TV की एक सूची जुड़ने से ग्यारह हो गईं। इनमें से सात बाकी सेट में पहले से शामिल थीं। जो एक सूची मैंने रखी, Abuse.ch ThreatFox, वह तब download होना बंद हो गई जब abuse.ch ने अपनी host file सिर्फ़ key के साथ देना शुरू किया। मैंने उसके address में एक free key डाली, तब से वह फिर download होती है। और मेरे फ़ोन पर YouTube और Instagram के भीतर के ads पूरे समय आते रहे, जिसे कोई blocklist बदल नहीं सकती थी।

    फिर मैंने allowlist की एंट्री दोबारा लिखीं। यह पोस्ट दोनों सफ़ाई के बारे में है: OPNsense allowlist की एंट्री के साथ क्या करता है, अपनी एंट्री कैसे जाँचें, और अठारह आपस में मिलती सूचियों का जोड़ क्या निकला। यह काम मैंने Claude के साथ दो sessions में किया, हर सफ़ाई के लिए एक; ThreatFox की key तीसरे session में डाली गई। उसने मेरे browser के ज़रिए router को पढ़ा; router पर हर बदलाव मेरी मंज़ूरी से हुआ। मैंने bare नाम वाला fix मंज़ूर किया था, इसलिए उस गलती के मामले में मंज़ूरी कोई सुरक्षा नहीं थी।

    Command line में नए हैं? इन boxes को कैसे पढ़ें

    PS> का मतलब है: इसे Windows पर PowerShell में type करें (Start menu → powershell type करें → Enter)। $ का मतलब है: इसे Linux या Mac के terminal में type करें, या Pi पर ssh से log in करने के बाद। $ या PS> को खुद type न करें।

    $ या PS> से शुरू होने वाली हर लाइन एक command है। सिर्फ़ उस लाइन को copy करने के लिए उस $ पर click करें, उसे paste करें, Enter दबाएँ, और अगले से पहले उसके पूरा होने का इंतज़ार करें। जिस box के ऊपरी हिस्से में Copy button है, वह एक command (या एक file) रखता है, इसलिए उसे पूरा copy करें। डैश वाली रेखाओं (- – -) से बना box दिखाता है कि आपको जवाब में क्या दिखना चाहिए; उसे आप type नहीं करते।

    Allowlist

    मेरी blocklist policy की allowlist में 26 एंट्री थीं। पहली सफ़ाई के दिन उनमें से चार टूटी हुई लगीं। तीन browser की address bar से पूरे address के रूप में चिपकाई गई थीं, जैसे https://example.org/। चौथी में नाम के पहले अक्षर से पहले एक space था। मैंने चारों को example.in जैसे bare नामों से बदल दिया। बाकी 22 कैसे लिखी गई थीं, यह मैंने नहीं देखा, और router की configuration history अब इतनी पीछे नहीं जाती कि जाँच हो सके। अगर वे bare नाम थीं, जैसे router का अपना Allow button लिखता है, तो यह कमी मेरे fix से पहले भी थी, और fix ने उसे उन तीन एंट्री तक बढ़ा दिया जो पहले किसी चीज़ से मेल नहीं खाती थीं।

    Router के log में पाँचवीं एंट्री दिखी, *.ntp.org के रूप में लिखी हुई, जो अब हटा दी गई है। हर रात के update ने उसके लिए “skip invalid whitelist exclude pattern” लिखा था। Python की regular expressions में शुरू का * मान्य नहीं है, इसलिए router हर रात वह एंट्री छोड़ देता था और इसकी सूचना सिर्फ़ log में देता था। जो रूप वही करता है जो मैं चाहता था, वह है (.*\.)?ntp\.org\.?$।

    बाद में Claude ने वह code पढ़ा जो allowlist लागू करता है, OPNsense 26.7 में। शुरू के space से कोई नुकसान नहीं हुआ था: code हर एंट्री से space हटा देता है। समस्या bare नामों की थी।

    OPNsense हर एंट्री को regular expression मानता है, case-insensitive, और उसे उस नाम की शुरुआत से मिलाता है जो कोई device पूछता है। कुछ भी उसे नाम के अंत से नहीं बाँधता, और बिना escape किया हुआ dot किसी भी अक्षर से मेल खाता है। इसलिए सिर्फ़ example.com लिखने पर example.com allow होता है, पर www.example.com नहीं। साथ ही वह हर उस नाम को allow करता है जो इन्हीं अक्षरों से शुरू हो, हर dot की जगह कोई भी अक्षर रखकर: example.com.evil.net, example-com.evil.net, example.community।

    Threat feed में ठीक इसी आकार के नाम हैं: किसी जाने-माने साइट का नाम, उसके बाद .https. और कोई असंबंधित domain, या dot की जगह hyphen वाला साइट का नाम। इस जाँच के लिए मैंने जो feed download किया, उस पर मेरी 26 एंट्री में से सात ऐसे 43 नामों से मेल खाती थीं; एक एंट्री 20 से। मेरे router के tester पर, ऐसे जो पाँच नाम मैंने आज़माए, हर एक पास हुआ, जबकि blocklist की उसी एंट्री से block होने वाला वही नाम, आगे www. लगाकर, block हो गया। मैंने खुद एक नाम बनाया, एक allow की गई साइट और एक ऐसे domain से जिसे threat feed block करता है; वह भी पास हुआ। Matching code के अनुसार, हर bare एंट्री उस हर नाम को allow करती है जो उससे शुरू होता है, चाहे कोई सूची उस नाम को block करे या न करे।

    OPNsense का अपना Allow button, Reporting → Unbound DNS में, bare नाम को उसी तरह save करता है। वहाँ से जोड़ी गई एंट्री भी उसी तरह चलती हैं।

    इसका हल है ठीक वही नाम allow करना, दोनों सिरों पर anchor के साथ:

    ^www\.example\.com\.?$

    Backslash dot को सिर्फ़ dot ही रहने देते हैं, किसी भी अक्षर से मेल खाने वाला नहीं, और $ pattern को नाम के अंत से बाँध देता है। \.? वह अंतिम dot allow करता है जो code की जाँच के दो रास्तों में से एक पर नाम में रहता है (गहराई वाला हिस्सा देखें)। ^ वही दोहराता है जो code पहले से करता है, इसलिए उसे छोड़ने पर भी काम चलेगा; मैं उसे रखता हूँ ताकि pattern कहीं भी एक जैसा दिखे। अपनी एंट्री जाँचने और दोबारा लिखने के steps “अपनी एंट्री कैसे जाँचें” के नीचे के ‘गहराई में’ वाले हिस्सों में हैं।

    किसी domain को उसके सभी subdomains के साथ allow करने के लिए (.*\.)?example\.com\.?$ चलता है, पर वह उन hosts को भी allow कर देता है जिन्हें सूची उसी domain के नीचे जान-बूझकर block करती है। मेरी एक एंट्री पर, Pro++ उस domain के नीचे पाँच hosts block करती है, advertising और sponsored-ads जैसे नामों वाले, और domain को या उसके www. नाम को block नहीं करती। पूरे subdomain वाला allow उन्हें वापस आने देगा।

    मैंने OPNsense का अपना parsing code और उसकी matching call कुछ नामों पर चलाई:

    Allowlist एंट्री पूछा गया नाम Allow हुआ?
    https://example.org/ example.org नहीं
    example.in example.in हाँ
    example.in www.example.in नहीं
    example.in example.in.example.net हाँ
    example.in example-info.de हाँ
    ^www\.example\.in\.?$ www.example.in हाँ
    ^www\.example\.in\.?$ advertising.example.in नहीं
    ^www\.example\.in\.?$ www.example.in.example.net नहीं

    मैंने सभी 26 एंट्री उसी सटीक, anchor वाले रूप में दोबारा लिखीं और बदलाव apply किया। जो हर नाम tester से पास हुआ था, वह बाद में block हुआ। जिस एंट्री का अपना नाम किसी सूची में है, वह आज भी पास होती है, जैसा चाहा था। बाकी 25 के सटीक नाम किसी सूची ने block नहीं किए थे, इसलिए उन एंट्री का अपने नामों के लिए कोई काम नहीं था; उनका एकमात्र असर prefix वाली कमी था। मैंने उन्हें हटाने की जगह anchor किया, क्योंकि कोई सूची बाद में कोई नाम जोड़ सकती है। अगर आपके पास ऐसी एंट्री हैं, तो उन्हें हटाना भी ठीक विकल्प है।

    गहराई में: code, और मेरे tests क्या दिखाते हैं और क्या नहीं

    Blocklist dialog में एक ही “Allowlist Domains” field है। उसके help text में लिखा है कि वह domains लेता है, regular expressions इस्तेमाल हो सकती हैं, और वह सिर्फ़ उसी policy के matches पर लागू होता है। 26.7 में:

    • src/opnsense/service/templates/OPNsense/Unbound/core/blocklists.conf इस field को excludes.patterns के रूप में, comma से अलग करके लिखता है।
    • src/opnsense/scripts/unbound/blocklists/default_bl.py उस value को commas पर बाँटता है, हर एंट्री पर strip() बुलाता है, जो एंट्री regular expression के रूप में compile नहीं होती उसे छोड़ देता है (“skip invalid” log लाइन के साथ), और बाकी को, एक built-in .*localhost$ एंट्री के साथ, | से जोड़कर एक pattern बना देता है।
    • src/opnsense/scripts/unbound-dnsbl/lib/__init__.py pattern को case-insensitive रूप में compile करता है।
    • src/opnsense/scripts/unbound-dnsbl/lib/dnsbl.py blocklist hit के बाद उसे r.match(domain) से जाँचता है। Python का match नाम की शुरुआत पर anchored है, अंत पर नहीं। नाम पहले lower-case किया जाता है और उसका अंतिम dot हटाया जाता है।
    • जब किसी CNAME target को block किया जाता है, वही function मूल नाम को भी जाँचता है (r.match(orig)), इसलिए allowlist किया हुआ नाम blocked alias के रास्ते भी resolve हो जाता है। वह मूल नाम Unbound से अंतिम dot के साथ आता है, www.example.com., और साफ़ नहीं किया जाता। सिर्फ़ $ पर ख़त्म होने वाला pattern वहाँ fail होता है; \.?$ दोनों रास्तों पर पास होता है।
    • src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php, updateBlocklistAction, वही है जिसे Reporting का Allow button बुलाता है। वह अंतिम dot हटाता है (rtrim($domain, '.')) और नाम को जैसा है वैसा save कर देता है, बिना escape और बिना anchor के।

    OPNsense की manual allowlist एंट्री को ऐसा बताती है जो उन blocklist items को बाहर करती है जिनमें pattern आता है। Code शुरुआत पर इससे संकरा है, क्योंकि वह सिर्फ़ पहले अक्षर से मिलाता है, और अंत पर उतना ही खुला है। दोनों तरह पढ़ने पर अंत को anchor करना एंट्री लिखने वाले पर छोड़ा गया है। मैंने यही पाँच files 26.7 की सबसे नई release में और development branch में मिलाईं: allowlist code वैसा ही है।

    Tests क्या दिखाते हैं: 26.7 source का parser और matching calls इन एंट्री को कैसे लेते हैं, router के बाहर चलाकर, CNAME वाला मामला अंतिम dot जोड़कर simulate किया हुआ; और, मेरे router पर, मैंने जो हर phishing नाम आज़माया उसके लिए tester का फ़ैसला, एक control के बगल में जो सिर्फ़ इसमें अलग है कि वह allowlist की किसी एंट्री से शुरू नहीं होता, rewrite से पहले और बाद। Tester वही matching code उन सूचियों पर चलाता है जो router ने load की हैं, पर सिर्फ़ सीधे lookup के लिए, इसलिए वह CNAME वाला रास्ता नहीं दिखा सकता। 43 नामों की गिनती प्रकाशित सूचियों से आती है, router से नहीं; सभी 43 TIF पर हैं।

    अपनी एंट्री कैसे जाँचें

    चार जाँचें, आख़िरी को छोड़कर सब सिर्फ़ पढ़ने वाली:

    1. Resolver log में देखें कि कौन-सी सूचियाँ download नहीं हुईं और कौन-सी allowlist एंट्री छोड़ी गईं।
    2. Blocklist tester में एक ऐसा नाम आज़माएँ जो block होना चाहिए और एक जो पास होना चाहिए, ताकि दिखे कि सूचियाँ load हैं।
    3. हर allowlist एंट्री के लिए, एंट्री के बाद ऐसा domain लगाकर test करें जिसे आपकी सूचियाँ block करती हैं, फिर वही नाम आगे www. लगाकर। अगर पहला पास हो और दूसरा block हो, तो एंट्री खुली है।
    4. हर खुली एंट्री को anchor के साथ दोबारा लिखें, apply करें, और फिर test करें।

    जाँच 1 से 3 और rewrite के click-by-click steps नीचे के दो ‘गहराई में’ वाले हिस्सों में हैं। वे sign-in पेज से शुरू होते हैं और बताते हैं कि हर step क्या बदलता है।

    गहराई में: step by step, अपनी allowlist की जाँच

    शुरू करने से पहले। आपको अपने network के किसी computer पर एक browser चाहिए, और अपने router के settings पेज का address और login। Steps 1 से 8 सिर्फ़ पढ़ते हैं: वे router पर कुछ नहीं बदलते, इसलिए आप किसी भी जगह रुक सकते हैं, कुछ वापस करने की ज़रूरत नहीं। लगभग दस मिनट रखें, और हर test के लिए लगभग दस सेकंड अलग से, क्योंकि tester हर बार पूरी blocklist load करता है।

    1. एक browser खोलें और वह address डालें जिससे आप OPNsense में sign in करते हैं। Sign in करें। आपको Lobby पेज दिखना चाहिए। अगर पेज load न हो, तो देखें कि computer आपके home network पर है और आपने वही address डाला है जो आप router में किसी भी दूसरे बदलाव के लिए डालते हैं।
    2. बाईं ओर के menu में Services पर click करें, फिर Unbound DNS, फिर Log File। आपको एक table दिखेगी जिसके columns Date, Severity, Process और Line हैं। उसके ऊपर एक search box, एक severity box (Warning पर set) और एक time box (Last day पर set) हैं।
    3. Search box में click करें, blocklist type करें और Enter दबाएँ। दो तरह की लाइनें मायने रखती हैं। “unable to download blocklist” का मतलब है कि एक सूची load नहीं हुई और उसका कोई योगदान नहीं है। “skip invalid whitelist exclude pattern” का मतलब है कि OPNsense ने एक allowlist एंट्री छोड़ दी। अगर table खाली है, तो पिछले एक दिन में Warning level पर कुछ log नहीं हुआ। “blocklist loaded” वाली लाइनें देखने के लिए severity box खोलें और Informational भी tick करें; और पीछे देखने के लिए time box खोलें।
    4. उसी menu में Blocklists पर click करें, फिर पेज के ऊपर Tester tab पर। आपको एक Domain box, एक Source box और एक Test button दिखेगा। Source खाली छोड़ें; तब test router खुद के रूप में चलता है। Source किसी device का address लेता है, और तभी काम आता है जब आपके पास ऐसी policy हो जो कुछ ही devices पर लागू होती हो।
    5. Domain में googleads.g.doubleclick.net type करें और Test पर click करें। लगभग दस सेकंड रुकें। नतीजा Block होना चाहिए। फिर www.youtube.com test करें; वह Pass होना चाहिए। अगर पहला नाम पास हो जाए, तो या कोई सूची load नहीं है, या वह नाम आपकी अपनी allowlist में है: step 3 पर लौटकर errors पढ़ें, और अगर आपने वह नाम allowlist किया है, तो कोई दूसरा नाम चुनें जिसे आपकी सूचियाँ block करती हैं। Tester CNAME को follow नहीं करता। CNAME ऐसा नाम है जो किसी दूसरे नाम की ओर इशारा करता है; tester सिर्फ़ वही नाम जाँचता है जो आप type करते हैं।
    6. Blocklists tab पर click करें। अपनी policy की row के दाएँ सिरे पर pencil (Edit) पर click करें। Edit Blocklist नाम की एक window खुलती है। Allowlist Domains में आपकी एंट्री दिखती हैं, हर एक अलग tag के रूप में। उन्हें पढ़ें, फिर Cancel पर click करें। कुछ save नहीं होता।
    7. हर एंट्री के लिए, एंट्री के बाद ऐसा domain लगाकर test करें जिसे आपकी सूचियाँ block करती हैं। मेरी सूचियाँ जिस नाम को block करती हैं, वह googleads.g.doubleclick.net है, वही जो step 5 में था। अगर आपकी सूचियाँ उसे block नहीं करतीं, तो कोई ऐसा नाम चुनें जिसे वे करती हैं। इसलिए एंट्री example.com के लिए example.com.googleads.g.doubleclick.net type करें और Test पर click करें। फिर वही नाम आगे www. लगाकर test करें, www.example.com.googleads.g.doubleclick.net। अगर आप TIF load करते हैं, तो उसकी जगह उस सूची का कोई नाम इस्तेमाल कर सकते हैं। जो एंट्री पहले से ^ से शुरू और $ पर ख़त्म होती है, वह anchored है; उसे छोड़ दें।
    8. दोनों नतीजे साथ पढ़ें। अगर पहला पास हो और दूसरा block हो, तो एंट्री खुली है: वह हर उस नाम को निकलने देती है जो उससे शुरू होता है। उसे anchor के साथ दोबारा लिखें। जिस नाम को कोई सूची block नहीं करती, वह allowlist चाहे जो कहे, पास होता है, इसलिए Pass को गलती मानने से पहले tester में पक्का कर लें कि नाम block होता है।
    गहराई में: step by step, अपनी allowlist को दोबारा लिखना

    शुरू करने से पहले। यह आपके router की filtering बदलता है। पंद्रह मिनट रखें। यहाँ की गलती ज़्यादातर इसी रूप में दिखती है कि एक allow की हुई साइट load नहीं होती। आपका बाकी internet चलता रहना चाहिए। Router बदलाव लगभग एक मिनट में लागू करता है (मेरे router पर 43 सेकंड) और Unbound को restart नहीं करता; log दिखाता है कि सूचियाँ चलते हुए process में load हो रही हैं। Step 3 आपकी पुरानी एंट्री की एक copy save करता है, और step 8 उन्हें वापस रख देता है।

    1. Router का settings पेज खोलें और sign in करें। Services पर click करें, फिर Unbound DNS, फिर Blocklists।
    2. अपनी policy की row के दाएँ सिरे पर pencil (Edit) पर click करें। Edit Blocklist window खुलती है। Allowlist Domains के नीचे, box के नीचे के छोटे link Text पर click करें। Tags एक सादे box में बदल जाते हैं जिसमें हर लाइन पर एक एंट्री होती है, और एक Back link दिखता है। अगर आपके पास एक से ज़्यादा policy हैं, तो हर एक की अपनी allowlist है; हर एक के लिए यह करें।
    3. Undo copy बनाएँ। Box के अंदर click करें, Ctrl + A दबाएँ, फिर Ctrl + C। Notepad खोलें (Start menu, notepad type करें, Enter दबाएँ), Ctrl + V दबाएँ, और file को allowlist-before.txt नाम से किसी ऐसे folder में save करें जो आपको फिर मिल जाए। File में हर लाइन पर एक एंट्री होनी चाहिए।
    4. Box की हर लाइन दोबारा लिखें। यह सादे नामों के लिए है; जो एंट्री पहले से pattern है, जैसे जिसमें (.*\.)? हो, वह वैसी ही रहती है। वही सटीक नाम लिखें जो आपके devices पूछते हैं। हर dot से पहले \ लगाएँ, शुरू में ^ और अंत में \.?$:

      • example.in बन जाता है ^example\.in\.?$
      • www.example.com बन जाता है ^www\.example\.com\.?$

      हर लाइन पर एक एंट्री रखें, कोई space नहीं और कोई comma नहीं। www. वाला नाम और वही नाम उसके बिना, दो अलग नाम हैं और उन्हें दो लाइनें चाहिए। अगर आपको पक्का नहीं है कि कोई device कौन-सा पूछता है, तो Reporting, Unbound DNS में देखें, या दोनों सूची में रख दें।

    5. Back पर click करें। लाइनें फिर tags बन जाती हैं। जाँचें कि हर tag नए रूप में है। Save पर click करें। Window बंद हो जाती है।

    6. Apply पर click करें, table के नीचे का नारंगी button। लगभग एक मिनट रुकें।
    7. नतीजा जाँचें। Services, Unbound DNS, Log File खोलें, blocklist खोजें, और severity box में Informational tick करें। आपको “updating blocklist”, फिर “blocklist loaded. length is” और एक संख्या दिखनी चाहिए, और कोई “skip invalid” लाइन नहीं। फिर ऊपर के tester वाले steps दोहराएँ: lookalike नाम अब Block होने चाहिए। जो एंट्री किसी ऐसे नाम को allow करती है जिसे कोई सूची block करती है (मेरे यहाँ, Google के एक ad host वाली), वह अब भी Pass होनी चाहिए।
    8. अगर बदलाव के बाद कोई साइट load होना बंद हो जाए, तो उसे undo करें। Notepad में allowlist-before.txt खोलें, Ctrl + A, फिर Ctrl + C दबाएँ। Router में steps 1 और 2 दोहराएँ, box के अंदर click करें, Ctrl + A, फिर Ctrl + V दबाकर पुरानी एंट्री नई एंट्री के ऊपर paste करें, Back, Save और Apply पर click करें। जिस साइट को ऐसा नाम चाहिए जो आपने सूची में नहीं डाला, वह तब तक block रहती है जब तक आप वही सटीक नाम नहीं जोड़ते।
    गहराई में: computer से allowlist के बदलाव को test करना

    शुरू करने से पहले। यह उस Windows PC के लिए है जो router वाले ही network में है। यह router के DNS से एक नाम पूछता है और PC का अपना DNS cache साफ़ करता है; इसके अलावा कुछ नहीं बदलता। इसमें दो मिनट लगते हैं। Mac या Linux पर विचार वही है (nslookup name router-address), पर cache साफ़ करने का command अलग होता है।

    1. Start menu पर click करें, powershell type करें और Enter दबाएँ। एक window खुलती है जिसके prompt की शुरुआत PS से होती है।
    2. Router का address खोजें। यह type करें और Enter दबाएँ:

      ipconfig

      उस adapter के नीचे Default Gateway देखें जो आप इस्तेमाल कर रहे हैं। वही address आपका router है; नीचे के steps उसे <router-ip> कहते हैं। अगर आपका router किसी दूसरे router के पीछे है, तो default gateway वह दूसरा device हो सकता है; उस box का address इस्तेमाल करें जो आपकी DNS blocklist चलाता है। अगर लाइन खाली है, तो आप ऐसे adapter को देख रहे हैं जो connected नहीं है; अगले adapter तक scroll करें।

    3. Router पर Apply पर click करने और एक मिनट रुकने के बाद, PC का cache साफ़ करें। Blocked जवाब एक घंटे तक cache में रहते हैं, इसलिए इसके बिना PC पुराना जवाब रखे रह सकता है:

      ipconfig /flushdns
    4. Router से नाम पूछें, <router-ip> की जगह step 2 का address डालकर। नाम के बाद का आख़िरी dot Windows को पहले अपने search suffixes आज़माने से रोकता है:

      nslookup www.example.com. <router-ip>

      Blocked नाम 0.0.0.0 का जवाब देता है, या अगर policy पर Return NXDOMAIN tick है तो “Non-existent domain” का। जो नाम allowed है, वह अपने असली address के साथ जवाब देता है। पहली दो लाइनें आपका router दिखाती हैं; बाकी जवाब है।

    अठारह सूचियों का जोड़

    Router के resolver log में, उसकी पहली एंट्री से लेकर पहली सफ़ाई तक, हर पूरा रात का update यही अठारह सूचियाँ load करने के लिए set था (ThreatFox उनमें शामिल है, नीचे देखें):

    • Hagezi Normal, साथ में Pro, Pro++ और Ultimate के Mini versions
    • Threat Intelligence Feeds (TIF) तीनों आकारों में: full, Medium और Mini
    • Gambling तीनों आकारों में
    • Fake, Pop-Up Ads, Badware Hoster, DynDNS, Anti Piracy और “Safesearch not supported”
    • OISD NSFW और Abuse.ch ThreatFox

    Hagezi, जो इनमें से ज़्यादातर सूचियाँ बनाए रखते हैं, अपने FAQ में अपनी सूचियों को मिलाने के ये नियम देते हैं:

    1. पाँच Multi सूचियाँ — Light, Normal, Pro, Pro++ और Ultimate — एक-दूसरे पर बनी हैं। हर एक में उसके नीचे वाली शामिल है। आप एक चुनते हैं।
    2. आकार घटाए हुए versions (Mini, और TIF तथा Gambling के लिए Medium) अपनी पूरी सूची के विकल्प हैं। वे उसके ऊपर नहीं लगते।
    3. TIF अपवाद है। वह malware, cryptojacking, scams, spam और phishing को कवर करती है और जो भी tier आप चुनें, उसके साथ चलने के लिए बनी है।

    Pro, Pro++, Ultimate और Gambling के Mini सिर्फ़ वे नाम रखते हैं जो सबसे ज़्यादा देखे जाने वाले domains की सूचियों में भी आते हैं। TIF Mini और Gambling Mini, Medium सूची से काटे गए हैं। Hagezi Mini को सीमित memory वाले devices पर चलने वाले blockers के लिए बने बताते हैं।

    गहराई में: किसके लिए कौन-सा tier, और Ultimate की क़ीमत क्या है

    Hagezi का FAQ tiers को उस व्यक्ति से मिलाता है जो गड़बड़ी सँभालेगा:

    Tier किसके लिए गड़बड़ी का जोखिम (Hagezi की रेटिंग)
    Light ऐसा blocker जो बड़ी सूचियाँ नहीं सँभाल सकता, या ऐसी setting जहाँ Normal भी ज़्यादा है बहुत कम
    Normal बिना देखरेख वाले setups, जहाँ चीज़ें unblock करने वाला कोई admin नहीं कम
    Pro जहाँ कोई चीज़ें unblock कर सकता है; उनकी default सिफ़ारिश, TIF के साथ कम से मध्यम
    Pro++ admin वाले अनुभवी users मध्यम
    Ultimate बहुत अनुभवी users, जिनके पास admin उपलब्ध है ज़्यादा

    हर tier में native tracker सूचियों का एक हिस्सा भी है: TVs, फ़ोन और operating systems में बनी telemetry। Pro++ लगभग सारी block करता है; Ultimate सारी। README बताती है कि Ultimate की क़ीमत क्या है: Facebook और Messenger के कुछ functions, WhatsApp के extras जैसे avatars और video effects, Windows Spotlight और Xbox achievement history, और वे location trackers जिन पर कुछ साइटें निर्भर हैं, जिससे गलत क्षेत्रीय settings और ज़्यादा CAPTCHAs आ सकते हैं।

    मेरे सेट ने पहले दो नियम तोड़े। मैंने इस जाँच के लिए सूचियाँ एक बार download कीं और नाम-दर-नाम मिलाईं, यह देखने के लिए कि एक सूची की कौन-सी एंट्री दूसरी में पहले से block हैं। Router ने पहले जो copies load की थीं, वे मेरे पास नहीं हैं, और मैंने ThreatFox नहीं नापा, इसलिए सत्रह सूचियाँ नापी गईं।

    सत्रह में से सात बाकी सेट में शामिल थीं, हर सूची की एक marker एंट्री को छोड़कर: Pro Mini, Pro++ Mini, TIF Medium, TIF Mini, Gambling Medium, Gambling Mini और Fake। सातों को साथ हटाने पर वे 15 नाम खो जाते जो TIF Medium और Mini में हैं और पूरे TIF में नहीं हैं। Pop-Up Ads ने अपने 48,277 नामों में से 37 बाकी सेट में जोड़े (अकेले Pro++ के मुक़ाबले वह तीन जोड़ती है, नीचे देखें)। DynDNS और Anti Piracy अलग थीं: उन सूचियों में लगभग 1,200 और लगभग 55,000 ऐसे नाम थे जो सेट की किसी और सूची में नहीं थे, और मैंने उन्हें duplicate मानकर नहीं, अपनी पसंद से हटाया।

    चारों tier सूचियों में मिलाकर 233,710 नाम थे; Hagezi की चार marker एंट्री को छोड़कर सब Ultimate में थे। अकेले Pro++ के मुक़ाबले, वे Pro++ की 31,411 एंट्री से चूक गईं, यानी वे जो सबसे ज़्यादा देखे जाने वाली सूचियों में नहीं हैं। उनकी जगह उनमें 25,040 एंट्री थीं जो सिर्फ़ Ultimate block करता है (Ultimate Mini के marker के साथ 25,041), सब सबसे ज़्यादा देखे जाने वाली सूचियों से। Hagezi Ultimate की गड़बड़ी का जोखिम ज़्यादा रेट करते हैं। मैंने उनसे होने वाली किसी गड़बड़ी का record नहीं रखा और उसके लिए test नहीं किया, पर Hagezi की रेटिंग के अनुसार इस मिश्रण ने Ultimate का जोखिम लिया और उसमें Pro++ की coverage की कमी थी।

    गहराई में: मैंने कैसे नापा, और सादी तुलना गलत क्यों निकलती है

    OPNsense Hagezi का wildcard format इस्तेमाल करता है, जिसमें *.example.com जैसी लाइन example.com को और उसके नीचे के हर नाम को block करती है। इसलिए सूची A की कोई एंट्री सूची B में पहले से blocked है, अगर B में वह एंट्री या उसका कोई parent domain हो।

    सादी text तुलना इसे चूक जाती है। comm बताता है कि Pro++ Mini की 3,294 एंट्री Ultimate Mini में “नहीं हैं”। उनमें से एक को छोड़कर सब covered हैं, क्योंकि Ultimate Mini कोई parent domain block करता है। उसमें पूरे omtrdc.net के लिए, जो Adobe का tracking domain है, एक ही लाइन है, जबकि Pro++ Mini उसके 998 hosts एक-एक करके लिखता है। बचा हुआ एक Hagezi की marker एंट्री है, जो नीचे समझाई गई है।

    चारों tier सूचियाँ, उसी तरह नापी गईं:

    Normal + Pro Mini + Pro++ Mini + Ultimate Mini
    अलग-अलग नाम 233,710
    इनमें से, Ultimate में भी 4 को छोड़कर सब (Hagezi की marker एंट्री)
    मिश्रण में न आने वाली Pro++ की एंट्री 223,551 में से 31,411
    मिश्रण के वे नाम जो सिर्फ़ Ultimate block करता है 25,040

    मैंने जो जाँच इस्तेमाल की, वह parent domains पर ऊपर की ओर चलती है। यह एक Python 3 script है, जिसके लिए Python के अलावा कुछ install नहीं करना पड़ता। पहले script है; उसके बाद के steps बताते हैं कि उसे कैसे save और run करें।

    #!/usr/bin/env python3
    """hagezi_overlap.py - how much of blocklist A is already blocked by blocklist B.
    
    Reads two Hagezi lists in the wildcard format (the /wildcard/ files, the format
    OPNsense uses). A line "*.example.com" blocks example.com and every name under
    it, so an entry of A counts as covered when the entry itself, or one of its
    parent domains, is in B. A plain text comparison (comm, diff) misses that and
    reports too many differences.
    
    Usage:  python3 hagezi_overlap.py A.txt B.txt
    Author: Vivek Sanghi. Licence: CC BY-NC-SA 4.0, as the blog.
    """
    import re
    import sys
    
    WILDCARD = re.compile(r"^\*\.[a-z0-9_-]+(\.[a-z0-9_-]+)+$")
    
    
    def load(path):
        names = set()
        try:
            f = open(path, encoding="utf-8-sig")
        except OSError as e:
            sys.exit(f"{path}: cannot open ({e.strerror})")
        with f:
            for number, line in enumerate(f, 1):
                line = line.strip().lower()
                if not line or line.startswith("#"):
                    continue
                if not WILDCARD.match(line):
                    sys.exit(f"{path}, line {number}: not a wildcard-format line "
                             "('*.example.com'). Download the /wildcard/ version of the list.")
                names.add(line[2:])
        if not names:
            sys.exit(f"{path}: no entries found; check the download")
        return names
    
    
    def covered(name, blocked):
        while True:
            if name in blocked:
                return True
            if "." not in name:
                return False
            name = name.split(".", 1)[1]
    
    
    def main():
        if len(sys.argv) != 3:
            sys.exit("usage: hagezi_overlap.py A.txt B.txt")
        a, b = load(sys.argv[1]), load(sys.argv[2])
        missing = sorted(n for n in a if not covered(n, b))
        print(f"{sys.argv[1]}: {len(a):,} entries; {len(a) - len(missing):,} already "
              f"blocked by {sys.argv[2]}; {len(missing):,} not")
        for n in missing[:10]:
            print(f"  not covered: {n}")
        if len(missing) > 10:
            print(f"  ... and {len(missing) - 10:,} more")
    
    
    if __name__ == "__main__":
        main()
    

    शुरू करने से पहले। यह एक Windows PC के लिए है। आपको Python 3 चाहिए (step 3 जाँचता है)। Steps आपके user folder में एक folder बनाते हैं, उसमें कुछ megabytes की दो सूची files download करते हैं, और उन्हें पढ़ते हैं; इसके अलावा कुछ नहीं बदलते। दस मिनट रखें। undo करने के लिए File Explorer में वह folder delete कर दें। Mac या Linux पर Terminal इस्तेमाल करें, py की जगह python3, और curl.exe की जगह curl।

    1. Start menu पर click करें, powershell type करें और Enter दबाएँ। एक window खुलती है जिसके prompt की शुरुआत PS से होती है।
    2. एक folder बनाएँ और उसमें जाएँ। हर लाइन में थोड़ा समय लगता है; उन्हें एक-एक करके चलाएँ:

      mkdir hagezi-check
      cd hagezi-check

      अब prompt का अंत hagezi-check से होना चाहिए। अगर पहली लाइन कहे कि folder पहले से है, तो कोई दूसरा नाम चुनें और दोनों लाइनों में वही इस्तेमाल करें।

    3. जाँचें कि Python install है:

      py --version

      आपको Python 3.12.4 जैसी एक लाइन दिखनी चाहिए। अगर PowerShell कहे कि वह py को नहीं पहचानता, तो python.org से Python 3 install करें (installer में “Add python.exe to PATH” पर tick करें), PowerShell बंद करें और step 1 से फिर शुरू करें।

    4. Script file बनाएँ। इससे Notepad खुलता है:

      notepad hagezi_overlap.py

      Notepad पूछता है कि नई file बनानी है या नहीं; Yes पर click करें। ऊपर के box से script paste करें (box पर Copy पर click करें, फिर Notepad में Ctrl + V), Ctrl + S दबाएँ, और Notepad बंद करें। अगर Notepad बिना पूछे खुल जाए, तो File, Save as से save करें, file के नाम के रूप में hagezi_overlap.py को quotation marks में type करें, पक्का करें कि folder hagezi-check है, और Save पर click करें।

    5. दो सूचियाँ folder में download करें। Windows पर PowerShell में curl नहीं, curl.exe type करें। लाइनें एक-एक करके चलाएँ:

      curl.exe -o pro.plus.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/pro.plus.mini.txt
      curl.exe -o ultimate.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/ultimate.mini.txt

      हर एक में कुछ सेकंड लगते हैं और एक progress table छपती है। अगर कोई लाइन error पर ख़त्म हो, तो connection जाँचें और वह लाइन फिर चलाएँ।

    6. जाँच चलाएँ:

      py hagezi_overlap.py pro.plus.mini.txt ultimate.mini.txt
    7. जो सूचियाँ मैंने इस जाँच के लिए download कीं, उन पर इसने यह छापा:

      pro.plus.mini.txt: 98,704 entries; 98,703 already blocked by ultimate.mini.txt; 1 not
        not covered: h4g3z1-pro-plus-mini.web.app

      आपके numbers अलग होंगे, क्योंकि सूचियाँ रोज़ बदलती हैं। अगर आपको numbers की जगह कोई संदेश दिखे, तो script जान-बूझकर रुका है: संदेश पढ़ें, वह file और लाइन बताता है।

    हर तुलना में बचा हुआ एक नाम वह marker है जो Hagezi हर सूची में डालते हैं (h4g3z1-<list>.web.app), ताकि पता चले कि कौन-सी सूची load है। अगर download fail हो, या file किसी और format में हो, तो script कोई number बताने की जगह रुक जाता है और यह कह देता है।

    उन्हीं सूचियों पर इसने और क्या दिया:

    सूची A सूची B A की वे एंट्री जो B से पहले ही blocked हैं
    Normal (171,454) Pro++ marker को छोड़कर सब
    Pro++ (223,551) Ultimate marker को छोड़कर सब
    Pro Mini (86,842) Ultimate Mini marker को छोड़कर सब
    TIF Mini (212,777) TIF Medium marker को छोड़कर सब
    Gambling Mini (118,888) Gambling Medium marker को छोड़कर सब
    Fake (17,622) Pro++ marker को छोड़कर सब
    Pop-Up Ads (48,277) Pro++ 4 को छोड़कर सब (marker और 3 दूसरी)
    Badware Hoster (1,088) Pro++ 966
    Ultimate Mini (120,458) Pro++ 95,417

    Script का test इन सूचियों पर किया गया, और इन पर भी: missing file, खाली file, सिर्फ़ comments वाली file, failed download, एक web page, और adblock, hosts और plain-domain formats की सूचियाँ।

    load हुए नामों की गिनती मेरे बदलावों के अनुसार नहीं बदली। पहली सफ़ाई के दिन router ने उससे पहले 2,840,117 नाम load किए और उसके बाद 3,188,234, अठारह की जगह दस सूचियों के साथ: उस दिन दो downloads के बीच TIF में 426,519 एंट्री बढ़ गई थीं। मेरी ओर से बिना किसी बदलाव के, गिनती चार दिन में 2,739,044 से 3,229,041 हो गई। जो सूची sizes मैंने इस जाँच के लिए download कीं, उन पर लगभग दो-तिहाई नाम TIF पर थे और लगभग 7 प्रतिशत Pro++ पर।

    गहराई में: router के आँकड़े, उनकी सीमाओं के साथ

    लोड हुए नाम, router के log से (“blocklist loaded. length is …”, unique नामों की संख्या):

    कब सूचियाँ लोड हुए नाम
    पहली सफ़ाई का दिन, पहले अठारह 2,840,117
    पहली सफ़ाई का दिन, बाद में नया सेट 3,188,234
    पाँच दिन बाद वही सेट 2,739,044
    नौ दिन बाद वही सेट 3,229,041
    अठारह दिन बाद वही सेट 3,198,953

    Block हुई queries का हिस्सा, Reporting → Unbound DNS से:

    अवधि Queries Blocked
    पहली सफ़ाई का दिन, उसी दिन पढ़ा गया दर्ज नहीं 12.9 प्रतिशत
    लगभग 38 घंटे की अवधि, बाद में पढ़ी गई 110,248 8,600 (7.80 प्रतिशत)

    दोनों प्रतिशत अलग सूचियों, अलग दिनों और उस समय network जो भी कर रहा था, उसे कवर करते हैं। वे पहले और बाद की तुलना नहीं हैं।

    अब मैं क्या tick रखता हूँ

    मेरे router की settings में यह है:

    • Hagezi Pro++ (full)
    • TIF (full)
    • Gambling (full)
    • Fake, Pop-Up Ads, Badware Hoster और “Safesearch not supported”
    • OISD NSFW
    • URL से जोड़ी गई दो Hagezi सूचियाँ: encrypted-DNS servers और LG TV trackers
    • Abuse.ch ThreatFox, URL से, एक free key के साथ (नीचे)

    मैंने Hagezi के सुझाए Pro की जगह Pro++ चुना, device trackers के लिए, क्योंकि Pro++ वह जगह है जहाँ वे लगभग सारे trackers block करते हैं।

    इनमें से दो duplicate हैं। Hagezi की cheat sheet Fake और Pop-Up Ads को Pro++ के अंदर बताती है। Fake के लिए नाप भी यही कहती है, और उसे हटाया जा सकता है; इससे जो block होता है वह नहीं बदलता। Pop-Up Ads में, मेरी download की हुई सूचियों पर, तीन नाम हैं जो Pro++, TIF, Gambling, Hoster या Fake में से किसी में नहीं हैं; उसे हटाने पर वे तीन जाते हैं। मैंने ThreatFox या दोनों URL सूचियों की तुलना नहीं की। Fake और Pop-Up Ads दोनों अब भी tick हैं।

    ThreatFox download होना बंद हो गई थी और अब फिर download होती है। हर update ने “unable to download blocklist … and no cache available” लिखा था। OPNsense की built-in एंट्री ने उसके लिए जो address इस्तेमाल किया, वह “410 Gone” का जवाब देता है, और abuse.ch का export पेज host file देने से पहले Auth-Key माँगता है। 26.7 की एक बाद की release ने इसी कारण built-in एंट्री हटा दी और users को “URLs of Blocklists” की ओर भेजा। abuse.ch अपने authentication portal से key free देता है। मैंने सूची URL से जोड़ी, key को address में रखकर। abuse.ch का export पेज key URL में माँगता है, और OPNsense का downloader कोई headers नहीं भेजता। नीचे के steps address का रूप दिखाते हैं। जिस update ने इसे जोड़ा, उसने इसके लिए 28,889 लाइनों के साथ “blocklist download” लिखा, जिनमें 28,869 नाम थे, और कोई error नहीं; उस update में बाकी सूचियाँ cache से load हुईं। Router की अपनी load हुए नामों की गिनती के अनुसार, वह 2,765,172 से बढ़कर 2,782,246 हुई। इसलिए 28,869 में से 17,074 उस सटीक नाम से पहले load नहीं थे, और लगभग 11,800 थे। गिनती नामों की अक्षर-दर-अक्षर तुलना करती है, इसलिए जिस नाम के parent domain को कोई और सूची पहले से block करती है, वह भी नया गिना जाता है। Hagezi ThreatFox को source के रूप में नाम नहीं देते।

    Key password की तरह काम करती है। Router उसे अपनी configuration में रखता है, और हर update key समेत address को resolver log में लिखता है। उसे उन screenshots, shared logs, configuration backups और किसी भी remote log server से बाहर रखें जो आपके हाथ से निकल जाते हैं। अगर वह leak हो गई हो, तो उसी portal से नई key लें और address बदल दें।

    गहराई में: key के साथ ThreatFox जोड़ना

    शुरू करने से पहले। यह आपकी policy में एक सूची जोड़ता है। दस मिनट रखें। कुछ delete नहीं होता। इसे undo करने के लिए, उसी box से address हटाएँ और फिर apply करें।

    1. Browser में https://auth.abuse.ch खोलें, अगर account नहीं है तो बनाएँ, और एक Auth-Key लें। Key free है। उसे सिर्फ़ step 4 तक किसी text file में copy रखें, जहाँ आप उसे एक बार paste करते हैं, फिर वह file delete कर दें।
    2. Router में log in करें। Services पर click करें, फिर Unbound DNS, फिर Blocklists।
    3. अपनी policy की row के दाएँ सिरे पर pencil (Edit) पर click करें। Edit Blocklist नाम की एक window खुलती है।
    4. URLs of Blocklists के अंदर click करें और नीचे का address type करें, YOUR_KEY की जगह अपनी key के साथ और बिना किसी space के। Enter दबाएँ ताकि वह अपना एक अलग tag बन जाए (tag वह एक एंट्री है जो field में छोटे box के रूप में दिखती है):

      https://threatfox-api.abuse.ch/v2/files/exports/YOUR_KEY/hostfile.txt

      Key exports/ और /hostfile.txt के बीच बैठती है।

    5. Save पर click करें, फिर Apply। Router सूचियाँ फिर download करता है; एक-दो मिनट रखें।

    6. Services, Unbound DNS, Log File पर click करें, download खोजें, और severity box में Informational tick करें। आपको “blocklist download:” और ThreatFox address के लिए लाइनों की संख्या दिखनी चाहिए। अगर लाइन “unable to download” कहे, तो key और address में किसी फ़ालतू space की जाँच करें।
    7. वह screen share न करें: लाइन में आपकी key के साथ address दिखता है।
    गहराई में: Badware Hoster और URL से जोड़ी गई दो सूचियाँ

    Badware Hoster Hagezi की एक अलग सूची है, और उसकी 1,088 एंट्री में से 966 पहले से Pro++ में हैं। बाकी वे पूरे hosting providers block करती है जो threat feeds में बार-बार आते हैं। Hagezi चेताते हैं कि उन hosts पर मौजूद वैध साइटें उनके साथ block हो जाती हैं, और उन्हें unblock करना वे सूची चलाने वाले पर छोड़ते हैं।

    URL से जोड़ी गई दो सूचियाँ Hagezi की हैं, wildcard format में:

    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/doh.txt
    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/native.lgwebos.txt

    पहली encrypted-DNS servers को नाम से सूचीबद्ध करती है, devices को router को बायपास करने से रोकने का एक हिस्सा। दूसरी LG webOS के ad और tracking servers सूचीबद्ध करती है। हर एक की अपनी कहानी है, अलग पोस्टों के लिए।

    OPNsense 26.7 के built-in Hagezi tick-boxes Hagezi के mirror, hagezi-mirror.dnsbunker.org, से download करते हैं, जैसा log दिखाता है। Hagezi कहते हैं कि वह mirror लगभग हर चार से आठ घंटे में नई build प्रकाशित करता है; jsDelivr की copies दिन में एक बार update होती हैं।

    DNS क्या block नहीं कर सकता

    YouTube और Instagram के in-app ads उन्हीं domains से आते हैं जिनसे videos और posts आते हैं, इसलिए उन्हें नाम से block करने पर content भी block हो जाएगा। Hagezi का FAQ सामान्य बात कहता है: कुछ ads content वाले ही domains से load होते हैं, और browser में content blocker, या फ़ोन पर app-level blocker, वह परत है जो उन्हें पकड़ती है। मैंने in-app ads को स्वीकार कर लिया।

    DNS blocklist सिर्फ़ उन्हीं devices को filter करती है जो router से पूछते हैं; जिन devices का अपना encrypted या hard-coded DNS है, वे उसे बायपास कर जाते हैं। वह एक अलग पोस्ट है।

    यह कैसे किया गया

    Claude ने documentation और सूचियाँ पढ़ीं, उनकी तुलना की, और मेरे logged-in browser session के ज़रिए मेरा router पढ़ा: settings, resolver log और tester। क्या बदलना है, यह मैंने तय किया। Allowlist वाले session में router पर एकमात्र बदलाव allowlist का rewrite था।

    Model ने गलतियाँ कीं। bare नाम वाला allowlist fix पहले session से निकला, और एक session में उसने मुझे यह भी बताया कि रात का blocklist update Unbound का cache flush करता है। Router के log में दिखा कि update सूचियों को चल रहे Unbound में load करता है, restart के बिना। Manual कहती है कि blocklist settings apply करने से Unbound restart नहीं होता, और source नई सूची को चल रहे process में load करता है। Flush वाली setting सिर्फ़ तब लागू होती है जब Unbound रुकता है।

    Router पर logged-in session वाला model अपने आप में एक जोखिम है। जो resolver log वह पढ़ता है, उसमें ऐसे नाम हैं जिन्हें कोई भी website किसी device से lookup करवा सकती है, और कोई नाम model को दिशा देने के लिए लिखा text ले जा सकता है। Allowlist वाले session में मैंने उसे सिर्फ़ पढ़ने तक रखा, allowlist के बदलाव को छोड़कर। यह model को दिया गया निर्देश है, कोई control नहीं; read-only OPNsense user एक control होता। Resolver log में key समेत ThreatFox address भी है, इसलिए जो session log पढ़ता है वह key देख लेता है। अगर आप किसी model को वह log पढ़ने देते हैं, तो बाद में key बदल दें।

    पहले session में मैंने पाँच Unbound settings और एक cron job भी बदले। Router छहों को set दिखाता है।

    गहराई में: हर setting, और DNS over TLS को undo कैसे करें
    Setting (पेज) पहले बाद में
    Flush DNS Cache during reload (General) चालू बंद
    Prefetch Support (Advanced) बंद चालू
    Serve Expired Responses (Advanced) बंद चालू; TTL for Expired Responses 86,400 s
    Use System Nameservers (Query Forwarding) चालू बंद
    DNS over TLS forwarders कोई नहीं Cloudflare और Quad9
    Blocklist update job (System → Settings → Cron) दूसरे jobs के साथ साझा slot अपना अलग slot

    Prefetch लोकप्रिय एंट्री को उनके expire होने से पहले refresh करता है। Manual इसकी क़ीमत लगभग 10 प्रतिशत ज़्यादा DNS traffic बताती है।

    Serve Expired Responses device को इंतज़ार कराने की जगह cache से expired record के साथ जवाब देता है। जब यह चालू होता है, तो और fields दिखते हैं। “TTL for Expired Responses” सीमित करता है कि expiry के कितनी देर बाद तक पुराना जवाब दिया जा सकता है; मैंने 86,400 सेकंड रखे, जो manual के सुझाए 86,400 से 259,200 का निचला सिरा है।

    एक interaction जिसे मैंने test नहीं किया: cache flushing बंद और पुराने जवाब allowed होने पर, जिस नाम को कोई सूची नया block करती है, उसे Unbound के cache से कुछ देर तक जवाब मिलते रह सकते हैं। अगर कोई block तुरंत असर न करे, तो मैं सबसे पहले यही देखूँगा।

    Use System Nameservers. Manual कहती है कि Query Forwarding और DNS over TLS की किसी भी catch-all एंट्री से system nameservers को प्राथमिकता मिलती है। इसे बंद करने पर DNS over TLS की एंट्री queries ले जाती हैं। चारों एंट्री, Services → Unbound DNS → DNS over TLS के नीचे:

    Server IP Port Verify CN
    1.1.1.1 853 cloudflare-dns.com
    1.0.0.1 853 cloudflare-dns.com
    9.9.9.9 853 dns.quad9.net
    149.112.112.112 853 dns.quad9.net

    Router की अपनी queries, जो इन servers को जाती हैं, encrypted निकलती हैं। जो firewall rule LAN से port 853 को reject करता है, devices को अपना encrypted DNS इस्तेमाल करने से रोकने के लिए, वह इन्हें नहीं छूता, क्योंकि ये router से ही निकलती हैं।

    Update का समय एक अलग slot में चला गया ताकि update अब दूसरे scheduled jobs के समय पर न चले।

    DNS over TLS का बदलाव undo करने के लिए:

    शुरू करने से पहले। यह आपके router की DNS settings बदलता है और इसमें पाँच मिनट लगते हैं। बाकी बची settings से DNS चलता रहता है। पहले चारों एंट्री note कर लें (ऊपर की table); बदलाव को दोबारा लागू करने के लिए आपको वे चाहिए।

    1. Router का settings पेज खोलें और sign in करें। आपको Lobby पेज दिखना चाहिए।
    2. Services पर click करें, फिर Unbound DNS, फिर DNS over TLS। एक table में एंट्री सूचीबद्ध हैं।
    3. पहली row के दाएँ सिरे पर pencil (Edit) पर click करें। Edit server नाम की एक window खुलती है। Enabled का tick हटाएँ और Save पर click करें। बाकी हर row के लिए यही करें।
    4. उसी पेज के ऊपर Use System Nameservers पर tick करें। वही box Query Forwarding के नीचे भी दिखता है; यह एक ही setting है।
    5. पेज के नीचे Apply पर click करें। Unbound कुछ सेकंड में reload होता है।
    6. जाँचें: network के किसी device से कोई ऐसी website खोलें जो आपने आज नहीं खोली। वह load होनी चाहिए। अगर System, Settings, General में कोई nameservers नहीं हैं, तो Unbound forward करने की जगह root servers से खुद resolve करता है; अगर आप चाहते हैं कि आपके provider के servers इस्तेमाल हों, तो उन्हें वहाँ जोड़ें।
    7. बदलाव को दोबारा लागू करने के लिए, हर एंट्री पर फिर Enabled tick करें, Use System Nameservers का tick हटाएँ, और Apply पर click करें।

    स्रोत

    ఫిషింగ్ పేర్లను లోపలికి పంపిన సవరణ

    ఆంగ్ల మూలం నుండి అనువదించినది. కమాండ్లు, కోడ్, సాంకేతిక పదాలు ఆంగ్లంలోనే ఉంచాను.

    అక్టోబర్‌లో ఒక శనివారం నా రూటర్ DNS allowlistలో పాడైన నాలుగు ఎంట్రీలను సరిచేశాను. రెండు వారాలకు కొంచెం ఎక్కువ రోజుల తర్వాత, సరిచేసిన ఎంట్రీలు threat feedలోని కొన్ని పేర్లను లోపలికి పంపుతున్నాయని కనుగొన్నాను. ఆ పేర్లు నేను అనుమతించదలచిన సైట్లలా కనిపించేలా తయారుచేసినవి: ఒక చెల్లింపు సైట్ domain తర్వాత .https. మరియు సంబంధం లేని మరో domain, లేదా చుక్క ఉండాల్సిన చోట హైఫన్ ఉన్న ఒక షాప్ పేరు. నా రూటర్ సొంత tester వాటిని Pass చేసింది.

    అదే సాయంత్రం నా blocklistలను పద్దెనిమిది నుండి పదికి తగ్గించాను; మరుసటి రోజు ఒక LG TV list చేరి పదకొండు అయింది. వాటిలో ఏడింటిని మిగతా సెట్ ఇప్పటికే కవర్ చేస్తోంది. నేను ఉంచిన ఒక list, Abuse.ch ThreatFox, abuse.ch తన host fileను key ఉన్నవారికే ఇవ్వడం మొదలుపెట్టినప్పుడు download కావడం ఆగిపోయింది. దాని addressలో ఒక ఉచిత key పెట్టినప్పటి నుండి మళ్లీ download అవుతోంది. నా ఫోన్‌లో YouTube, Instagram లోపలి ప్రకటనలు మొత్తం సమయంలో వస్తూనే ఉన్నాయి; ఏ blocklist కూడా దాన్ని మార్చగలిగేది కాదు.

    ఆ తర్వాత allowlist ఎంట్రీలను తిరిగి రాశాను. ఈ పోస్ట్ రెండు శుభ్రతల గురించి: allowlist ఎంట్రీని OPNsense ఏం చేస్తుంది, మీది ఎలా తనిఖీ చేయాలి, ఒకదానిపై ఒకటి ఉన్న పద్దెనిమిది lists చివరికి ఏమి చేర్చాయి. ఈ పనిని Claudeతో రెండు సెషన్లలో చేశాను, ఒక్కో శుభ్రతకు ఒకటి; ThreatFox key మూడో సెషన్‌లో వేశాను. అది నా browser ద్వారా రూటర్‌ను చదివింది; రూటర్‌పై ప్రతి మార్పునూ నేనే ఆమోదించాలి. bare name (యాంకర్ లేని సాదా పేరు) సవరణను నేనే ఆమోదించాను, కాబట్టి ఆ పొరపాటు విషయంలో ఆమోదం రక్షణ కాలేదు.

    కమాండ్ లైన్ మీకు కొత్తా? boxes ను ఎలా చదవాలి

    PS> అంటే: Windowsలో PowerShell లో దీన్ని type చేయండి (Start menu → powershell అని type చేయండి → Enter). $ అంటే: Linux లేదా Mac లోని terminal లో, లేదా Pi లో ssh తో login అయిన తర్వాత దీన్ని type చేయండి. $ లేదా PS> ను మీరు type చేయవద్దు.

    $ లేదా PS> తో మొదలయ్యే ప్రతి line ఒక కమాండ్. ఆ line ను మాత్రమే copy చేయడానికి ఆ $ ను click చేసి, paste చేసి, Enter నొక్కి, తర్వాతి దానికి ముందు అది పూర్తయ్యే వరకు వేచి ఉండండి. పైన Copy button ఉన్న box ఒక కమాండ్ (లేదా ఒక ఫైల్) కలిగి ఉంటుంది, కాబట్టి దాన్ని మొత్తం copy చేయండి. చుక్కల అంచు ఉన్న box మీకు తిరిగి కనిపించాల్సినదాన్ని చూపుతుంది; దాన్ని మీరు type చేయరు.

    Allowlist

    నా blocklist policy allowlistలో 26 ఎంట్రీలు ఉన్నాయి. మొదటి శుభ్రత రోజున వాటిలో నాలుగు పాడైనట్లు కనిపించాయి. మూడింటిని browser address bar నుండి పూర్తి address రూపంలో, అంటే https://example.org/ రూపంలో, paste చేశారు. నాలుగో దానిలో పేరు మొదటి అక్షరానికి ముందు ఒక space ఉంది. ఆ నాలుగింటినీ example.in వంటి bare namesతో మార్చాను. మిగతా 22 ఎలా రాసి ఉన్నాయో నేను చూడలేదు, రూటర్ configuration history ఇప్పుడు తనిఖీ చేసేంత వెనక్కి వెళ్లదు. అవి రూటర్ సొంత Allow button రాసినట్లు bare names అయి ఉంటే, నా సవరణకు ముందే ఈ లోపం ఉంది, సవరణ దాన్ని ఇంతవరకు దేనికీ సరిపోని మూడు ఎంట్రీలకూ విస్తరించింది.

    రూటర్ log ఐదో ఎంట్రీని చూపింది, *.ntp.org అని రాసినది, దాన్ని తర్వాత తొలగించాను. ప్రతి nightly update దాని గురించి “skip invalid whitelist exclude pattern” అని log చేసింది. Python regular expressionsలో ప్రారంభంలో * చెల్లదు, కాబట్టి రూటర్ ప్రతి రాత్రి ఆ ఎంట్రీని వదిలేసింది, ఆ విషయం log లో మాత్రమే చెప్పింది. ఉద్దేశించినది చేసే రూపం (.*\.)?ntp\.org\.?$.

    తర్వాత Claude, OPNsense 26.7లో allowlistను వర్తింపజేసే codeను చదివింది. ప్రారంభంలోని space ఏ హానీ చేయలేదు: code ప్రతి ఎంట్రీ నుండి spaces తొలగిస్తుంది. సమస్య bare names.

    OPNsense ప్రతి ఎంట్రీని regular expressionగా తీసుకుంటుంది, case-insensitiveగా, మరియు ఒక device అడిగే పేరు ప్రారంభంతో సరిపోల్చుతుంది. ఎంట్రీ పేరు చివరకు కట్టబడి ఉండదు, escape చేయని చుక్క ఏ అక్షరానికైనా సరిపోతుంది. కాబట్టి bare example.com, example.comను అనుమతిస్తుంది కానీ www.example.comను కాదు. అది ఆ అక్షరాలతో మొదలయ్యే ఏ పేరునైనా కూడా అనుమతిస్తుంది, ప్రతి చుక్క స్థానంలో ఏ అక్షరమున్నా: example.com.evil.net, example-com.evil.net, example.community.

    Threat feedలో సరిగ్గా అలాంటి ఆకృతి గల పేర్లు ఉన్నాయి: ప్రసిద్ధ సైట్ పేరు తర్వాత .https. మరియు సంబంధం లేని domain, లేదా చుక్కకు బదులు హైఫన్ ఉన్న సైట్ పేరు. ఈ పరిశీలన కోసం నేను download చేసిన feedలో, నా 26 ఎంట్రీలలో ఏడు అలాంటి 43 పేర్లకు సరిపోయాయి; ఒక ఎంట్రీ 20కి సరిపోయింది. నా రూటర్ testerలో, నేను ప్రయత్నించిన అలాంటి ఐదు పేర్లూ Pass అయ్యాయి, అదే list ఎంట్రీ బ్లాక్ చేసే, ముందు www. ఉన్న అదే పేరు మాత్రం blocked అయింది. అనుమతించిన సైట్ పేరుతో, threat feed బ్లాక్ చేసే domainతో నేను తయారుచేసిన పేరు కూడా Pass అయింది. matching code ప్రకారం, ప్రతి bare ఎంట్రీ, దానితో మొదలయ్యే ఏ పేరునైనా అనుమతిస్తుంది, ఏదైనా list ఆ పేరును బ్లాక్ చేసినా, చేయకపోయినా.

    OPNsense సొంత Allow button, Reporting → Unbound DNSలో, bare nameను అదే విధంగా save చేస్తుంది. అక్కడి నుండి చేర్చిన ఎంట్రీలు కూడా అదే విధంగా పనిచేస్తాయి.

    సవరణ ఏమిటంటే, ఖచ్చితమైన పేరును రెండు చివరలా anchor చేసి అనుమతించడం:

    ^www\.example\.com\.?$

    backslashలు చుక్కలను అక్షరార్థంగా చేస్తాయి, $ pattern ను పేరు చివరికి కట్టేస్తుంది. \.? అనేది code తనిఖీ చేసే రెండు మార్గాలలో ఒక దానిలో పేరుకు ఉండే చివరి చుక్కను అనుమతిస్తుంది (లోతైన పరిశీలన చూడండి). ^ code ఇప్పటికే చేసే పనినే పునరావృతం చేస్తుంది, కాబట్టి దాన్ని వదిలేసినా పనిచేస్తుంది; pattern ఎక్కడైనా ఒకేలా చదవబడేలా నేను దాన్ని ఉంచుతాను. మీ ఎంట్రీలను తనిఖీ చేసి తిరిగి రాసే దశలు “మీది ఎలా తనిఖీ చేయాలి” కింద ఉన్న లోతైన పరిశీలనలలో ఉన్నాయి.

    ఒక domainను దాని అన్ని subdomainలతో అనుమతించాలంటే (.*\.)?example\.com\.?$ పనిచేస్తుంది, కానీ list ఉద్దేశపూర్వకంగా ఆ domain కింద బ్లాక్ చేసే hostలను కూడా అది అనుమతిస్తుంది. నా ఎంట్రీలలో ఒకదానిపై, Pro++ ఆ domain కింద advertising, sponsored-ads వంటి పేర్లున్న ఐదు hostలను బ్లాక్ చేస్తుంది, domainను గానీ దాని www. పేరును గానీ బ్లాక్ చేయదు. subdomain అంతటికీ allow ఇస్తే అవి తిరిగి లోపలికి వస్తాయి.

    OPNsense సొంత parsing code, matching call ను కొన్ని పేర్లపై నడిపాను:

    Allowlist ఎంట్రీ అడిగిన పేరు అనుమతి?
    https://example.org/ example.org కాదు
    example.in example.in అవును
    example.in www.example.in కాదు
    example.in example.in.example.net అవును
    example.in example-info.de అవును
    ^www\.example\.in\.?$ www.example.in అవును
    ^www\.example\.in\.?$ advertising.example.in కాదు
    ^www\.example\.in\.?$ www.example.in.example.net కాదు

    ఆ 26 ఎంట్రీలన్నీ ఆ ఖచ్చితమైన, anchor చేసిన రూపంలో తిరిగి రాసి మార్పును apply చేశాను. tester ద్వారా Pass అయిన ప్రతి పేరు ఆ తర్వాత blocked అయింది. తన పేరే ఒక list లో ఉన్న ఒక్క ఎంట్రీ మాత్రం ఉద్దేశించినట్లే ఇప్పటికీ Pass అవుతోంది. మిగతా 25 లోని ఖచ్చితమైన పేర్లను ఏ list బ్లాక్ చేయలేదు, కాబట్టి అవి తాము రాసిన పేర్లకు ఏ పనీ చేయలేదు; వాటి ఏకైక ప్రభావం prefix లోపమే. వాటిని తొలగించకుండా anchor చేశాను, ఎందుకంటే ఒక list తర్వాత ఒక పేరును చేర్చవచ్చు. మీకూ అలాంటి ఎంట్రీలు ఉంటే, వాటిని తొలగించడం కూడా సముచితమైన ఎంపికే.

    లోతైన పరిశీలన: code, మరియు నా పరీక్షలు ఏమి చూపిస్తాయి, ఏమి చూపవు

    blocklist dialogలో ఒకే “Allowlist Domains” field ఉంది. దాని help text ప్రకారం అది domains తీసుకుంటుంది, regular expressions వాడవచ్చు, మరియు ఆ policyలోని matchesకు మాత్రమే వర్తిస్తుంది. 26.7లో:

    • src/opnsense/service/templates/OPNsense/Unbound/core/blocklists.conf ఆ fieldను excludes.patternsగా, commaలతో వేరు చేసి రాస్తుంది.
    • src/opnsense/scripts/unbound/blocklists/default_bl.py ఆ విలువను commaల వద్ద విభజిస్తుంది, ప్రతి ఎంట్రీపై strip() పిలుస్తుంది, regular expressionగా compile కాని ఎంట్రీని వదిలేస్తుంది (“skip invalid” log line తో), మిగతావాటిని, built-in .*localhost$ ఎంట్రీతో కలిపి, | తో ఒకే patternగా కలుపుతుంది.
    • src/opnsense/scripts/unbound-dnsbl/lib/__init__.py ఆ patternను case-insensitiveగా compile చేస్తుంది.
    • src/opnsense/scripts/unbound-dnsbl/lib/dnsbl.py blocklist hit తర్వాత దాన్ని r.match(domain) తో పరీక్షిస్తుంది. Python match పేరు ప్రారంభం వద్ద anchor అవుతుంది, చివర కాదు. పేరును ముందుగా lower-case చేసి, దాని చివరి చుక్కను తొలగిస్తారు.
    • CNAME target blocked అయినప్పుడు, అదే function అసలు పేరును కూడా (r.match(orig)) పరీక్షిస్తుంది, కాబట్టి allowlist చేసిన పేరు blocked alias ద్వారా కూడా resolve అవుతుంది. ఆ అసలు పేరు Unbound నుండి చివరి చుక్కతో, www.example.com. గా వస్తుంది, శుభ్రం చేయబడదు. చివర కేవలం $ ఉన్న pattern అక్కడ విఫలమవుతుంది; \.?$ రెండు మార్గాల్లోనూ Pass అవుతుంది.
    • src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php, updateBlocklistAction, Reportingలోని Allow button పిలిచేది. అది చివరి చుక్కను తొలగించి (rtrim($domain, '.')), పేరును ఉన్నది ఉన్నట్లు, escape చేయకుండా, anchor చేయకుండా save చేస్తుంది.

    OPNsense manual allowlist ఎంట్రీని, pattern ఉన్న blocklist items ను మినహాయించేదిగా వివరిస్తుంది. code ప్రారంభంలో మరింత ఇరుకుగా ఉంది, ఎందుకంటే మొదటి అక్షరం నుండి మాత్రమే సరిపోల్చుతుంది, చివర మాత్రం అంతే తెరిచి ఉంది. ఏ అర్థం తీసుకున్నా, చివరను anchor చేయడం ఎంట్రీ రాసేవారికే వదిలేశారు. అవే ఐదు ఫైళ్లను 26.7 తాజా release లో, development branch లో పోల్చాను: allowlist code మారలేదు.

    పరీక్షలు చూపేవి: 26.7 source లోని parser, matching calls ఈ ఎంట్రీలను ఎలా చూస్తాయో, రూటర్ బయట నడిపినవి, CNAME కేసును చివరి చుక్క చేర్చి simulate చేసినవి; మరియు నా రూటర్‌లో, నేను ప్రయత్నించిన ప్రతి phishing పేరుకు tester తీర్పు, allowlist చేసిన పేరుతో మొదలుకాకపోవడమే తేడా అయిన control తో పాటు, rewrite కు ముందు, తర్వాత. tester రూటర్ load చేసిన lists పై అదే matching code నడుపుతుంది, కానీ direct lookup కు మాత్రమే, కాబట్టి CNAME మార్గాన్ని అది చూపలేదు. 43 పేర్ల లెక్క రూటర్ నుండి కాదు, ప్రచురించిన lists నుండి వచ్చింది; ఆ 43 అన్నీ TIFలో ఉన్నాయి.

    మీది ఎలా తనిఖీ చేయాలి

    నాలుగు తనిఖీలు, చివరిది తప్ప అన్నీ చదవడానికి మాత్రమే:

    1. resolver logలో download కాని lists కోసం, skip అయిన allowlist ఎంట్రీల కోసం చదవండి.
    2. blocklist testerలో, blocked కావలసిన ఒక పేరును, Pass కావలసిన ఒక పేరును ప్రయత్నించి, lists load అయ్యాయో చూడండి.
    3. ప్రతి allowlist ఎంట్రీకి, ఆ ఎంట్రీ తర్వాత మీ lists బ్లాక్ చేసే domain చేర్చిన పేరును test చేయండి, తర్వాత ముందు www. ఉన్న అదే పేరును. మొదటిది Pass అయి రెండోది blocked అయితే, ఆ ఎంట్రీ తెరిచి ఉంది.
    4. తెరిచి ఉన్న ప్రతి ఎంట్రీని anchor చేసి తిరిగి రాయండి, apply చేసి, మళ్లీ test చేయండి.

    1 నుండి 3 వరకు తనిఖీల click-by-click దశలు, rewrite దశలు కింద ఉన్న రెండు లోతైన పరిశీలనలలో ఉన్నాయి. అవి sign-in పేజీ నుండి మొదలై, ప్రతి దశ ఏమి మారుస్తుందో చెబుతాయి.

    లోతైన పరిశీలన: దశలవారీగా, మీ allowlist తనిఖీ

    మొదలుపెట్టే ముందు. మీ నెట్‌వర్క్‌లోని ఒక కంప్యూటర్‌లో browser, మరియు మీ రూటర్ settings పేజీ address, login కావాలి. 1 నుండి 8 దశలు చదవడం మాత్రమే: రూటర్‌లో ఏదీ మార్చవు, కాబట్టి ఎక్కడ ఆపినా ఏదీ వెనక్కి తీసుకోనక్కర్లేదు. సుమారు పది నిమిషాలు పడుతుంది, దానికి తోడు ప్రతి test కు సుమారు పది సెకన్లు, ఎందుకంటే tester ప్రతిసారీ మొత్తం blocklistను load చేస్తుంది.

    1. browser తెరిచి, OPNsense లోకి sign in అవడానికి మీరు వాడే addressను type చేయండి. Sign in అవండి. Lobby page కనిపించాలి. page load కాకపోతే, కంప్యూటర్ మీ ఇంటి నెట్‌వర్క్‌లో ఉందో లేదో, రూటర్‌కు ఏ ఇతర మార్పు కోసమైనా వాడే అదే addressను వాడారో లేదో చూడండి.
    2. ఎడమవైపు menuలో Services, తర్వాత Unbound DNS, తర్వాత Log File click చేయండి. Date, Severity, Process, Line columns ఉన్న table కనిపించాలి. దానికి పైన search box, severity box (Warning కు set చేసి), time box (Last day కు set చేసి) ఉన్నాయి.
    3. search boxను click చేసి, blocklist అని type చేసి Enter నొక్కండి. రెండు రకాల lines ముఖ్యం. “unable to download blocklist” అంటే ఒక list load కాలేదు, అది ఏమీ చేర్చదు. “skip invalid whitelist exclude pattern” అంటే OPNsense ఒక allowlist ఎంట్రీని వదిలేసింది. table ఖాళీగా ఉంటే, గత ఒక రోజులో Warning స్థాయిలో ఏదీ log కాలేదు. “blocklist loaded” lines చూడటానికి severity boxను తెరిచి Informational ను కూడా tick చేయండి; ఇంకా వెనక్కి చూడటానికి time boxను తెరవండి.
    4. అదే menuలో Blocklists click చేసి, తర్వాత పేజీ పైన ఉన్న Tester tab click చేయండి. Domain box, Source box, Test button కనిపించాలి. Sourceను ఖాళీగా వదిలేయండి; అప్పుడు test రూటర్ స్వయంగా అడిగినట్లు నడుస్తుంది. Source ఒక device address తీసుకుంటుంది, కొన్ని devicesకు మాత్రమే వర్తించే policy మీకు ఉంటేనే అది అవసరం.
    5. Domain లో googleads.g.doubleclick.net type చేసి Test click చేయండి. సుమారు పది సెకన్లు వేచి ఉండండి. ఫలితం Block అయి ఉండాలి. తర్వాత www.youtube.com test చేయండి; అది Pass కావాలి. మొదటి పేరు Pass అయితే, ఏ list కూడా load కాలేదు, లేదా ఆ పేరు మీ సొంత allowlistలో ఉంది: 3వ దశకు వెళ్లి errors చదవండి, ఆ పేరును మీరు allowlist చేసి ఉంటే, మీ lists బ్లాక్ చేసే మరో పేరును ఎంచుకోండి. tester CNAMEలను అనుసరించదు. CNAME అంటే మరో పేరును చూపే పేరు; tester మీరు type చేసిన పేరును మాత్రమే తనిఖీ చేస్తుంది.
    6. Blocklists tab click చేయండి. మీ policy row కుడి చివర, పెన్సిల్ (Edit) click చేయండి. Edit Blocklist అనే window తెరుచుకుంటుంది. Allowlist Domains మీ ఎంట్రీలను, ఒక్కో tag గా చూపుతుంది. వాటిని చదివి, Cancel click చేయండి. ఏదీ save కాదు.
    7. ప్రతి ఎంట్రీకి, ఆ ఎంట్రీ తర్వాత మీ lists బ్లాక్ చేసే domain చేర్చిన పేరును test చేయండి. నా lists బ్లాక్ చేసే పేరు googleads.g.doubleclick.net, 5వ దశలోనిదే. మీ lists దాన్ని బ్లాక్ చేయకపోతే, అవి బ్లాక్ చేసే పేరును ఎంచుకోండి. కాబట్టి example.com ఎంట్రీకి, example.com.googleads.g.doubleclick.net type చేసి Test click చేయండి. తర్వాత ముందు www. ఉన్న అదే పేరును, www.example.com.googleads.g.doubleclick.net, test చేయండి. మీరు TIF load చేస్తే, బదులుగా ఆ list లోని ఒక పేరును వాడవచ్చు. ఇప్పటికే ^ తో మొదలై $ తో ముగిసే ఎంట్రీ anchor చేసినదే; దాన్ని వదిలేయండి.
    8. రెండు ఫలితాలను కలిపి చదవండి. మొదటిది Pass అయి రెండోది blocked అయితే, ఆ ఎంట్రీ తెరిచి ఉంది: దానితో మొదలయ్యే ప్రతి పేరునూ అది లోపలికి పంపుతుంది. దాన్ని anchor చేసి తిరిగి రాయండి. ఏ list బ్లాక్ చేయని పేరు allowlist ఏం చెప్పినా Pass అవుతుంది, కాబట్టి Pass ను లోపంగా చదివే ముందు, ఆ పేరు blocked అవుతుందని testerలో నిర్ధారించుకోండి.
    లోతైన పరిశీలన: దశలవారీగా, మీ allowlist తిరిగి రాయడం

    మొదలుపెట్టే ముందు. ఇది మీ రూటర్ filteringను మారుస్తుంది. పదిహేను నిమిషాలు పడుతుంది. ఇక్కడ పొరపాటు చాలావరకు, అనుమతించిన ఒక సైట్ load కాకపోవడంగా కనిపిస్తుంది. మీ ఇంటర్నెట్ మిగతా భాగం పనిచేస్తూనే ఉండాలి. రూటర్ మార్పును సుమారు ఒక నిమిషంలో apply చేస్తుంది (నా దానిపై 43 సెకన్లు), Unboundను restart చేయదు; నడుస్తున్న process లోకి lists load అవుతున్నట్లు log చూపుతుంది. 3వ దశ మీ పాత ఎంట్రీల కాపీని save చేస్తుంది, 8వ దశ వాటిని తిరిగి పెడుతుంది.

    1. రూటర్ settings పేజీ తెరిచి sign in అవండి. Services, తర్వాత Unbound DNS, తర్వాత Blocklists click చేయండి.
    2. మీ policy row కుడి చివర, పెన్సిల్ (Edit) click చేయండి. Edit Blocklist window తెరుచుకుంటుంది. Allowlist Domains కింద, box కింద ఉన్న చిన్న link Text click చేయండి. tags ఒక్కో line కు ఒక ఎంట్రీ ఉన్న సాదా boxగా మారతాయి, Back link కనిపిస్తుంది. మీకు ఒకటికంటే ఎక్కువ policy ఉంటే, ప్రతిదానికి దాని సొంత allowlist ఉంటుంది; ప్రతిదానికీ ఇలా చేయండి.
    3. undo కోసం ఒక కాపీ తయారుచేయండి. box లోపల click చేసి, Ctrl + A, తర్వాత Ctrl + C నొక్కండి. Notepad తెరిచి (Start menu, notepad అని type చేసి, Enter నొక్కండి), Ctrl + V నొక్కి, ఫైల్‌ను allowlist-before.txt పేరుతో మీకు మళ్లీ దొరికే ఫోల్డర్‌లో save చేయండి. ఫైల్‌లో ఒక్కో line కు ఒక ఎంట్రీ ఉండాలి.
    4. box లోని ప్రతి line ను తిరిగి రాయండి. ఇది సాదా పేర్ల కోసం; ఇప్పటికే pattern అయిన ఎంట్రీ, అంటే (.*\.)? ఉన్నది, అలాగే ఉంటుంది. మీ devices అడిగే ఖచ్చితమైన పేరును రాయండి. ప్రతి చుక్క ముందు \, మొదట ^, చివర \.?$ పెట్టండి:

      • example.in అనేది ^example\.in\.?$ అవుతుంది
      • www.example.com అనేది ^www\.example\.com\.?$ అవుతుంది

      ప్రతి line కు ఒక ఎంట్రీ ఉంచండి, spaces లేకుండా, commas లేకుండా. www. ఉన్న పేరు, అది లేని అదే పేరు రెండు వేర్వేరు పేర్లు, రెండు lines కావాలి. device ఏది అడుగుతుందో మీకు తెలియకపోతే, Reporting, Unbound DNS లో చూడండి, లేదా రెండూ list లో పెట్టండి.

    5. Back click చేయండి. lines tags గా తిరిగి వస్తాయి. ప్రతి tag కొత్త రూపంలో ఉందో చూడండి. Save click చేయండి. window మూసుకుంటుంది.

    6. table కింద ఉన్న నారింజ రంగు button Apply click చేయండి. సుమారు ఒక నిమిషం వేచి ఉండండి.
    7. ఫలితాన్ని తనిఖీ చేయండి. Services, Unbound DNS, Log File తెరిచి, blocklist కోసం search చేసి, severity boxలో Informational tick చేయండి. “updating blocklist”, తర్వాత “blocklist loaded. length is” మరియు ఒక సంఖ్య కనిపించాలి, “skip invalid” line ఉండకూడదు. తర్వాత పైన చెప్పిన tester దశలను మళ్లీ చేయండి: lookalike పేర్లు ఇప్పుడు Block అవ్వాలి. ఒక list బ్లాక్ చేసే పేరును అనుమతించే ఎంట్రీ (నా దానిలో, ఒక Google ad host కోసం ఉన్నది) ఇప్పటికీ Pass అవ్వాలి.
    8. మార్పు తర్వాత ఒక సైట్ load కావడం ఆగితే, దాన్ని undo చేయండి. Notepadలో allowlist-before.txt తెరిచి, Ctrl + A, తర్వాత Ctrl + C నొక్కండి. రూటర్‌లో 1, 2 దశలను మళ్లీ చేసి, box లోపల click చేసి, Ctrl + A, తర్వాత Ctrl + V నొక్కి పాత ఎంట్రీలను కొత్తవాటిపై paste చేసి, Back, Save, Apply click చేయండి. మీరు list చేయని పేరు అవసరమైన సైట్, ఆ ఖచ్చితమైన పేరును మీరు చేర్చే వరకు blocked గా ఉంటుంది.
    లోతైన పరిశీలన: కంప్యూటర్ నుండి allowlist మార్పును పరీక్షించడం

    మొదలుపెట్టే ముందు. ఇది రూటర్ ఉన్న నెట్‌వర్క్‌లోని Windows PC కోసం. ఇది రూటర్ DNSను ఒక పేరు అడుగుతుంది, PC సొంత DNS cacheను clear చేస్తుంది; ఇంకేదీ మార్చదు. రెండు నిమిషాలు పడుతుంది. Mac లేదా Linuxలో ఆలోచన అదే (nslookup name router-address), కానీ cache-clear కమాండ్ వేరుగా ఉంటుంది.

    1. Start menu click చేసి, powershell అని type చేసి Enter నొక్కండి. PS తో మొదలయ్యే prompt ఉన్న window తెరుచుకుంటుంది.
    2. రూటర్ addressను కనుక్కోండి. ఇది type చేసి Enter నొక్కండి:

      ipconfig

      మీరు వాడుతున్న adapter కింద Default Gateway కోసం చూడండి. ఆ address మీ రూటర్; కింది దశలు దాన్ని <router-ip> అంటాయి. మీ రూటర్ మరో రూటర్ వెనుక ఉంటే, default gateway ఆ ఇతర device కావచ్చు; మీ DNS blocklists నడిపే box address వాడండి. line ఖాళీగా ఉంటే, మీరు connect కాని adapter చూస్తున్నారు; తర్వాతి దాని వద్దకు scroll చేయండి.

    3. రూటర్‌లో Apply click చేసి ఒక నిమిషం వేచిన తర్వాత, PC cacheను clear చేయండి. Blocked answers PC cache లో ఒక గంట వరకు ఉంటాయి, కాబట్టి ఇది చేయకపోతే PC పాత answerను ఉంచుకోవచ్చు:

      ipconfig /flushdns
    4. <router-ip> స్థానంలో 2వ దశలోని addressను పెట్టి, రూటర్‌ను ఆ పేరు అడగండి. పేరు తర్వాత ఉన్న చివరి చుక్క Windows తన search suffixes ను ముందుగా ప్రయత్నించకుండా ఆపుతుంది:

      nslookup www.example.com. <router-ip>

      blocked పేరుకు 0.0.0.0 సమాధానం వస్తుంది, లేదా policyలో Return NXDOMAIN tick చేసి ఉంటే “Non-existent domain”. అనుమతించిన పేరుకు దాని నిజమైన address వస్తుంది. మొదటి రెండు lines మీ రూటర్‌ను చూపుతాయి; మిగతాది సమాధానం.

    పద్దెనిమిది lists చివరికి ఏమి చేర్చాయి

    రూటర్ resolver logలో, దాని మొదటి ఎంట్రీ నుండి మొదటి శుభ్రత వరకు, ప్రతి పూర్తి nightly update అదే పద్దెనిమిది lists ను load చేసేలా set చేసి ఉంది (వాటిలో ThreatFox కూడా, కింద చూడండి):

    • Hagezi Normal, దానికి తోడు Pro, Pro++, Ultimate Mini versions
    • Threat Intelligence Feeds (TIF) మూడు పరిమాణాలలోనూ: full, Medium, Mini
    • Gambling మూడు పరిమాణాలలోనూ
    • Fake, Pop-Up Ads, Badware Hoster, DynDNS, Anti Piracy, “Safesearch not supported”
    • OISD NSFW, Abuse.ch ThreatFox

    వీటిలో చాలావాటిని నిర్వహించే Hagezi, తన lists ను కలపడానికి తన FAQలో ఈ నియమాలు ఇస్తాడు:

    1. ఐదు Multi lists — Light, Normal, Pro, Pro++, Ultimate — ఒకదానిపై ఒకటి నిర్మితమై ఉంటాయి. ప్రతిదానిలో దాని కింది list ఉంటుంది. మీరు ఒకదాన్ని ఎంచుకోవాలి.
    2. పరిమాణం తగ్గించిన versions (Mini, మరియు TIF, Gambling కు Medium) వాటి full list కు ప్రత్యామ్నాయాలు. వాటిని full list పైన పెట్టరు.
    3. TIF మినహాయింపు. ఇది malware, cryptojacking, scams, spam, phishing లను కవర్ చేస్తుంది, మీరు ఎంచుకునే tier తో పాటు నడపడానికే ఉద్దేశించినది.

    Pro, Pro++, Ultimate, Gambling Minis ఎక్కువగా సందర్శించే domains lists లో కూడా ఉన్న పేర్లను మాత్రమే ఉంచుతాయి. TIF Mini, Gambling Mini Medium list నుండి కత్తిరించినవి. Minis ను పరిమిత మెమరీ ఉన్న devices లోని blockers కోసం తయారు చేసినవిగా Hagezi వివరిస్తాడు.

    లోతైన పరిశీలన: ఏ tier ఎవరికి, Ultimate ఖరీదు ఏమిటి

    సైట్లు పనిచేయకపోతే దాన్ని ఎవరు చూసుకుంటారో ఆ వ్యక్తికి Hagezi FAQ tiers ను జత చేస్తుంది:

    Tier ఎవరికి పనిచేయకపోయే ప్రమాదం (Hagezi రేటింగ్)
    Light పెద్ద lists ను తట్టుకోలేని blocker, లేదా Normal కూడా ఎక్కువైన సెట్టింగ్ కనిష్టం
    Normal ఎవరూ unblock చేయడానికి లేని, పర్యవేక్షణ లేని setups తక్కువ
    Pro ఎవరైనా unblock చేయగలిగే చోట; TIF తో కలిపి అతని default సిఫార్సు తక్కువ నుండి మధ్యస్థం
    Pro++ admin ఉన్న అనుభవజ్ఞులైన వినియోగదారులు మధ్యస్థం
    Ultimate admin అందుబాటులో ఉన్న, చాలా అనుభవజ్ఞులైన వినియోగదారులు ఎక్కువ

    ప్రతి tier లో native tracker lists వాటా కూడా ఉంటుంది: TVలు, ఫోన్లు, operating systems లో అంతర్నిర్మితంగా ఉన్న telemetry. Pro++ దాదాపు అన్నింటినీ బ్లాక్ చేస్తుంది; Ultimate అన్నింటినీ బ్లాక్ చేస్తుంది. Ultimate వల్ల కలిగే నష్టాలను README జాబితా చేస్తుంది: కొన్ని Facebook, Messenger functions, avatars, video effects వంటి WhatsApp అదనపు సౌకర్యాలు, Windows Spotlight, Xbox achievement history, మరియు కొన్ని సైట్లు ఆధారపడే location trackers, వీటివల్ల తప్పు regional settings, ఎక్కువ CAPTCHAs రావచ్చు.

    నా సెట్ మొదటి రెండు నియమాలను ఉల్లంఘించింది. ఈ పరిశీలన కోసం lists ను ఒకసారి download చేసి, ఒక list లోని ఏ ఎంట్రీలను మరో list ఇప్పటికే బ్లాక్ చేస్తోందో చూడటానికి వాటిని పేరు పేరుగా పోల్చాను. రూటర్ ఇంతకుముందు load చేసిన కాపీలు నా దగ్గర లేవు, ThreatFox ను నేను కొలవలేదు, కాబట్టి పదిహేడు lists ను కొలిచాను.

    ఆ పదిహేడింటిలో ఏడు, ప్రతి list లోని ఒక్క marker ఎంట్రీ మినహా, మిగతా సెట్ ద్వారా కవర్ అయ్యాయి: Pro Mini, Pro++ Mini, TIF Medium, TIF Mini, Gambling Medium, Gambling Mini, Fake. ఆ ఏడింటినీ కలిపి తొలగిస్తే, TIF Medium, Mini లో ఉండి full TIF లో లేని 15 పేర్లు పోయేవి. Pop-Up Ads తన 48,277 పేర్లలో 37 ను మిగతా సెట్‌కు చేర్చింది (Pro++ ఒక్కదానితో పోలిస్తే అది మూడింటిని చేర్చుతుంది, కింద చూడండి). DynDNS, Anti Piracy భిన్నమైనవి: ఆ lists లో సెట్‌లోని మరే list లో లేని సుమారు 1,200, సుమారు 55,000 పేర్లు ఉన్నాయి, వాటిని duplicates గా కాక, నా ఎంపికతో తొలగించాను.

    ఆ నాలుగు tier lists కలిసి 233,710 పేర్లు కలిగి ఉన్నాయి, అవన్నీ Ultimate లో ఉన్నాయి, Hagezi నాలుగు marker ఎంట్రీలు తప్ప. Pro++ ఒక్కదానితో పోలిస్తే, అవి 31,411 Pro++ ఎంట్రీలను కోల్పోయాయి, అవి ఎక్కువగా సందర్శించే lists లో లేనివి. వాటి స్థానంలో Ultimate మాత్రమే బ్లాక్ చేసే 25,040 ఎంట్రీలను (Ultimate Mini marker తో 25,041) అవి కలిగి ఉన్నాయి, అన్నీ ఎక్కువగా సందర్శించే lists నుండి. Hagezi Ultimate పనిచేయకపోయే ప్రమాదాన్ని “ఎక్కువ” అని రేట్ చేస్తాడు. వాటివల్ల కలిగిన అంతరాయాల రికార్డు నా దగ్గర లేదు, దాని కోసం నేను పరీక్షించనూ లేదు, కానీ Hagezi రేటింగ్ ప్రకారం ఆ మిశ్రమం Ultimate ప్రమాదాన్ని తీసుకుంది, Pro++ కవరేజీని కోల్పోయింది.

    లోతైన పరిశీలన: నేను ఎలా కొలిచాను, సాదా పోలిక ఎందుకు తప్పు ఫలితం ఇస్తుంది

    OPNsense Hagezi wildcard formatను వాడుతుంది, అందులో *.example.com వంటి line example.com ను, దాని కింది ప్రతి పేరును బ్లాక్ చేస్తుంది. కాబట్టి list A లోని ఎంట్రీ, list B లో ఆ ఎంట్రీ లేదా దాని parent domains ఏవైనా ఉంటే, B ద్వారా ఇప్పటికే blocked అయినట్లే.

    సాదా text పోలిక దాన్ని గుర్తించదు. comm Ultimate Mini లో “లేవు” అని 3,294 Pro++ Mini ఎంట్రీలను చూపిస్తుంది. వాటిలో ఒకటి తప్ప అన్నీ కవర్ అయ్యాయి, ఎందుకంటే Ultimate Mini బదులుగా parent domain ను బ్లాక్ చేస్తుంది. Adobe tracking domain అయిన omtrdc.net మొత్తానికి దానికి ఒకే line ఉంది, Pro++ Mini దాని 998 hosts ను ఒక్కొక్కటిగా జాబితా చేస్తుంది. మిగిలిన ఒకటి Hagezi marker ఎంట్రీ, కింద వివరించాను.

    అదే విధంగా కొలిచిన నాలుగు tier lists:

    Normal + Pro Mini + Pro++ Mini + Ultimate Mini
    ప్రత్యేక పేర్లు 233,710
    వాటిలో, Ultimate లో కూడా ఉన్నవి 4 తప్ప అన్నీ (Hagezi marker ఎంట్రీలు)
    మిశ్రమంలో లేని Pro++ ఎంట్రీలు 223,551 లో 31,411
    మిశ్రమంలోని, Ultimate మాత్రమే బ్లాక్ చేసే పేర్లు 25,040

    నేను వాడిన తనిఖీ parent domains ను పైకి నడుస్తూ చూస్తుంది. ఇది Python 3 script, Python తప్ప ఇన్‌స్టాల్ చేయాల్సినదేదీ లేదు. script మొదట ఉంది; దాన్ని save చేసి నడపడానికి దశలు ఆ తర్వాత ఉన్నాయి.

    #!/usr/bin/env python3
    """hagezi_overlap.py - how much of blocklist A is already blocked by blocklist B.
    
    Reads two Hagezi lists in the wildcard format (the /wildcard/ files, the format
    OPNsense uses). A line "*.example.com" blocks example.com and every name under
    it, so an entry of A counts as covered when the entry itself, or one of its
    parent domains, is in B. A plain text comparison (comm, diff) misses that and
    reports too many differences.
    
    Usage:  python3 hagezi_overlap.py A.txt B.txt
    Author: Vivek Sanghi. Licence: CC BY-NC-SA 4.0, as the blog.
    """
    import re
    import sys
    
    WILDCARD = re.compile(r"^\*\.[a-z0-9_-]+(\.[a-z0-9_-]+)+$")
    
    
    def load(path):
        names = set()
        try:
            f = open(path, encoding="utf-8-sig")
        except OSError as e:
            sys.exit(f"{path}: cannot open ({e.strerror})")
        with f:
            for number, line in enumerate(f, 1):
                line = line.strip().lower()
                if not line or line.startswith("#"):
                    continue
                if not WILDCARD.match(line):
                    sys.exit(f"{path}, line {number}: not a wildcard-format line "
                             "('*.example.com'). Download the /wildcard/ version of the list.")
                names.add(line[2:])
        if not names:
            sys.exit(f"{path}: no entries found; check the download")
        return names
    
    
    def covered(name, blocked):
        while True:
            if name in blocked:
                return True
            if "." not in name:
                return False
            name = name.split(".", 1)[1]
    
    
    def main():
        if len(sys.argv) != 3:
            sys.exit("usage: hagezi_overlap.py A.txt B.txt")
        a, b = load(sys.argv[1]), load(sys.argv[2])
        missing = sorted(n for n in a if not covered(n, b))
        print(f"{sys.argv[1]}: {len(a):,} entries; {len(a) - len(missing):,} already "
              f"blocked by {sys.argv[2]}; {len(missing):,} not")
        for n in missing[:10]:
            print(f"  not covered: {n}")
        if len(missing) > 10:
            print(f"  ... and {len(missing) - 10:,} more")
    
    
    if __name__ == "__main__":
        main()
    

    మొదలుపెట్టే ముందు. ఇది Windows PC కోసం. మీకు Python 3 కావాలి (3వ దశ తనిఖీ చేస్తుంది). ఈ దశలు మీ user folder లో ఒక ఫోల్డర్ సృష్టిస్తాయి, అందులో కొన్ని megabytes ఉన్న రెండు list ఫైళ్లను download చేసి, వాటిని చదువుతాయి; ఇంకేదీ మార్చవు. పది నిమిషాలు పడుతుంది. Undo చేయడానికి, File Explorer లో ఆ ఫోల్డర్‌ను delete చేయండి. Mac లేదా Linuxలో Terminal వాడండి, python3 వాడండి (py బదులు), curl వాడండి (curl.exe బదులు).

    1. Start menu click చేసి, powershell అని type చేసి Enter నొక్కండి. PS తో మొదలయ్యే prompt ఉన్న window తెరుచుకుంటుంది.
    2. ఒక ఫోల్డర్ చేసి దానిలోకి వెళ్లండి. ప్రతి line కు కొంత సమయం పడుతుంది; వాటిని ఒక్కొక్కటిగా నడపండి:

      mkdir hagezi-check
      cd hagezi-check

      prompt ఇప్పుడు hagezi-check తో ముగియాలి. మొదటి line ఆ ఫోల్డర్ ఇప్పటికే ఉందని చెబితే, మరో పేరు ఎంచుకుని రెండు lines లోనూ వాడండి.

    3. Python ఇన్‌స్టాల్ అయి ఉందో తనిఖీ చేయండి:

      py --version

      Python 3.12.4 వంటి line కనిపించాలి. PowerShell py ను గుర్తించలేదని చెబితే, python.org నుండి Python 3 ను ఇన్‌స్టాల్ చేయండి (installer లో “Add python.exe to PATH” tick చేయండి), PowerShell మూసి 1వ దశ నుండి మళ్లీ మొదలుపెట్టండి.

    4. script ఫైల్ సృష్టించండి. ఇది Notepad ను తెరుస్తుంది:

      notepad hagezi_overlap.py

      Notepad కొత్త ఫైల్ సృష్టించాలా అని అడుగుతుంది; Yes click చేయండి. పై box లోని script ను paste చేయండి (box లో Copy click చేసి, Notepad లో Ctrl + V), Ctrl + S నొక్కి, Notepad మూసివేయండి. Notepad అడగకుండా తెరుచుకుంటే, File, Save as తో save చేయండి, ఫైల్ పేరుగా కొటేషన్ మార్కుల్లో hagezi_overlap.py type చేసి, ఫోల్డర్ hagezi-check అని చూసుకుని, Save click చేయండి.

    5. రెండు lists ను ఫోల్డర్‌లోకి download చేయండి. Windowsలో, PowerShell లో curl.exe type చేయండి, curl కాదు. lines ను ఒక్కొక్కటిగా నడపండి:

      curl.exe -o pro.plus.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/pro.plus.mini.txt
      curl.exe -o ultimate.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/ultimate.mini.txt

      ప్రతిదానికి కొన్ని సెకన్లు పడుతుంది, progress table ను చూపుతుంది. ఒక line error తో ముగిస్తే, connection ను చూసి ఆ line ను మళ్లీ నడపండి.

    6. తనిఖీని నడపండి:

      py hagezi_overlap.py pro.plus.mini.txt ultimate.mini.txt
    7. ఈ పరిశీలన కోసం నేను download చేసిన lists పై ఇది ఇలా print చేసింది:

      pro.plus.mini.txt: 98,704 entries; 98,703 already blocked by ultimate.mini.txt; 1 not
        not covered: h4g3z1-pro-plus-mini.web.app

      lists రోజూ మారుతాయి కాబట్టి మీ సంఖ్యలు వేరుగా ఉంటాయి. సంఖ్యలకు బదులు ఒక సందేశం కనిపిస్తే, script ఉద్దేశపూర్వకంగా ఆగింది: ఆ సందేశాన్ని చదవండి, అది ఫైల్‌ను, line ను పేర్కొంటుంది.

    ప్రతి పోలికలో మిగిలిపోయే ఒక పేరు, Hagezi ప్రతి list లో ఉంచే marker (h4g3z1-<list>.web.app), ఏ list load అయిందో తెలుసుకోవడానికి. download విఫలమైతే, లేదా ఫైల్ మరో format లో ఉంటే, script సంఖ్యను చెప్పకుండా ఆగి ఆ విషయం చెబుతుంది.

    అవే lists పై అది ఇంకా ఇచ్చినవి:

    List A List B B ద్వారా ఇప్పటికే blocked అయిన A ఎంట్రీలు
    Normal (171,454) Pro++ marker తప్ప అన్నీ
    Pro++ (223,551) Ultimate marker తప్ప అన్నీ
    Pro Mini (86,842) Ultimate Mini marker తప్ప అన్నీ
    TIF Mini (212,777) TIF Medium marker తప్ప అన్నీ
    Gambling Mini (118,888) Gambling Medium marker తప్ప అన్నీ
    Fake (17,622) Pro++ marker తప్ప అన్నీ
    Pop-Up Ads (48,277) Pro++ 4 తప్ప అన్నీ (marker, మరో 3)
    Badware Hoster (1,088) Pro++ 966
    Ultimate Mini (120,458) Pro++ 95,417

    script ను ఈ lists పై, అలాగే లేని ఫైల్, ఖాళీ ఫైల్, comments మాత్రమే ఉన్న ఫైల్, విఫలమైన download, ఒక web page, adblock, hosts, plain-domain formats లోని lists పై పరీక్షించాను.

    load అయిన పేర్ల సంఖ్య నా మార్పులను అనుసరించలేదు. మొదటి శుభ్రత రోజున రూటర్ దానికి ముందు 2,840,117 పేర్లను, తర్వాత 3,188,234 పేర్లను load చేసింది, పద్దెనిమిదికి బదులు పది lists తో: ఆ రోజు రెండు downloads మధ్య TIF 426,519 ఎంట్రీలు పెరిగింది. నా వైపు మార్పు లేకుండానే, ఆ సంఖ్య నాలుగు రోజుల్లో 2,739,044 నుండి 3,229,041 కు మారింది. ఈ పరిశీలన కోసం నేను download చేసిన list పరిమాణాల ప్రకారం, పేర్లలో సుమారు మూడింట రెండు వంతులు TIF లో, సుమారు 7 శాతం Pro++ లో ఉన్నాయి.

    లోతైన పరిశీలన: రూటర్ గణాంకాలు, వాటి పరిమితులు

    load అయిన పేర్లు, రూటర్ log నుండి (“blocklist loaded. length is …”, ప్రత్యేక పేర్ల సంఖ్య):

    ఎప్పుడు Lists load అయిన పేర్లు
    మొదటి శుభ్రత రోజు, ముందు ఆ పద్దెనిమిది 2,840,117
    మొదటి శుభ్రత రోజు, తర్వాత కొత్త సెట్ 3,188,234
    ఐదు రోజుల తర్వాత అదే సెట్ 2,739,044
    తొమ్మిది రోజుల తర్వాత అదే సెట్ 3,229,041
    పద్దెనిమిది రోజుల తర్వాత అదే సెట్ 3,198,953

    blocked అయిన queries వాటా, Reporting → Unbound DNS నుండి:

    కాలం Queries Blocked అయినవి
    మొదటి శుభ్రత రోజు, ఆ రోజే చదివినది నమోదు చేయలేదు 12.9 శాతం
    సుమారు 38 గంటల కాలం, తర్వాత చదివినది 110,248 8,600 (7.80 శాతం)

    ఆ రెండు శాతాలు వేర్వేరు lists, వేర్వేరు రోజులు, ఆ సమయంలో నెట్‌వర్క్ ఏం చేస్తూ ఉందో దాని మీద ఆధారపడినవి. అవి ముందు-తర్వాత పోలిక కావు.

    ఇప్పుడు నేను tick చేసినవి

    నా రూటర్ settings ఇవి చూపుతాయి:

    • Hagezi Pro++ (full)
    • TIF (full)
    • Gambling (full)
    • Fake, Pop-Up Ads, Badware Hoster మరియు “Safesearch not supported”
    • OISD NSFW
    • URL ద్వారా రెండు Hagezi lists: encrypted-DNS servers, LG TV trackers
    • Abuse.ch ThreatFox, URL ద్వారా, ఉచిత key తో (కింద)

    device trackers కోసం Hagezi సిఫార్సు చేసిన Pro కంటే Pro++ ను ఎంచుకున్నాను, ఎందుకంటే వాటిలో దాదాపు అన్నింటినీ అతను Pro++ లోనే బ్లాక్ చేస్తాడు.

    వీటిలో రెండు duplicates. Fake, Pop-Up Ads Pro++ లోపలే ఉన్నాయని Hagezi cheat sheet గుర్తిస్తుంది. Fake విషయంలో కొలత ఏకీభవిస్తుంది, ఏది బ్లాక్ అవుతుందో మారకుండా దాన్ని తొలగించవచ్చు. నేను download చేసిన lists లో, Pop-Up Ads లో Pro++, TIF, Gambling, Hoster, Fake లో దేనిలోనూ లేని మూడు పేర్లు ఉన్నాయి; దాన్ని తొలగిస్తే ఆ మూడూ పోతాయి. ThreatFox ను, URL ద్వారా చేర్చిన రెండు lists ను నేను పోల్చలేదు. Fake, Pop-Up Ads రెండూ ఇప్పటికీ tick చేసి ఉన్నాయి.

    ThreatFox download కావడం ఆగిపోయి, ఇప్పుడు మళ్లీ download అవుతోంది. ప్రతి update “unable to download blocklist … and no cache available” అని log చేసింది. దాని కోసం OPNsense built-in ఎంట్రీ వాడిన address “410 Gone” అని సమాధానమిస్తుంది, abuse.ch export పేజీ host file ఇవ్వడానికి ముందు Auth-Key అడుగుతుంది. తర్వాతి 26.7 release అందుకే built-in ఎంట్రీని తొలగించి, వినియోగదారులను “URLs of Blocklists” వైపు చూపుతుంది. abuse.ch key ను తన authentication portal ద్వారా ఉచితంగా ఇస్తుంది. నేను key ను addressలో పెట్టి list ను URL ద్వారా చేర్చాను. abuse.ch export పేజీ key ను URLలో అడుగుతుంది, OPNsense downloader ఎలాంటి headers పంపదు. address రూపాన్ని కింది దశలు చూపుతాయి. దాన్ని చేర్చిన update దాని కోసం 28,889 lines తో “blocklist download” అని log చేసింది, వాటిలో 28,869 పేర్లు, error లేదు; ఆ update లో మిగతా lists cache నుండి load అయ్యాయి. load అయిన పేర్ల రూటర్ సొంత లెక్క ప్రకారం, అది 2,765,172 నుండి 2,782,246 కు పెరిగింది. కాబట్టి ఆ 28,869 లో 17,074, ఆ ఖచ్చితమైన పేరుతో ఇంతకుముందే load అయి లేవు, సుమారు 11,800 అయి ఉన్నాయి. ఈ లెక్క పేర్లను అక్షరాలా పోలుస్తుంది, కాబట్టి దాని parent domain ను మరో list ఇప్పటికే బ్లాక్ చేస్తున్న పేరు కూడా కొత్తగా లెక్కలోకి వస్తుంది. Hagezi ThreatFox ను source గా పేర్కొనడు.

    key పాస్‌వర్డ్ లాగా పనిచేస్తుంది. రూటర్ దాన్ని తన configuration లో నిల్వ చేస్తుంది, ప్రతి update key తో సహా addressను resolver logకు రాస్తుంది. మీ చేతి నుండి బయటకు వెళ్లే screenshots, shared logs, configuration backups, remote log server లలో దాన్ని ఉంచకండి. అది leak అయి ఉంటే, అదే portal నుండి కొత్త key తీసుకుని addressను మార్చండి.

    లోతైన పరిశీలన: key తో ThreatFox ను చేర్చడం

    మొదలుపెట్టే ముందు. ఇది మీ policy కి ఒక list ను చేర్చుతుంది. పది నిమిషాలు పడుతుంది. ఏదీ delete కాదు. Undo చేయడానికి, అదే box నుండి addressను తొలగించి మళ్లీ apply చేయండి.

    1. browser లో https://auth.abuse.ch తెరిచి, account లేకపోతే సృష్టించి, Auth-Key తీసుకోండి. key ఉచితం. దాన్ని ఒక text ఫైల్‌లో 4వ దశ వరకు మాత్రమే ఉంచండి; 4వ దశలో మీరు దాన్ని ఒకసారి paste చేస్తారు, ఆ తర్వాత ఆ text ఫైల్‌ను delete చేయండి.
    2. రూటర్‌లోకి login అవండి. Services, తర్వాత Unbound DNS, తర్వాత Blocklists click చేయండి.
    3. మీ policy row కుడి చివర, పెన్సిల్ (Edit) click చేయండి. Edit Blocklist అనే window తెరుచుకుంటుంది.
    4. URLs of Blocklists లోపల click చేసి, కింది addressను type చేయండి, YOUR_KEY స్థానంలో మీ key పెట్టి, spaces లేకుండా. Enter నొక్కండి, అప్పుడు అది ఒక tag గా మారుతుంది (tag అంటే field లో చిన్న boxగా కనిపించే ఒక ఎంట్రీ):

      https://threatfox-api.abuse.ch/v2/files/exports/YOUR_KEY/hostfile.txt

      key exports/ మరియు /hostfile.txt మధ్య ఉంటుంది.

    5. Save, తర్వాత Apply click చేయండి. రూటర్ lists ను మళ్లీ download చేస్తుంది; ఒకటి రెండు నిమిషాలు వేచి ఉండండి.

    6. Services, Unbound DNS, Log File click చేసి, download కోసం search చేసి, severity boxలో Informational tick చేయండి. ThreatFox address కోసం “blocklist download:” అనే line, దానితో పాటు lines సంఖ్య, కనిపించాలి. line “unable to download” అంటే, key ను, addressలో అదనపు space ఉందేమో చూడండి.
    7. ఆ screen ను share చేయవద్దు: ఆ line మీ key తో పాటు addressను చూపుతుంది.
    లోతైన పరిశీలన: Badware Hoster, URL ద్వారా చేర్చిన రెండు lists

    Badware Hoster Hagezi సొంతంగా నిలిచే list, దాని 1,088 ఎంట్రీలలో 966 ఇప్పటికే Pro++ లో ఉన్నాయి. మిగతావి threat feeds లో పదే పదే కనిపించే మొత్తం hosting providers ను బ్లాక్ చేస్తాయి. ఆ hosts లోని చట్టబద్ధమైన సైట్లు కూడా వాటితో పాటు blocked అవుతాయని Hagezi హెచ్చరిస్తాడు, వాటిని unblock చేయడాన్ని list నడిపే వారికి వదిలేస్తాడు.

    URL ద్వారా చేర్చిన రెండు lists Hagezi వే, wildcard format లో:

    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/doh.txt
    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/native.lgwebos.txt

    మొదటిది encrypted-DNS servers ను పేరు ద్వారా జాబితా చేస్తుంది, devices రూటర్‌ను తప్పించుకోకుండా ఆపడంలో భాగం. రెండోది LG webOS ad, tracking servers ను జాబితా చేస్తుంది. ప్రతిదానికి దాని సొంత కథ ఉంది, అవి వేరే పోస్ట్‌లకు.

    OPNsense 26.7 లోని built-in Hagezi tick-boxes, log చూపినట్లు, Hagezi mirror hagezi-mirror.dnsbunker.org నుండి download చేస్తాయి. ఆ mirror సుమారు ప్రతి నాలుగు నుండి ఎనిమిది గంటలకు కొత్త build ప్రచురిస్తుందని Hagezi చెబుతాడు; jsDelivr కాపీలు రోజుకు ఒకసారి update అవుతాయి.

    DNS బ్లాక్ చేయలేనివి

    YouTube, Instagram app లోపలి ప్రకటనలు వీడియోలు, పోస్ట్‌లు వచ్చే domains నుండే వస్తాయి, కాబట్టి పేరుతో బ్లాక్ చేస్తే కంటెంట్ కూడా బ్లాక్ అవుతుంది. Hagezi FAQ సాధారణ విషయాన్ని చెబుతుంది: కొన్ని ప్రకటనలు కంటెంట్ వచ్చే domains నుండే load అవుతాయి, వాటిని పట్టేది browser లోని content blocker, లేదా ఫోన్‌లో app-level blocker. app లోపలి ప్రకటనలను నేను అంగీకరించాను.

    DNS blocklist రూటర్‌ను అడిగే devices ను మాత్రమే filter చేస్తుంది; తమ సొంత encrypted లేదా hard-coded DNS ఉన్న devices దాన్ని తప్పించుకుంటాయి. అది వేరే పోస్ట్.

    ఇది ఎలా చేశాను

    Claude documentation, lists ను చదివి, వాటిని పోల్చి, నా logged-in browser session ద్వారా నా రూటర్‌ను చదివింది: settings, resolver log, tester. ఏం మార్చాలో నేను నిర్ణయించాను. allowlist సెషన్‌లో రూటర్‌పై జరిగిన ఏకైక మార్పు allowlist rewrite.

    model తప్పులు చేసింది. bare-name allowlist సవరణ మొదటి సెషన్ నుండి వచ్చింది, మరియు ఒక సెషన్‌లో nightly blocklist update Unbound cache ను flush చేస్తుందని కూడా అది నాకు చెప్పింది. రూటర్ log, update lists ను నడుస్తున్న Unbound లోకి, restart లేకుండా, load చేస్తున్నట్లు చూపింది. blocklist settings ను apply చేయడం Unbound ను restart చేయదని manual చెబుతుంది, source కొత్త list ను నడుస్తున్న process లోకి load చేస్తుంది. flush setting Unbound ఆగినప్పుడు మాత్రమే వర్తిస్తుంది.

    రూటర్‌పై logged-in session ఉన్న model ఒక ప్రమాదమే. అది చదివే resolver log లో, ఏ వెబ్‌సైట్ అయినా ఒక device చేత look up చేయించగల పేర్లు ఉంటాయి, ఒక పేరులో model ను నడిపించడానికి రాసిన text ఉండవచ్చు. allowlist సెషన్‌లో, allowlist మార్పు తప్ప, దాన్ని చదవడానికే పరిమితం చేశాను. అది model కు ఇచ్చిన సూచన, నియంత్రణ కాదు; read-only OPNsense user నియంత్రణ అవుతుంది. resolver log లో ThreatFox address కూడా key తో ఉంటుంది, కాబట్టి log చదివే సెషన్ key ను చూస్తుంది. మీరు ఒక model ను ఆ log చదవనిస్తే, ఆ తర్వాత key ను మార్చండి.

    మొదటి సెషన్‌లో నేను ఐదు Unbound settings, ఒక cron job ను కూడా మార్చాను. ఆరూ set అయి ఉన్నట్లు రూటర్ చూపుతుంది.

    లోతైన పరిశీలన: ప్రతి setting, DNS over TLS ను ఎలా undo చేయాలి
    Setting (పేజీ) ముందు తర్వాత
    Flush DNS Cache during reload (General) on off
    Prefetch Support (Advanced) off on
    Serve Expired Responses (Advanced) off on; TTL for Expired Responses 86,400 s
    Use System Nameservers (Query Forwarding) on off
    DNS over TLS forwarders ఏవీ లేవు Cloudflare, Quad9
    Blocklist update job (System → Settings → Cron) ఇతర jobs తో పంచుకునే slot దాని సొంత slot

    Prefetch popular entries expire కావడానికి ముందే refresh చేస్తుంది. manual ఖరీదును సుమారు 10 శాతం ఎక్కువ DNS traffic గా చెబుతుంది.

    Serve Expired Responses device ను వేచి ఉంచే బదులు cache నుండి expired record తో సమాధానం ఇస్తుంది. అది on అయినప్పుడు మరిన్ని fields కనిపిస్తాయి. “TTL for Expired Responses” గడువు ముగిసిన తర్వాత ఎంతసేపు stale answer ఇవ్వవచ్చో పరిమితం చేస్తుంది; నేను 86,400 సెకన్లు పెట్టాను, manual సూచించే 86,400 నుండి 259,200 లో కనిష్ట చివర.

    నేను పరీక్షించని ఒక పరస్పర ప్రభావం: cache flushing off గా, stale answers అనుమతించి ఉన్నప్పుడు, ఒక list కొత్తగా బ్లాక్ చేసిన పేరుకు Unbound cache నుండి కొంతకాలం సమాధానం వస్తూనే ఉండవచ్చు. ఒక block వెంటనే అమలు కాకపోతే, నేను మొదట చూసేది అదే.

    Use System Nameservers. Query Forwarding, DNS over TLS లోని ఏ catch-all ఎంట్రీ కంటే system nameservers కే ప్రాధాన్యత ఉంటుందని manual చెబుతుంది. దాన్ని off చేస్తే DNS over TLS ఎంట్రీలు queries ను పంపుతాయి. ఆ నాలుగు ఎంట్రీలు, Services → Unbound DNS → DNS over TLS కింద:

    Server IP Port Verify CN
    1.1.1.1 853 cloudflare-dns.com
    1.0.0.1 853 cloudflare-dns.com
    9.9.9.9 853 dns.quad9.net
    149.112.112.112 853 dns.quad9.net

    ఈ servers కు రూటర్ సొంత queries encrypted గా వెళ్తాయి. devices తమ సొంత encrypted DNS వాడకుండా ఆపడానికి LAN నుండి port 853 ను reject చేసే firewall rule వాటిని ఏమీ చేయదు, ఎందుకంటే అవి రూటర్ నుండే బయలుదేరతాయి.

    update సమయం దాని సొంత slot కు మారింది, కాబట్టి update ఇకపై ఇతర scheduled jobs తో సమయాన్ని పంచుకోదు.

    DNS over TLS మార్పును undo చేయడానికి:

    మొదలుపెట్టే ముందు. ఇది మీ రూటర్ DNS settings ను మారుస్తుంది, ఐదు నిమిషాలు పడుతుంది. మిగిలిన settings ద్వారా DNS పనిచేస్తూనే ఉంటుంది. ముందు ఆ నాలుగు ఎంట్రీలను (పై table) నోట్ చేసుకోండి; మార్పును తిరిగి పెట్టడానికి అవి కావాలి.

    1. రూటర్ settings పేజీ తెరిచి sign in అవండి. Lobby page కనిపించాలి.
    2. Services, తర్వాత Unbound DNS, తర్వాత DNS over TLS click చేయండి. ఒక table ఎంట్రీలను జాబితా చేస్తుంది.
    3. మొదటి row కుడి చివర, పెన్సిల్ (Edit) click చేయండి. Edit server అనే window తెరుచుకుంటుంది. Enabled ను untick చేసి Save click చేయండి. మిగతా ప్రతి row కూ ఇలాగే చేయండి.
    4. అదే పేజీ పైన, Use System Nameservers ను tick చేయండి. అదే box Query Forwarding కింద కూడా కనిపిస్తుంది; అది ఒకే setting.
    5. పేజీ అడుగున Apply click చేయండి. Unbound కొన్ని సెకన్లలో reload అవుతుంది.
    6. తనిఖీ: నెట్‌వర్క్‌లోని ఒక device నుండి, ఈ రోజు మీరు సందర్శించని ఏ వెబ్‌సైట్‌నైనా తెరవండి. అది load కావాలి. System, Settings, General లో nameservers లేకపోతే, Unbound forwarding చేయకుండా root servers నుండి స్వయంగా resolve చేస్తుంది; మీ provider servers వాడాలంటే వాటిని అక్కడ చేర్చండి.
    7. మార్పును తిరిగి పెట్టడానికి, ప్రతి ఎంట్రీపై Enabled ను మళ్లీ tick చేసి, Use System Nameservers ను untick చేసి, Apply click చేయండి.

    మూలాలు

    การแก้ไขที่ปล่อยให้ชื่อ phishing ผ่านเข้ามา

    แปลจากต้นฉบับภาษาอังกฤษ คำสั่ง โค้ด และศัพท์เทคนิคคงเป็นภาษาอังกฤษไว้

    ในวันเสาร์วันหนึ่งของเดือนตุลาคม ผมแก้ 4 รายการที่เสียใน allowlist ของ DNS บน router ของผม หลังจากนั้นสองสัปดาห์เศษ ผมพบว่ารายการที่แก้แล้วปล่อยให้ชื่อใน threat feed ผ่านเข้ามา ซึ่งเป็นชื่อที่ถูกสร้างให้ดูเหมือนเว็บไซต์ที่ผมตั้งใจ allow ไว้ คือโดเมนของเว็บชำระเงินตามด้วย .https. และโดเมนอื่นที่ไม่เกี่ยวกัน หรือชื่อร้านค้าที่ใช้ขีดกลางแทนจุด tester ของ router เองก็ปล่อยชื่อเหล่านี้ผ่าน

    ในเย็นวันเดียวกัน ผมลด blocklist จาก 18 เหลือ 10 วันรุ่งขึ้นผมเพิ่ม list ของ LG TV อีกหนึ่ง ทำให้เป็น 11 7 list ในจำนวนนั้นมีชุดที่เหลือครอบคลุมอยู่แล้ว list หนึ่งที่ผมเก็บไว้คือ Abuse.ch ThreatFox หยุดดาวน์โหลดเมื่อ abuse.ch เริ่มแจก host file ให้เฉพาะผู้ที่มี key ตอนนี้มันดาวน์โหลดได้อีกครั้ง หลังจากผมใส่ key ฟรีไว้ในที่อยู่ของมัน ส่วนโฆษณาภายใน YouTube และ Instagram บนโทรศัพท์ของผมเข้ามาตลอด ซึ่ง blocklist ใดก็เปลี่ยนไม่ได้

    จากนั้นผมเขียนรายการ allowlist ใหม่ โพสต์นี้เล่าถึงการล้างทั้งสองครั้ง ได้แก่ OPNsense ทำอะไรกับรายการ allowlist วิธีตรวจรายการของคุณเอง และ list 18 รายการที่ซ้อนกันรวมกันแล้วได้อะไร ผมทำงานนี้กับ Claude ใน 2 session หนึ่ง session ต่อการล้างหนึ่งครั้ง ส่วน key ของ ThreatFox ใส่ไปใน session ที่สาม Claude อ่าน router ผ่าน browser ของผม ทุกการเปลี่ยนแปลงบน router ผมเป็นผู้อนุมัติ ผมอนุมัติการแก้ด้วยชื่อเปล่า (bare name) การอนุมัติจึงไม่ได้ป้องกันความผิดพลาดนั้น

    ไม่คุ้นกับ command line? วิธีอ่านกล่องต่าง ๆ

    PS> หมายถึง พิมพ์คำสั่งนี้ใน PowerShell บน Windows (เมนู Start → พิมพ์ powershell → Enter) $ หมายถึง พิมพ์ใน terminal บน Linux หรือ Mac หรือบน Pi หลังจากคุณล็อกอินด้วย ssh แล้ว อย่าพิมพ์ $ หรือ PS> เอง

    แต่ละบรรทัดที่ขึ้นต้นด้วย $ หรือ PS> คือคำสั่ง 1 คำสั่ง คลิกที่ $ นั้นเพื่อคัดลอกเฉพาะบรรทัดนั้น วาง กด Enter และรอจนเสร็จก่อนทำบรรทัดถัดไป กล่องที่มีปุ่ม Copy ด้านบนมี 1 คำสั่ง (หรือ 1 ไฟล์) ให้คัดลอกทั้งกล่อง กล่องเส้นประแสดงสิ่งที่คุณควรเห็นตอบกลับมา คุณไม่ต้องพิมพ์มัน

    Allowlist

    allowlist ของ blocklist policy ของผมมี 26 รายการ ในวันที่ล้างครั้งแรก 4 รายการดูเหมือนเสีย สามรายการถูกวางมาจากแถบที่อยู่ของ browser เป็นที่อยู่เต็ม ในรูป https://example.org/ รายการที่สี่มีช่องว่างหนึ่งช่องหน้าตัวอักษรแรกของชื่อ ผมแทนที่ทั้ง 4 รายการด้วยชื่อเปล่า เช่น example.in ผมไม่ได้ดูว่า 22 รายการที่เหลือเขียนไว้อย่างไร และประวัติ configuration ของ router ย้อนกลับไปไม่ไกลพอที่จะตรวจได้อีก ถ้ารายการเหล่านั้นเป็นชื่อเปล่า ตามที่ปุ่ม Allow ของ router เองเขียนไว้ ช่องโหว่ก็มีอยู่ก่อนที่ผมแก้ และการแก้ของผมขยายช่องโหว่ไปถึง 3 รายการที่เดิมไม่จับคู่กับชื่อใดเลย

    log ของ router แสดงรายการที่ห้า เป็นรายการที่เขียนเป็น *.ntp.org ซึ่งลบไปแล้ว การอัปเดตทุกคืนบันทึก “skip invalid whitelist exclude pattern” ไว้สำหรับรายการนี้ เครื่องหมาย * นำหน้าใช้ไม่ได้ใน regular expression ของ Python router จึงทิ้งรายการนั้นทุกคืนและแจ้งไว้ใน log เท่านั้น รูปแบบที่ทำสิ่งที่ตั้งใจไว้คือ (.*\.)?ntp\.org\.?$

    ต่อมา Claude อ่านโค้ดที่ใช้ allowlist ใน OPNsense 26.7 ช่องว่างนำหน้าไม่ได้ก่อความเสียหาย โค้ดตัดช่องว่างออกจากทุกรายการ ปัญหาอยู่ที่ชื่อเปล่า

    OPNsense ถือแต่ละรายการเป็น regular expression ไม่สนใจตัวพิมพ์เล็กใหญ่ และตรวจกับส่วนต้นของชื่อที่อุปกรณ์ถาม ไม่มีสิ่งใดผูกรายการกับท้ายชื่อ และจุดที่ไม่ได้ escape จับคู่กับอักขระใดก็ได้ ดังนั้น example.com เปล่า ๆ อนุญาต example.com แต่ไม่อนุญาต www.example.com และยังอนุญาตชื่อใดก็ตามที่ขึ้นต้นด้วยตัวอักษรเหล่านั้น โดยมีอักขระใดก็ได้แทนแต่ละจุด: example.com.evil.net, example-com.evil.net, example.community

    threat feed มีชื่อที่มีรูปแบบนั้นพอดี คือชื่อของเว็บไซต์ที่รู้จักกันดีตามด้วย .https. และโดเมนที่ไม่เกี่ยวกัน หรือชื่อเว็บไซต์นั้นโดยใช้ขีดกลางแทนจุด บน feed ที่ผมดาวน์โหลดมาสำหรับการตรวจครั้งนี้ 7 จาก 26 รายการของผมจับคู่กับชื่อแบบนี้ 43 ชื่อ รายการหนึ่งจับคู่ 20 ชื่อ บน tester ของ router ผม ชื่อแบบนี้ 5 ชื่อที่ผมลองผ่านทุกชื่อ ขณะที่ชื่อเดียวกันที่มี www. นำหน้า ซึ่งถูกบล็อกโดยรายการเดียวกันใน list ก็ถูกบล็อก ชื่อที่ผมประกอบเองจากเว็บไซต์ที่ allow ไว้กับโดเมนที่ threat feed บล็อกก็ผ่านเช่นกัน ตามโค้ดที่จับคู่ ทุกรายการชื่อเปล่าอนุญาตชื่อใดก็ตามที่ขึ้นต้นด้วยมัน ไม่ว่ามี list ใดบล็อกชื่อนั้นหรือไม่

    ปุ่ม Allow ของ OPNsense เอง ใน Reporting → Unbound DNS บันทึกชื่อเปล่าแบบเดียวกัน รายการที่เพิ่มจากที่นั่นจึงทำงานแบบเดียวกัน

    วิธีแก้คือ allow ชื่อที่ตรงทุกตัว โดยผูกทั้งสองปลาย:

    ^www\.example\.com\.?$

    เครื่องหมาย backslash ทำให้จุดเป็นจุดจริง และ $ ผูก pattern กับท้ายชื่อ \.? อนุญาตจุดท้ายที่ชื่อมีอยู่ใน 1 จาก 2 เส้นทางที่โค้ดตรวจ (ดูส่วนเจาะลึก) ^ ทำซ้ำสิ่งที่โค้ดทำอยู่แล้ว การละไว้จึงใช้ได้เช่นกัน ผมคงไว้เพื่อให้ pattern อ่านเหมือนกันทุกที่ ขั้นตอนตรวจและเขียนรายการของคุณใหม่อยู่ในส่วนเจาะลึกภายใต้ “วิธีตรวจของคุณ”

    การ allow โดเมนพร้อม subdomain ทั้งหมด ใช้ (.*\.)?example\.com\.?$ ได้ แต่ก็อนุญาต host ที่ list จงใจบล็อกไว้ใต้โดเมนนั้นด้วย ในรายการหนึ่งของผม Pro++ บล็อก 5 host ใต้โดเมน ด้วยชื่อเช่น advertising และ sponsored-ads และไม่บล็อกโดเมนเอง หรือชื่อ www. ของมัน การ allow ทั้ง subdomain จะปล่อย host เหล่านั้นกลับเข้ามา

    ผมรันโค้ด parsing ของ OPNsense เองและ call ที่ใช้จับคู่ กับชื่อบางชื่อ:

    รายการ allowlist ชื่อที่ถูกถาม อนุญาตหรือไม่
    https://example.org/ example.org ไม่
    example.in example.in ใช่
    example.in www.example.in ไม่
    example.in example.in.example.net ใช่
    example.in example-info.de ใช่
    ^www\.example\.in\.?$ www.example.in ใช่
    ^www\.example\.in\.?$ advertising.example.in ไม่
    ^www\.example\.in\.?$ www.example.in.example.net ไม่

    ผมเขียนทั้ง 26 รายการใหม่ในรูปแบบที่ตรงและผูกหัวท้ายนั้น แล้ว apply การเปลี่ยนแปลง ทุกชื่อที่เคยผ่าน tester ถูกบล็อกหลังจากนั้น รายการหนึ่งที่ชื่อของมันเองอยู่ใน list ยังผ่านตามที่ตั้งใจ ชื่อที่ตรงใน 25 รายการที่เหลือไม่ถูก list ใดบล็อก รายการเหล่านั้นจึงไม่ได้ทำงานให้กับชื่อที่มันสะกด ผลอย่างเดียวของมันคือช่องโหว่คำนำหน้า ผมผูกหัวท้ายแทนที่จะลบ เพราะ list อาจเพิ่มชื่อนั้นเข้ามาภายหลัง ถ้าคุณมีรายการแบบนั้น การลบก็เป็นทางเลือกที่สมเหตุสมผล

    เจาะลึก: โค้ด และสิ่งที่การทดสอบของผมแสดงและไม่แสดง

    dialog ของ blocklist มีช่อง “Allowlist Domains” ช่องเดียว ข้อความช่วยเหลือของช่องบอกว่ารับโดเมน ใช้ regular expression ได้ และใช้กับรายการที่ตรงใน policy นั้นเท่านั้น ใน 26.7:

    • src/opnsense/service/templates/OPNsense/Unbound/core/blocklists.conf เขียนช่องนี้เป็น excludes.patterns คั่นด้วยจุลภาค
    • src/opnsense/scripts/unbound/blocklists/default_bl.py แยกค่านั้นที่เครื่องหมายจุลภาค เรียก strip() กับแต่ละรายการ ทิ้งรายการที่ compile เป็น regular expression ไม่ได้ (พร้อมบรรทัด log “skip invalid”) และรวมรายการที่เหลือ พร้อมรายการ .*localhost$ ที่มีมาในตัว เป็น pattern เดียวด้วย |
    • src/opnsense/scripts/unbound-dnsbl/lib/__init__.py compile pattern โดยไม่สนใจตัวพิมพ์เล็กใหญ่
    • src/opnsense/scripts/unbound-dnsbl/lib/dnsbl.py ทดสอบด้วย r.match(domain) หลังจากพบชื่อใน blocklist match ของ Python ผูกที่ต้นชื่อ ไม่ผูกที่ท้าย ชื่อถูกแปลงเป็นตัวพิมพ์เล็กและตัดจุดท้ายออกก่อน
    • เมื่อเป้าหมายของ CNAME ถูกบล็อก ฟังก์ชันเดียวกันจะทดสอบชื่อเดิม (r.match(orig)) ด้วย ชื่อที่อยู่ใน allowlist จึงยัง resolve ผ่าน alias ที่ถูกบล็อกได้ ชื่อเดิมนั้นมาจาก Unbound พร้อมจุดท้าย www.example.com. และไม่ถูกตัดจุดท้ายออก pattern ที่ลงท้ายด้วย $ เปล่า ๆ ล้มเหลวที่นั่น \.?$ ผ่านทั้งสองเส้นทาง
    • src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php, updateBlocklistAction คือสิ่งที่ปุ่ม Allow ใน Reporting เรียก มันลบจุดท้าย (rtrim($domain, '.')) และบันทึกชื่อตามที่เป็น ไม่ escape และไม่ผูกหัวท้าย

    คู่มือของ OPNsense อธิบายรายการ allowlist ว่าเป็นการยกเว้นรายการ blocklist ที่มี pattern อยู่ในนั้น โค้ดแคบกว่าที่ต้นชื่อ เพราะจับคู่จากอักขระแรกเท่านั้น และเปิดกว้างเท่ากันที่ปลาย ไม่ว่าจะอ่านแบบใด การผูกปลายเป็นหน้าที่ของผู้เขียนรายการ ผมเทียบไฟล์ 5 ไฟล์เดิมนี้ใน release 26.7 ล่าสุดกับ development branch โค้ด allowlist ไม่เปลี่ยน

    สิ่งที่การทดสอบแสดง คือ parser และ matching call ใน source 26.7 จัดการรายการเหล่านี้อย่างไร รันนอก router โดยจำลองกรณี CNAME ด้วยการเติมจุดท้าย และบน router ของผม ผลของ tester สำหรับแต่ละชื่อ phishing ที่ผมลอง เทียบกับตัวควบคุมที่ต่างกันเพียงไม่ได้ขึ้นต้นด้วยชื่อที่อยู่ใน allowlist ทั้งก่อนและหลังการเขียนใหม่ tester รันโค้ดจับคู่เดียวกันกับ list ที่ router โหลดไว้ แต่ใช้ได้เฉพาะกับการ lookup ตรง จึงแสดงเส้นทาง CNAME ไม่ได้ จำนวน 43 ชื่อมาจาก list ที่เผยแพร่ ไม่ได้มาจาก router ทั้ง 43 ชื่ออยู่บน TIF

    วิธีตรวจของคุณ

    ตรวจ 4 อย่าง ทั้งหมดอ่านอย่างเดียวจนถึงอย่างสุดท้าย:

    1. อ่าน resolver log เพื่อหา list ที่ดาวน์โหลดไม่สำเร็จ และรายการ allowlist ที่ถูกข้าม
    2. ใน tester ของ blocklist ลองชื่อที่ควรถูกบล็อกหนึ่งชื่อ และชื่อที่ควรผ่านหนึ่งชื่อ เพื่อดูว่า list โหลดอยู่
    3. สำหรับแต่ละรายการ allowlist ให้ทดสอบรายการนั้นตามด้วยโดเมนที่ list ของคุณบล็อก แล้วทดสอบชื่อเดียวกันโดยมี www. นำหน้า ถ้าชื่อแรกผ่านและชื่อที่สองถูกบล็อก รายการนั้นเปิดอยู่
    4. เขียนแต่ละรายการที่เปิดอยู่ใหม่แบบผูกหัวท้าย apply แล้วทดสอบอีกครั้ง

    ขั้นตอนคลิกทีละขั้นสำหรับข้อ 1 ถึง 3 และสำหรับการเขียนใหม่อยู่ในส่วนเจาะลึก 2 ส่วนด้านล่าง ขั้นตอนเริ่มจากหน้า sign-in และบอกว่าแต่ละขั้นเปลี่ยนอะไร

    เจาะลึก: ทีละขั้น การตรวจ allowlist ของคุณ

    ก่อนเริ่ม คุณต้องมี browser บนคอมพิวเตอร์ในเครือข่ายของคุณ และที่อยู่กับข้อมูลล็อกอินของหน้าตั้งค่า router ขั้นที่ 1 ถึง 8 อ่านอย่างเดียว ไม่เปลี่ยนอะไรบน router คุณจึงหยุดตรงไหนก็ได้โดยไม่ต้องย้อนอะไร ใช้เวลาประมาณ 10 นาที บวกประมาณ 10 วินาทีต่อการทดสอบหนึ่งครั้ง เพราะ tester โหลด blocklist ทั้งชุดทุกครั้ง

    1. เปิด browser และพิมพ์ที่อยู่ที่คุณใช้ sign in เข้า OPNsense แล้ว sign in คุณควรเห็นหน้า Lobby ถ้าหน้าไม่โหลด ให้ตรวจว่าคอมพิวเตอร์อยู่ในเครือข่ายบ้านของคุณ และคุณใช้ที่อยู่เดียวกับที่ใช้เปลี่ยนค่าอื่นของ router
    2. ในเมนูทางซ้าย คลิก Services แล้ว Unbound DNS แล้ว Log File คุณควรเห็นตารางที่มีคอลัมน์ Date, Severity, Process และ Line ด้านบนมีช่องค้นหา ช่อง severity (ตั้งเป็น Warning) และช่องเวลา (ตั้งเป็น Last day)
    3. คลิกช่องค้นหา พิมพ์ blocklist แล้วกด Enter บรรทัดที่สำคัญมี 2 แบบ “unable to download blocklist” หมายความว่า list โหลดไม่สำเร็จและไม่ได้ช่วยอะไรเลย “skip invalid whitelist exclude pattern” หมายความว่า OPNsense ทิ้งรายการ allowlist ถ้าตารางว่าง แปลว่าในวันที่ผ่านมาไม่มีการบันทึกระดับ Warning เปิดช่อง severity แล้วติ๊ก Informational เพิ่มเพื่อดูบรรทัด “blocklist loaded” เปิดช่องเวลาเพื่อดูย้อนไปไกลกว่านั้น
    4. ในเมนูเดียวกัน คลิก Blocklists แล้วแท็บ Tester ที่ด้านบนของหน้า คุณควรเห็นช่อง Domain ช่อง Source และปุ่ม Test ปล่อยช่อง Source ว่างไว้ การทดสอบจะรันในฐานะตัว router เอง ช่อง Source รับที่อยู่ของอุปกรณ์ และสำคัญเฉพาะเมื่อคุณมี policy ที่ใช้กับอุปกรณ์บางเครื่อง
    5. พิมพ์ googleads.g.doubleclick.net ในช่อง Domain แล้วคลิก Test รอประมาณ 10 วินาที ผลควรเป็น Block จากนั้นทดสอบ www.youtube.com ควรเป็น Pass ถ้าชื่อแรกผ่าน แปลว่าไม่มี list ใดโหลดอยู่ หรือชื่อนั้นอยู่ใน allowlist ของคุณเอง ให้กลับไปขั้นที่ 3 และอ่านข้อผิดพลาด และถ้าคุณ allow ชื่อนั้นไว้ ให้เลือกชื่ออื่นที่ list ของคุณบล็อก tester ไม่ตาม CNAME CNAME คือชื่อที่ชี้ไปยังอีกชื่อหนึ่ง tester ตรวจเฉพาะชื่อที่คุณพิมพ์
    6. คลิกแท็บ Blocklists จากนั้นที่ปลายด้านขวาของแถว policy ของคุณ คลิกไอคอนดินสอ (Edit) หน้าต่างชื่อ Edit Blocklist เปิดขึ้น Allowlist Domains แสดงรายการของคุณ รายการละ 1 tag อ่านแล้วคลิก Cancel ไม่มีอะไรถูกบันทึก
    7. สำหรับแต่ละรายการ ให้ทดสอบรายการนั้นตามด้วยโดเมนที่ list ของคุณบล็อก ชื่อที่ list ของผมบล็อกคือ googleads.g.doubleclick.net ตัวเดียวกับในขั้นที่ 5 ถ้า list ของคุณไม่บล็อกชื่อนี้ ให้เลือกชื่อที่ list ของคุณบล็อก ดังนั้นสำหรับรายการ example.com พิมพ์ example.com.googleads.g.doubleclick.net แล้วคลิก Test จากนั้นทดสอบชื่อเดียวกันโดยมี www. นำหน้า www.example.com.googleads.g.doubleclick.net ถ้าคุณโหลด TIF คุณใช้ชื่อจาก list นั้นแทนได้ รายการที่ขึ้นต้นด้วย ^ และลงท้ายด้วย $ อยู่แล้วคือรายการที่ผูกหัวท้ายแล้ว ให้ข้ามไป
    8. อ่านผลทั้งสองร่วมกัน ถ้าชื่อแรกผ่านและชื่อที่สองถูกบล็อก รายการนั้นเปิดอยู่ มันปล่อยผ่านทุกชื่อที่ขึ้นต้นด้วยมัน ให้เขียนใหม่แบบผูกหัวท้าย ชื่อที่ไม่มี list ใดบล็อกจะผ่านไม่ว่า allowlist จะระบุอย่างไร ดังนั้นให้ยืนยันใน tester ว่าชื่อนั้นถูกบล็อกก่อนจะอ่านผล Pass เป็นข้อบกพร่อง
    เจาะลึก: ทีละขั้น การเขียน allowlist ของคุณใหม่

    ก่อนเริ่ม ขั้นตอนนี้เปลี่ยนการกรองของ router ควรเผื่อเวลา 15 นาที ความผิดพลาดที่นี่ส่วนใหญ่แสดงเป็นเว็บไซต์ที่ allow ไว้ 1 แห่งโหลดไม่ขึ้น อินเทอร์เน็ตส่วนที่เหลือควรยังทำงานอยู่ router ใช้การเปลี่ยนแปลงภายในประมาณ 1 นาที (43 วินาทีบนเครื่องผม) และไม่ restart Unbound log แสดง list โหลดเข้าสู่ process ที่กำลังรันอยู่ ขั้นที่ 3 เก็บสำเนารายการเก่าของคุณ และขั้นที่ 8 ใส่กลับคืน

    1. เปิดหน้าตั้งค่าของ router แล้ว sign in คลิก Services แล้ว Unbound DNS แล้ว Blocklists
    2. ที่ปลายด้านขวาของแถว policy ของคุณ คลิกไอคอนดินสอ (Edit) หน้าต่าง Edit Blocklist เปิดขึ้น ใต้ Allowlist Domains คลิก Text ซึ่งเป็นลิงก์เล็ก ๆ ใต้ช่อง tag จะกลายเป็นช่องธรรมดาที่มี 1 รายการต่อบรรทัด และลิงก์ Back ปรากฏขึ้น ถ้าคุณมี policy มากกว่า 1 อัน แต่ละอันมี allowlist ของตัวเอง ให้ทำกับทุกอัน
    3. ทำสำเนาไว้เผื่อย้อนกลับ คลิกในช่อง กด Ctrl + A แล้ว Ctrl + C เปิด Notepad (เมนู Start พิมพ์ notepad กด Enter) กด Ctrl + V และบันทึกไฟล์เป็น allowlist-before.txt ในโฟลเดอร์ที่คุณจะหาเจออีก ไฟล์ควรมี 1 รายการต่อบรรทัด
    4. เขียนแต่ละบรรทัดในช่องใหม่ ขั้นนี้ใช้กับชื่อธรรมดา รายการที่เป็น pattern อยู่แล้ว เช่นรายการที่มี (.*\.)? คงไว้ตามเดิม เขียนชื่อที่ตรงตามที่อุปกรณ์ของคุณถาม ใส่ \ หน้าทุกจุด ใส่ ^ ที่ต้น และ \.?$ ที่ท้าย:

      • example.in กลายเป็น ^example\.in\.?$
      • www.example.com กลายเป็น ^www\.example\.com\.?$

      ให้มี 1 รายการต่อบรรทัด ไม่มีช่องว่าง และไม่มีจุลภาค ชื่อที่มี www. กับชื่อเดียวกันที่ไม่มีเป็น 2 ชื่อ และต้องใช้ 2 บรรทัด ถ้าคุณไม่แน่ใจว่าอุปกรณ์ถามชื่อไหน ให้ดูใน Reporting → Unbound DNS หรือใส่ทั้งสองชื่อไว้ในรายการ

    5. คลิก Back บรรทัดจะกลับเป็น tag ตรวจว่าทุก tag อยู่ในรูปแบบใหม่ คลิก Save หน้าต่างปิด

    6. คลิก Apply ซึ่งเป็นปุ่มสีส้มใต้ตาราง รอประมาณ 1 นาที
    7. ตรวจผล เปิด Services, Unbound DNS, Log File ค้นหา blocklist และติ๊ก Informational ในช่อง severity คุณควรเห็น “updating blocklist” แล้ว “blocklist loaded. length is” และตัวเลข และไม่มีบรรทัด “skip invalid” จากนั้นทำขั้นตอนของ tester ซ้ำจากข้างต้น ชื่อที่หน้าตาคล้ายกันควรเป็น Block แล้ว รายการที่ allow ชื่อที่ list บล็อก (บนเครื่องผมคือรายการสำหรับ ad host ของ Google) ควรยังเป็น Pass
    8. ถ้าเว็บไซต์หยุดโหลดหลังการเปลี่ยนแปลง ให้ย้อนกลับ เปิด allowlist-before.txt ใน Notepad กด Ctrl + A แล้ว Ctrl + C ใน router ทำขั้นที่ 1 และ 2 ซ้ำ คลิกในช่อง กด Ctrl + A แล้ว Ctrl + V เพื่อวางรายการเก่าทับรายการใหม่ คลิก Back, Save และ Apply เว็บไซต์ที่ต้องการชื่อที่คุณไม่ได้ใส่ไว้จะถูกบล็อกจนกว่าคุณจะเพิ่มชื่อที่ตรงนั้น
    เจาะลึก: ทดสอบการเปลี่ยน allowlist จากคอมพิวเตอร์

    ก่อนเริ่ม ส่วนนี้สำหรับ Windows PC ในเครือข่ายเดียวกับ router มันถาม DNS ของ router หา 1 ชื่อ และล้าง DNS cache ของ PC เอง ไม่เปลี่ยนอย่างอื่น ใช้เวลา 2 นาที บน Mac หรือ Linux แนวคิดเหมือนกัน (nslookup name router-address) แต่คำสั่งล้าง cache ต่างกัน

    1. คลิกเมนู Start พิมพ์ powershell แล้วกด Enter หน้าต่างเปิดขึ้นพร้อม prompt ที่ขึ้นต้นด้วย PS
    2. หาที่อยู่ของ router พิมพ์คำสั่งนี้แล้วกด Enter:

      ipconfig

      มองหา Default Gateway ใต้ adapter ที่คุณใช้ ที่อยู่นั้นคือ router ของคุณ ขั้นตอนด้านล่างเรียกมันว่า <router-ip> ถ้า router ของคุณอยู่หลัง router อีกตัว default gateway อาจเป็นอุปกรณ์อีกตัวนั้น ให้ใช้ที่อยู่ของกล่องที่รัน DNS blocklist ของคุณ ถ้าบรรทัดว่าง คุณกำลังดู adapter ที่ไม่ได้เชื่อมต่อ ให้เลื่อนไปอันถัดไป

    3. หลังคลิก Apply บน router และรอ 1 นาที ให้ล้าง cache ของ PC คำตอบที่ถูกบล็อกมีอายุ 1 ชั่วโมง ถ้าไม่ล้าง PC อาจเก็บคำตอบเก่าไว้:

      ipconfig /flushdns
    4. ถาม router หาชื่อ โดยแทน <router-ip> ด้วยที่อยู่จากขั้นที่ 2 จุดสุดท้ายหลังชื่อกันไม่ให้ Windows ลอง search suffix ก่อน:

      nslookup www.example.com. <router-ip>

      ชื่อที่ถูกบล็อกตอบ 0.0.0.0 หรือ “Non-existent domain” ถ้าติ๊ก Return NXDOMAIN บน policy ชื่อที่ allow ตอบด้วยที่อยู่จริงของมัน 2 บรรทัดแรกแสดง router ของคุณ ที่เหลือคือคำตอบ

    18 list รวมกันได้อะไร

    ใน resolver log ของ router ตั้งแต่บรรทัดแรกจนถึงการล้างครั้งแรก ทุกการอัปเดตเต็มตอนกลางคืนถูกตั้งให้โหลด 18 list ชุดเดียวกัน (รวม ThreatFox ดูด้านล่าง):

    • Hagezi Normal บวกรุ่น Mini ของ Pro, Pro++ และ Ultimate
    • Threat Intelligence Feeds (TIF) ทั้ง 3 ขนาด: full, Medium และ Mini
    • Gambling ทั้ง 3 ขนาด
    • Fake, Pop-Up Ads, Badware Hoster, DynDNS, Anti Piracy และ “Safesearch not supported”
    • OISD NSFW และ Abuse.ch ThreatFox

    Hagezi ผู้ดูแล list เหล่านี้ส่วนใหญ่ ให้กฎการรวม list ของเขาไว้ใน FAQ:

    1. Multi list ทั้ง 5 ได้แก่ Light, Normal, Pro, Pro++ และ Ultimate ต่อยอดกัน แต่ละ list มี list ระดับล่างรวมอยู่ คุณเลือก 1 list
    2. รุ่นที่ปรับขนาด (Mini และ Medium สำหรับ TIF และ Gambling) เป็นทางเลือกแทน list เต็มของมัน ไม่ใช่สิ่งที่วางซ้อนบน list เต็ม
    3. TIF เป็นข้อยกเว้น มันครอบคลุม malware, cryptojacking, scam, spam และ phishing และตั้งใจให้รันควบคู่กับ tier ใดก็ตามที่คุณเลือก

    Mini ของ Pro, Pro++, Ultimate และ Gambling เก็บเฉพาะชื่อที่ปรากฏอยู่ใน list ของโดเมนที่ถูกเข้าชมมากที่สุดด้วย TIF Mini และ Gambling Mini ตัดมาจาก list Medium Hagezi อธิบายว่า Mini ทำมาสำหรับตัวบล็อกบนอุปกรณ์ที่มีหน่วยความจำจำกัด

    เจาะลึก: tier ไหนเหมาะกับใคร และ Ultimate มีต้นทุนอะไร

    FAQ ของ Hagezi จับคู่ tier กับคนที่จะจัดการเมื่อมีสิ่งใช้งานไม่ได้:

    Tier เหมาะกับ ความเสี่ยงที่ใช้งานไม่ได้ (การจัดระดับของ Hagezi)
    Light blocker ที่รับ list ใหญ่ไม่ไหว หรือการตั้งค่าที่แม้ Normal ก็มากเกินไป น้อยที่สุด
    Normal การตั้งค่าที่ไม่มีคนดูแล และไม่มี admin คอยปลดบล็อก ต่ำ
    Pro มีคนปลดบล็อกให้ได้ เป็นคำแนะนำเริ่มต้นของเขา คู่กับ TIF ต่ำถึงปานกลาง
    Pro++ ผู้ใช้ที่มีประสบการณ์และมี admin ปานกลาง
    Ultimate ผู้ใช้ที่มีประสบการณ์มากและมี admin อยู่ สูง

    แต่ละ tier ยังมีส่วนแบ่งของ list tracker ในตัวอุปกรณ์ (native tracker) คือ telemetry ที่ฝังอยู่ใน TV โทรศัพท์ และระบบปฏิบัติการ Pro++ บล็อกเกือบทั้งหมด Ultimate บล็อกทั้งหมด README ระบุสิ่งที่ Ultimate ต้องแลก ได้แก่ บางฟังก์ชันของ Facebook และ Messenger; ส่วนเสริมของ WhatsApp เช่น avatar และเอฟเฟกต์วิดีโอ; Windows Spotlight และประวัติความสำเร็จของ Xbox; และ tracker ตำแหน่งที่บางเว็บไซต์พึ่งพา ซึ่งอาจทำให้ได้การตั้งค่าภูมิภาคผิดและเจอ CAPTCHA มากขึ้น

    ชุดของผมฝ่าฝืนกฎ 2 ข้อแรก ผมดาวน์โหลด list ครั้งเดียวสำหรับการตรวจนี้และเทียบกันทีละชื่อ เพื่อดูว่ารายการใดที่ list หนึ่งบล็อกอยู่แล้วใน list อื่น ผมไม่มีสำเนาที่ router โหลดไว้ก่อนหน้า และผมไม่ได้วัด ThreatFox จึงวัด 17 list

    7 จาก 17 list ถูกชุดที่เหลือครอบคลุม ยกเว้นรายการ marker หนึ่งรายการของแต่ละ list ได้แก่ Pro Mini, Pro++ Mini, TIF Medium, TIF Mini, Gambling Medium, Gambling Mini และ Fake การทิ้งทั้ง 7 พร้อมกันจะเสีย 15 ชื่อที่ TIF Medium และ Mini มี แต่ TIF เต็มไม่มี Pop-Up Ads เพิ่ม 37 ชื่อจาก 48,277 ชื่อของมันให้กับชุดที่เหลือ (เทียบกับ Pro++ อย่างเดียวมันเพิ่ม 3 ชื่อ ดูด้านล่าง) DynDNS และ Anti Piracy ต่างออกไป บน list เหล่านั้นมีประมาณ 1,200 และประมาณ 55,000 ชื่อที่ไม่มี list อื่นในชุดมี และผมทิ้งไปโดยเลือกเอง ไม่ใช่เพราะซ้ำ

    tier list ทั้ง 4 รวมกันมี 233,710 ชื่อ ซึ่งอยู่ใน Ultimate ทั้งหมดยกเว้นรายการ marker 4 รายการของ Hagezi เมื่อเทียบกับ Pro++ อย่างเดียว ชุดนี้ขาด 31,411 รายการของ Pro++ ซึ่งเป็นรายการที่ไม่อยู่ใน list ของโดเมนที่ถูกเข้าชมมากที่สุด แทนที่นั้นมันมี 25,040 รายการที่มีเพียง Ultimate บล็อก (25,041 เมื่อรวม marker ของ Ultimate Mini) ทั้งหมดมาจาก list ของโดเมนที่ถูกเข้าชมมากที่สุด Hagezi จัดความเสี่ยงที่ Ultimate ทำให้ใช้งานไม่ได้ว่าสูง ผมไม่ได้เก็บบันทึกว่ามีสิ่งใดใช้งานไม่ได้จาก list เหล่านั้น และไม่ได้ทดสอบ แต่ตามการจัดระดับของ Hagezi ชุดผสมนี้รับความเสี่ยงของ Ultimate และขาดความครอบคลุมของ Pro++

    เจาะลึก: ผมวัดอย่างไร และทำไมการเทียบแบบธรรมดาจึงให้ผลผิด

    OPNsense ใช้รูปแบบ wildcard ของ Hagezi ซึ่งบรรทัดอย่าง *.example.com บล็อก example.com และทุกชื่อใต้มัน ดังนั้นรายการใน list A ถูก list B บล็อกอยู่แล้ว ถ้า B มีรายการนั้นหรือโดเมนแม่ของมันรายการใดรายการหนึ่ง

    การเทียบข้อความธรรมดาพลาดเรื่องนี้ comm รายงานว่า 3,294 รายการของ Pro++ Mini “ไม่อยู่ใน” Ultimate Mini ทั้งหมดยกเว้น 1 รายการถูกครอบคลุม เพราะ Ultimate Mini บล็อกโดเมนแม่แทน มีบรรทัดเดียวสำหรับ omtrdc.net ทั้งโดเมน ซึ่งเป็นโดเมน tracking ของ Adobe ขณะที่ Pro++ Mini ระบุ host ของมัน 998 รายการทีละตัว รายการที่เหลือ 1 รายการคือ marker ของ Hagezi ซึ่งอธิบายด้านล่าง

    tier list ทั้ง 4 วัดด้วยวิธีเดียวกัน:

    Normal + Pro Mini + Pro++ Mini + Ultimate Mini
    ชื่อที่ไม่ซ้ำ 233,710
    ในจำนวนนั้น อยู่ใน Ultimate ด้วย ทั้งหมดยกเว้น 4 (รายการ marker ของ Hagezi)
    รายการของ Pro++ ที่ขาดจากชุดผสม 31,411 จาก 223,551
    ชื่อในชุดผสมที่มีเพียง Ultimate บล็อก 25,040

    การตรวจที่ผมใช้ไล่ขึ้นไปตามโดเมนแม่ เป็น script Python 3 ที่ไม่ต้องติดตั้งอะไรนอกจาก Python เอง script อยู่ก่อน ขั้นตอนหลังจากนั้นบอกวิธีบันทึกและรัน

    #!/usr/bin/env python3
    """hagezi_overlap.py - how much of blocklist A is already blocked by blocklist B.
    
    Reads two Hagezi lists in the wildcard format (the /wildcard/ files, the format
    OPNsense uses). A line "*.example.com" blocks example.com and every name under
    it, so an entry of A counts as covered when the entry itself, or one of its
    parent domains, is in B. A plain text comparison (comm, diff) misses that and
    reports too many differences.
    
    Usage:  python3 hagezi_overlap.py A.txt B.txt
    Author: Vivek Sanghi. Licence: CC BY-NC-SA 4.0, as the blog.
    """
    import re
    import sys
    
    WILDCARD = re.compile(r"^\*\.[a-z0-9_-]+(\.[a-z0-9_-]+)+$")
    
    
    def load(path):
        names = set()
        try:
            f = open(path, encoding="utf-8-sig")
        except OSError as e:
            sys.exit(f"{path}: cannot open ({e.strerror})")
        with f:
            for number, line in enumerate(f, 1):
                line = line.strip().lower()
                if not line or line.startswith("#"):
                    continue
                if not WILDCARD.match(line):
                    sys.exit(f"{path}, line {number}: not a wildcard-format line "
                             "('*.example.com'). Download the /wildcard/ version of the list.")
                names.add(line[2:])
        if not names:
            sys.exit(f"{path}: no entries found; check the download")
        return names
    
    
    def covered(name, blocked):
        while True:
            if name in blocked:
                return True
            if "." not in name:
                return False
            name = name.split(".", 1)[1]
    
    
    def main():
        if len(sys.argv) != 3:
            sys.exit("usage: hagezi_overlap.py A.txt B.txt")
        a, b = load(sys.argv[1]), load(sys.argv[2])
        missing = sorted(n for n in a if not covered(n, b))
        print(f"{sys.argv[1]}: {len(a):,} entries; {len(a) - len(missing):,} already "
              f"blocked by {sys.argv[2]}; {len(missing):,} not")
        for n in missing[:10]:
            print(f"  not covered: {n}")
        if len(missing) > 10:
            print(f"  ... and {len(missing) - 10:,} more")
    
    
    if __name__ == "__main__":
        main()
    

    ก่อนเริ่ม ส่วนนี้สำหรับ Windows PC คุณต้องมี Python 3 (ขั้นที่ 3 ตรวจให้) ขั้นตอนสร้างโฟลเดอร์ 1 โฟลเดอร์ในโฟลเดอร์ผู้ใช้ของคุณ ดาวน์โหลดไฟล์ list 2 ไฟล์ขนาดไม่กี่เมกะไบต์ลงไป และอ่านไฟล์เหล่านั้น ไม่เปลี่ยนอย่างอื่น ควรเผื่อเวลา 10 นาที เพื่อย้อนกลับ ให้ลบโฟลเดอร์ใน File Explorer บน Mac หรือ Linux ใช้ Terminal, python3 แทน py และ curl แทน curl.exe

    1. คลิกเมนู Start พิมพ์ powershell แล้วกด Enter หน้าต่างเปิดขึ้นพร้อม prompt ที่ขึ้นต้นด้วย PS
    2. สร้างโฟลเดอร์และเข้าไปในโฟลเดอร์นั้น แต่ละบรรทัดใช้เวลาครู่หนึ่ง รันทีละบรรทัด:

      mkdir hagezi-check
      cd hagezi-check

      prompt ควรลงท้ายด้วย hagezi-check ถ้าบรรทัดแรกบอกว่ามีโฟลเดอร์อยู่แล้ว ให้เลือกชื่ออื่นและใช้ในทั้งสองบรรทัด

    3. ตรวจว่าติดตั้ง Python แล้ว:

      py --version

      คุณควรเห็นบรรทัดเช่น Python 3.12.4 ถ้า PowerShell บอกว่าไม่รู้จัก py ให้ติดตั้ง Python 3 จาก python.org (ติ๊ก “Add python.exe to PATH” ใน installer) ปิด PowerShell และเริ่มใหม่ที่ขั้นที่ 1

    4. สร้างไฟล์ script ขั้นนี้จะเปิด Notepad:

      notepad hagezi_overlap.py

      Notepad ถามว่าจะสร้างไฟล์ใหม่หรือไม่ คลิก Yes วาง script จากกล่องด้านบน (คลิก Copy บนกล่อง แล้ว Ctrl + V ใน Notepad) กด Ctrl + S แล้วปิด Notepad ถ้า Notepad เปิดโดยไม่ถาม ให้บันทึกด้วย File, Save as พิมพ์ hagezi_overlap.py โดยใส่ในเครื่องหมายคำพูด เป็นชื่อไฟล์ ตรวจว่าโฟลเดอร์คือ hagezi-check แล้วคลิก Save

    5. ดาวน์โหลด list 2 รายการลงโฟลเดอร์ บน Windows พิมพ์ curl.exe ไม่ใช่ curl ใน PowerShell รันทีละบรรทัด:

      curl.exe -o pro.plus.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/pro.plus.mini.txt
      curl.exe -o ultimate.mini.txt https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/ultimate.mini.txt

      แต่ละบรรทัดใช้เวลาไม่กี่วินาทีและพิมพ์ตารางความคืบหน้า ถ้าบรรทัดใดลงท้ายด้วยข้อผิดพลาด ให้ตรวจการเชื่อมต่อและรันบรรทัดนั้นอีกครั้ง

    6. รันการตรวจ:

      py hagezi_overlap.py pro.plus.mini.txt ultimate.mini.txt
    7. บน list ที่ผมดาวน์โหลดสำหรับการตรวจนี้ มันพิมพ์ว่า:

      pro.plus.mini.txt: 98,704 entries; 98,703 already blocked by ultimate.mini.txt; 1 not
        not covered: h4g3z1-pro-plus-mini.web.app

      ตัวเลขของคุณจะต่างออกไป เพราะ list เปลี่ยนทุกวัน ถ้าคุณเห็นข้อความแทนตัวเลข แปลว่า script หยุดโดยตั้งใจ ให้อ่านข้อความนั้น เพราะมันระบุชื่อไฟล์และบรรทัด

    ชื่อที่เหลือ 1 ชื่อในแต่ละการเทียบคือ marker ที่ Hagezi ใส่ในทุก list (h4g3z1-<list>.web.app) เพื่อให้คุณรู้ว่าโหลด list ใดอยู่ ถ้าการดาวน์โหลดล้มเหลว หรือไฟล์อยู่ในรูปแบบอื่น script จะหยุดและบอกเช่นนั้น แทนที่จะรายงานตัวเลข

    สิ่งอื่นที่มันให้ บน list ชุดเดียวกัน:

    List A List B รายการของ A ที่ B บล็อกอยู่แล้ว
    Normal (171,454) Pro++ ทั้งหมดยกเว้น marker
    Pro++ (223,551) Ultimate ทั้งหมดยกเว้น marker
    Pro Mini (86,842) Ultimate Mini ทั้งหมดยกเว้น marker
    TIF Mini (212,777) TIF Medium ทั้งหมดยกเว้น marker
    Gambling Mini (118,888) Gambling Medium ทั้งหมดยกเว้น marker
    Fake (17,622) Pro++ ทั้งหมดยกเว้น marker
    Pop-Up Ads (48,277) Pro++ ทั้งหมดยกเว้น 4 (marker และอีก 3 รายการ)
    Badware Hoster (1,088) Pro++ 966
    Ultimate Mini (120,458) Pro++ 95,417

    script ถูกทดสอบกับ list เหล่านี้ และกับไฟล์ที่หายไป ไฟล์ว่าง ไฟล์ที่มีแต่ comment การดาวน์โหลดที่ล้มเหลว หน้าเว็บ และ list ในรูปแบบ adblock, hosts และ plain-domain

    จำนวนชื่อที่โหลดเข้ามาไม่ได้เปลี่ยนไปตามสิ่งที่ผมทำ ในวันที่ล้างครั้งแรก router โหลด 2,840,117 ชื่อก่อนล้าง และ 3,188,234 ชื่อหลังล้าง โดยใช้ 10 list แทน 18 list: ระหว่างการดาวน์โหลด 2 ครั้งในวันนั้น TIF โตขึ้น 426,519 รายการ ต่อมา โดยที่ผมไม่ได้เปลี่ยนอะไร จำนวนนี้เคลื่อนจาก 2,739,044 ไปเป็น 3,229,041 ใน 4 วัน จากขนาด list ที่ผมดาวน์โหลดสำหรับการตรวจนี้ ประมาณสองในสามของชื่ออยู่บน TIF และประมาณร้อยละ 7 อยู่บน Pro++

    เจาะลึก: ตัวเลขจาก router พร้อมข้อควรระวัง

    ชื่อที่โหลด จาก log ของ router (“blocklist loaded. length is …” คือจำนวนชื่อที่ไม่ซ้ำ):

    เมื่อใด List ชื่อที่โหลด
    วันล้างครั้งแรก ก่อนล้าง 18 list เดิม 2,840,117
    วันล้างครั้งแรก หลังล้าง ชุดใหม่ 3,188,234
    5 วันต่อมา ชุดเดิม 2,739,044
    9 วันต่อมา ชุดเดิม 3,229,041
    18 วันต่อมา ชุดเดิม 3,198,953

    สัดส่วนของ query ที่ถูกบล็อก จาก Reporting → Unbound DNS:

    ช่วงเวลา Query ถูกบล็อก
    วันล้างครั้งแรก อ่านในวันนั้น ไม่ได้บันทึก ร้อยละ 12.9
    ช่วงประมาณ 38 ชั่วโมง อ่านภายหลัง 110,248 8,600 (ร้อยละ 7.80)

    ค่าร้อยละทั้งสองครอบคลุม list ต่างกัน วันต่างกัน และสิ่งใดก็ตามที่เครือข่ายทำอยู่ในช่วงนั้น จึงไม่ใช่ก่อนและหลัง

    สิ่งที่ผมติ๊กตอนนี้

    การตั้งค่าบน router ของผมแสดง:

    • Hagezi Pro++ (full)
    • TIF (full)
    • Gambling (full)
    • Fake, Pop-Up Ads, Badware Hoster และ “Safesearch not supported”
    • OISD NSFW
    • list ของ Hagezi 2 รายการตาม URL ได้แก่เซิร์ฟเวอร์ encrypted-DNS และ tracker ของ LG TV
    • Abuse.ch ThreatFox ตาม URL พร้อม key ฟรี (ดูด้านล่าง)

    ผมเลือก Pro++ แทน Pro ที่ Hagezi แนะนำ เพื่อ tracker ของอุปกรณ์ เพราะ Pro++ คือที่ที่เขาบล็อกเกือบทั้งหมด

    2 รายการในนี้ซ้ำกัน cheat sheet ของ Hagezi ระบุว่า Fake และ Pop-Up Ads อยู่ใน Pro++ สำหรับ Fake ผลการวัดตรงกัน และเอาออกได้โดยไม่เปลี่ยนสิ่งที่ถูกบล็อก บน list ที่ผมดาวน์โหลด Pop-Up Ads มี 3 ชื่อที่ไม่มีใน Pro++, TIF, Gambling, Hoster หรือ Fake การทิ้งมันจะทำให้เสีย 3 ชื่อนั้น ผมไม่ได้เทียบ ThreatFox หรือ list 2 รายการที่ใส่ตาม URL Fake และ Pop-Up Ads ยังติ๊กอยู่ทั้งคู่

    ThreatFox หยุดดาวน์โหลด และตอนนี้ดาวน์โหลดได้อีกครั้ง ทุกการอัปเดตบันทึก “unable to download blocklist … and no cache available” ที่อยู่ที่รายการในตัวของ OPNsense ใช้สำหรับมันตอบ “410 Gone” และหน้า export ของ abuse.ch ขอ Auth-Key ก่อนจะให้ host file release 26.7 รุ่นหลังลบรายการในตัวออกด้วยเหตุนี้ และชี้ผู้ใช้ไปที่ “URLs of Blocklists” abuse.ch ออก key ให้ฟรีผ่านพอร์ทัลยืนยันตัวตนของตน ผมเพิ่ม list ด้วย URL โดยใส่ key ไว้ในที่อยู่ หน้า export ของ abuse.ch ขอ key ใน URL และตัวดาวน์โหลดของ OPNsense ไม่ส่ง header ใดเลย ขั้นตอนด้านล่างแสดงรูปแบบของที่อยู่ การอัปเดตที่เพิ่มมันบันทึก “blocklist download” ด้วย 28,889 บรรทัดสำหรับมัน เป็นชื่อ 28,869 ชื่อ และไม่มีข้อผิดพลาด list อื่นโหลดจาก cache ในการอัปเดตนั้น จากจำนวนชื่อที่โหลดตามที่ router นับเอง จำนวนเพิ่มจาก 2,765,172 เป็น 2,782,246 ดังนั้น 17,074 จาก 28,869 ชื่อยังไม่ได้ถูกโหลดอยู่แล้วภายใต้ชื่อที่ตรงตัวนั้น และประมาณ 11,800 ชื่อถูกโหลดอยู่แล้ว การนับเทียบชื่อตามตัวอักษร ชื่อที่โดเมนแม่ถูก list อื่นบล็อกอยู่แล้วจึงนับเป็นชื่อใหม่ Hagezi ไม่ระบุว่า ThreatFox เป็นแหล่งที่มา

    key ทำงานเหมือนรหัสผ่าน router เก็บมันไว้ใน configuration และทุกการอัปเดตเขียนที่อยู่ รวมทั้ง key ลงใน resolver log อย่าให้ key ปรากฏใน screenshot, log ที่แชร์, ไฟล์สำรอง configuration หรือ remote log server ที่ออกจากมือคุณไป ถ้ามันรั่ว ให้ขอ key ใหม่จากพอร์ทัลเดียวกันและเปลี่ยนที่อยู่

    เจาะลึก: เพิ่ม ThreatFox ด้วย key

    ก่อนเริ่ม ขั้นตอนนี้เพิ่ม list 1 รายการให้ policy ของคุณ ควรเผื่อเวลา 10 นาที ไม่มีอะไรถูกลบ เพื่อย้อนกลับ ให้ลบที่อยู่ออกจากช่องเดิมแล้ว apply อีกครั้ง

    1. ใน browser เปิด https://auth.abuse.ch สร้างบัญชีถ้ายังไม่มี และขอ Auth-Key key ใช้ได้ฟรี คัดลอกมันลงไฟล์ข้อความเฉพาะจนถึงขั้นที่ 4 ซึ่งคุณวางมันครั้งเดียว แล้วลบไฟล์นั้น
    2. ล็อกอินเข้า router คลิก Services แล้ว Unbound DNS แล้ว Blocklists
    3. ที่ปลายด้านขวาของแถว policy ของคุณ คลิกไอคอนดินสอ (Edit) หน้าต่างชื่อ Edit Blocklist เปิดขึ้น
    4. คลิกใน URLs of Blocklists และพิมพ์ที่อยู่ด้านล่าง โดยใส่ key ของคุณแทน YOUR_KEY และไม่มีช่องว่าง กด Enter เพื่อให้มันเป็น tag ของตัวเอง (tag คือ 1 รายการที่แสดงเป็นกล่องเล็กในช่อง):

      https://threatfox-api.abuse.ch/v2/files/exports/YOUR_KEY/hostfile.txt

      key อยู่ระหว่าง exports/ และ /hostfile.txt

    5. คลิก Save แล้ว Apply router ดาวน์โหลด list ใหม่อีกครั้ง รอ 1 ถึง 2 นาที

    6. คลิก Services, Unbound DNS, Log File ค้นหา download และติ๊ก Informational ในช่อง severity คุณควรเห็น “blocklist download:” และจำนวนบรรทัดสำหรับที่อยู่ ThreatFox ถ้าบรรทัดบอก “unable to download” ให้ตรวจ key และที่อยู่ว่ามีช่องว่างหลงอยู่หรือไม่
    7. อย่าแชร์หน้าจอนั้น บรรทัดนั้นแสดงที่อยู่พร้อม key ของคุณ
    เจาะลึก: Badware Hoster และ list 2 รายการที่เพิ่มด้วย URL

    Badware Hoster เป็น list เดี่ยวของ Hagezi และ 966 จาก 1,088 รายการของมันอยู่ใน Pro++ แล้ว ส่วนที่เหลือบล็อกผู้ให้บริการ hosting ทั้งรายที่โผล่ใน threat feed ซ้ำ ๆ Hagezi เตือนว่าเว็บไซต์ที่ถูกต้องบน host เหล่านั้นถูกบล็อกไปด้วย และปล่อยให้ผู้ที่รัน list เป็นคนปลดบล็อกเอง

    list 2 รายการที่เพิ่มด้วย URL เป็นของ Hagezi ในรูปแบบ wildcard:

    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/doh.txt
    https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/native.lgwebos.txt

    list แรกระบุเซิร์ฟเวอร์ encrypted-DNS ตามชื่อ เป็นส่วนหนึ่งของการกันไม่ให้อุปกรณ์เลี่ยง router list ที่สองระบุเซิร์ฟเวอร์โฆษณาและ tracking ของ LG webOS แต่ละรายการมีเรื่องของตัวเอง สำหรับโพสต์แยกต่างหาก

    tick-box ของ Hagezi ในตัวของ OPNsense 26.7 ดาวน์โหลดจาก mirror ของ Hagezi hagezi-mirror.dnsbunker.org ตามที่ log แสดง Hagezi บอกว่า mirror นั้นเผยแพร่ build ใหม่ราวทุก 4 ถึง 8 ชั่วโมง สำเนาจาก jsDelivr อัปเดตวันละครั้ง

    สิ่งที่ DNS บล็อกไม่ได้

    โฆษณาในแอป YouTube และ Instagram มาจากโดเมนเดียวกับวิดีโอและโพสต์ การบล็อกด้วยชื่อจึงบล็อกเนื้อหาไปด้วย FAQ ของ Hagezi กล่าวประเด็นทั่วไปไว้ว่า โฆษณาบางส่วนโหลดจากโดเมนเดียวกับเนื้อหา และ content blocker ใน browser หรือ blocker ระดับแอปบนโทรศัพท์คือชั้นที่จับมันได้ ผมยอมให้โฆษณาในแอปผ่านเข้ามา

    นอกจากนี้ DNS blocklist กรองเฉพาะอุปกรณ์ที่ถาม router อุปกรณ์ที่มี DNS แบบเข้ารหัสหรือ hard-coded ของตัวเองจะเลี่ยงมันไป นั่นเป็นอีกโพสต์หนึ่ง

    งานนี้ทำอย่างไร

    Claude อ่านเอกสารและ list เปรียบเทียบกัน และอ่าน router ของผมผ่าน session ใน browser ที่ผมล็อกอินไว้ ได้แก่การตั้งค่า resolver log และ tester ผมตัดสินว่าจะเปลี่ยนอะไร ใน session เรื่อง allowlist การเปลี่ยนแปลงเดียวบน router คือการเขียน allowlist ใหม่

    โมเดลผิดพลาดหลายเรื่อง การแก้ allowlist ด้วยชื่อเปล่ามาจาก session แรก และใน session หนึ่งมันยังบอกผมว่าการอัปเดต blocklist ตอนกลางคืนล้าง cache ของ Unbound log ของ router แสดงว่าการอัปเดตโหลด list เข้า Unbound ที่กำลังรันอยู่ โดยไม่ restart คู่มือบอกว่าการ apply การตั้งค่า blocklist ไม่ restart Unbound และ source โหลด list ใหม่เข้า process ที่กำลังรันอยู่ การตั้งค่า flush มีผลเฉพาะตอนที่ Unbound หยุด

    โมเดลที่มี session ล็อกอินบน router เป็นความเสี่ยงในตัวมันเอง resolver log ที่มันอ่านมีชื่อที่เว็บไซต์ใดก็ทำให้อุปกรณ์ lookup ได้ และชื่อหนึ่งอาจมีข้อความที่เขียนขึ้นเพื่อชักนำโมเดล ใน session เรื่อง allowlist ผมให้มันอ่านอย่างเดียว นอกจากการเปลี่ยน allowlist นั่นเป็นคำสั่งถึงโมเดล ไม่ใช่การควบคุม ผู้ใช้ OPNsense แบบอ่านอย่างเดียวจะเป็นการควบคุม resolver log ยังมีที่อยู่ ThreatFox พร้อม key ดังนั้น session ที่อ่าน log จะเห็น key ถ้าคุณให้โมเดลอ่าน log นั้น ให้เปลี่ยน key ภายหลัง

    ใน session แรก ผมยังเปลี่ยนการตั้งค่า Unbound 5 อย่างและ cron job 1 งาน router แสดงว่าทั้ง 6 อย่างตั้งค่าไว้

    เจาะลึก: แต่ละการตั้งค่า และวิธีย้อน DNS over TLS
    การตั้งค่า (หน้า) ก่อน หลัง
    Flush DNS Cache during reload (General) เปิด ปิด
    Prefetch Support (Advanced) ปิด เปิด
    Serve Expired Responses (Advanced) ปิด เปิด; TTL for Expired Responses 86,400 s
    Use System Nameservers (Query Forwarding) เปิด ปิด
    DNS over TLS forwarders ไม่มี Cloudflare และ Quad9
    งานอัปเดต blocklist (System → Settings → Cron) ช่วงเวลาที่ใช้ร่วมกับงานอื่น ช่วงเวลาของตัวเอง

    Prefetch รีเฟรชรายการยอดนิยมก่อนที่มันจะหมดอายุ คู่มือระบุต้นทุนไว้ที่ DNS traffic เพิ่มขึ้นประมาณร้อยละ 10

    Serve Expired Responses ตอบจาก cache ด้วย record ที่หมดอายุแล้ว แทนที่จะให้อุปกรณ์รอ เมื่อเปิด จะมีช่องเพิ่มขึ้น ช่อง “TTL for Expired Responses” จำกัดว่าหลังหมดอายุนานเท่าใดจึงยังให้คำตอบเก่าได้ ผมตั้ง 86,400 วินาที ซึ่งเป็นขอบล่างของช่วง 86,400 ถึง 259,200 ที่คู่มือแนะนำ

    ผลร่วมกันของสองการตั้งค่าที่ผมไม่ได้ทดสอบ เมื่อปิดการ flush cache และอนุญาตคำตอบที่เก่า ชื่อที่ list เพิ่งบล็อกอาจยังถูกตอบจาก cache ของ Unbound ต่อไปอีกระยะหนึ่ง ถ้าการบล็อกไม่มีผลทันที นั่นคือสิ่งแรกที่ผมจะดู

    Use System Nameservers คู่มือบอกว่า system nameserver ถูกเลือกก่อนรายการ catch-all ใด ๆ ใน Query Forwarding และ DNS over TLS การปิดมันทำให้รายการ DNS over TLS รับ query ไปแทน รายการทั้ง 4 ใต้ Services → Unbound DNS → DNS over TLS:

    Server IP Port Verify CN
    1.1.1.1 853 cloudflare-dns.com
    1.0.0.1 853 cloudflare-dns.com
    9.9.9.9 853 dns.quad9.net
    149.112.112.112 853 dns.quad9.net

    query ที่ router ส่งไปยังเซิร์ฟเวอร์เหล่านี้ออกไปแบบเข้ารหัส firewall rule ที่ปฏิเสธ port 853 จาก LAN เพื่อกันไม่ให้อุปกรณ์ใช้ DNS แบบเข้ารหัสของตัวเอง ไม่กระทบมัน เพราะมันออกจากตัว router เอง

    เวลาอัปเดต ถูกย้ายไปอยู่ในช่วงเวลาของตัวเอง เพื่อให้การอัปเดตไม่ใช้เวลาเดียวกับงานตามกำหนดอื่นอีก

    หากต้องการย้อนการเปลี่ยนแปลง DNS over TLS:

    ก่อนเริ่ม ขั้นตอนนี้เปลี่ยนการตั้งค่า DNS ของ router และใช้เวลา 5 นาที DNS ยังทำงานผ่านการตั้งค่าที่เหลืออยู่ จดรายการทั้ง 4 ไว้ก่อน (ตารางด้านบน) คุณต้องใช้มันเพื่อใส่การเปลี่ยนแปลงกลับคืน

    1. เปิดหน้าตั้งค่าของ router แล้ว sign in คุณควรเห็นหน้า Lobby
    2. คลิก Services แล้ว Unbound DNS แล้ว DNS over TLS ตารางแสดงรายการ
    3. ที่ปลายด้านขวาของแถวแรก คลิกไอคอนดินสอ (Edit) หน้าต่างชื่อ Edit server เปิดขึ้น เอาเครื่องหมายติ๊กออกจาก Enabled แล้วคลิก Save ทำเช่นเดียวกันกับแถวอื่นทุกแถว
    4. ที่ด้านบนของหน้าเดียวกัน ติ๊ก Use System Nameservers ช่องเดียวกันนี้ปรากฏใต้ Query Forwarding ด้วย มันเป็นการตั้งค่าเดียว
    5. คลิก Apply ที่ด้านล่างของหน้า Unbound โหลดใหม่ภายในไม่กี่วินาที
    6. ตรวจ จากอุปกรณ์ในเครือข่าย เปิดเว็บไซต์ใดก็ได้ที่คุณยังไม่ได้เข้าวันนี้ มันควรโหลดได้ ถ้าใน System → Settings → General ไม่มี nameserver เลย Unbound จะ resolve จาก root server เองแทนที่จะ forward ถ้าต้องการให้ใช้เซิร์ฟเวอร์ของผู้ให้บริการของคุณ ให้เพิ่มไว้ที่นั่น
    7. เพื่อใส่การเปลี่ยนแปลงกลับ ให้ติ๊ก Enabled ที่แต่ละรายการอีกครั้ง เอาเครื่องหมายติ๊กออกจาก Use System Nameservers และคลิก Apply

    แหล่งที่มา