Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HOWTO: Transparently block all ads on home / work network

    Scheduled Pinned Locked Moved webGUI
    26 Posts 15 Posters 36.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mr. Jingles
      last edited by

      Well, I rebooted the box and hoped for the best. It appears it is now running and I am allowed to visit this fine forum via Squid  :-X

      Yet, Maxamoto, the result is not what I expected when I visit newgrounds, per the attached screenshot.

      I did notice that little 'alert generated by Opera', 'though. So I checked in firefox and internet explorer, and there it does not show that alert, but it leaves the space blank (second pic). But then you never know if there was an ad there, or something else 'important'.

      Do you experience the same?

      2013-11-11_134900.jpg
      2013-11-11_134900.jpg_thumb
      Internetexplorerandfirefox.jpg
      Internetexplorerandfirefox.jpg_thumb

      6 and a half billion people know that they are stupid, agressive, lower life forms.

      1 Reply Last reply Reply Quote 0
      • M
        Maxamoto
        last edited by

        The second screenshot you posted is what I get in Linux Mint with FF or Chromium and on Windows running IE, FF or Chrome. I've never really used Opera so I don't know what it's doing there, or why. Seems kinda pointless.

        Anyway, I would say you've achieved the result we were looking for with your second screenshot. If you're running into issues with pages / images being blocked that you don't want blocked just grep the blacklist and take it out :)

        1 Reply Last reply Reply Quote 0
        • V
          vincom
          last edited by

          got this to work, yeh, my initial prob was dansguardian, i disabled it but i forgot to change the proxy interface to point to lan in the squid general page as it was set to loopback. its so simple once you figure out your mistakes, its nice and light and should not overwhelm and basic hw setup

          Image3.jpg
          Image3.jpg_thumb

          1 Reply Last reply Reply Quote 0
          • S
            SpankIt
            last edited by

            Thanks for writing this how to. It worked great. I did go a step further and added some automation in order to update the definitions once a week using crontab and the following script I hacked together.

            
            #!/bin/sh
            
            PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/"
            
            # Blacklist Removal
            rm /var/squid/acl/blacklist.acl
            
            # Blacklist Download
            wget -O /var/squid/acl/blacklist.acl "http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex&showintro="
            
            # Set Permissions
            chown proxy:proxy /var/squid/acl/blacklist.acl
            
            # Restarting Squid
            killall -9 squid
            squid
            
            
            1 Reply Last reply Reply Quote 0
            • C
              cplmayo
              last edited by

              @SpankIt:

              Thanks for writing this how to. It worked great. I did go a step further and added some automation in order to update the definitions once a week using crontab and the following script I hacked together.

              
              #!/bin/sh
              
              PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/"
              
              # Blacklist Removal
              rm /var/squid/acl/blacklist.acl
              
              # Blacklist Download
              wget -O /var/squid/acl/blacklist.acl "http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex&showintro="
              
              # Set Permissions
              chown proxy:proxy /var/squid/acl/blacklist.acl
              
              # Restarting Squid
              killall -9 squid
              squid
              
              

              I think I did the same thing using the cron package on pfsense. Is there anyway to double check this?

              1 Reply Last reply Reply Quote 0
              • R
                Reiner030
                last edited by

                @Maxamoto:

                if you are running the webGUI on SSL, try switching it to regular HTTP, restarting squid and Ctrl+F5 on your client to force it to reload the page with the new config. Hopefully that will set you right!

                better:

                • deactivate https redirect rule in advanded section

                • optionally install package Filer if you have editable content

                • install package vHosts

                • create a vhost on port 80 for your static content which would be go to /usr/local/vhosts/

                • put with scp content in this folder

                • reference your content by url

                so you have secured WebGUI for administration and "free" available content for your users

                1 Reply Last reply Reply Quote 0
                • ExolonE
                  Exolon
                  last edited by

                  @SpankIt:

                  
                  # Blacklist Download
                  wget -O /var/squid/acl/blacklist.acl "http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex&showintro="
                  
                  

                  This is downloading an HTML file, if you look at the start and end, there are HTML tags, best to add the &mimetype=plaintext like this:

                  
                  # Blacklist Download
                  wget -O /var/squid/acl/blacklist.acl "http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex&mimetype=plaintext&showintro="
                  
                  

                  Is there any need to kill Squid?

                  @SpankIt:

                  
                  # Restarting Squid
                  killall -9 squid
                  squid
                  
                  

                  Could you not use the reconfigure parameter:

                  
                  # Restarting Squid
                  squid -k reconfigure
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • A
                    angst
                    last edited by

                    I can confirm this works with squid 2, just add the deny line in the custom config box, it works exactly the same as far as I can see as squid 3. Full Install v2.1. Thanks Maximoto, really clear, consise guide one of the best on this subject I have read.

                    1 Reply Last reply Reply Quote 0
                    • N
                      nextear
                      last edited by

                      Thanks so much for doing this!  It works great!  To automate the updates (per above)

                      • Install package Cron

                      • Install package Filer

                      • In WebGui, select Diagnostics/Filer and create file "/usr/local/bin/update-blacklist", permissions of 744

                      • In WebGui, Services/Cron create a new entry to run "/usr/local/bin/update-blacklist" periodically (I do once a week)

                      #!/bin/sh
                      
                      PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/"
                      
                      #mount as rw
                      /etc/rc.conf_mount_rw
                      
                      # Blacklist Removal
                      rm /var/squid/acl/blacklist.acl
                      
                      # Blacklist Download
                      fetch -qno /var/squid/acl/blacklist.acl "http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex&mimetype=plaintext&showintro="
                      
                      # Set Permissions
                      chown proxy:proxy /var/squid/acl/blacklist.acl
                      
                      #mount as ro
                      /etc/rc.conf_mount_ro
                      
                      # Restarting Squid
                      squid -k reconfigure
                      

                      Thanks again!

                      1 Reply Last reply Reply Quote 0
                      • E
                        Escorpiom
                        last edited by

                        Awesome, works on 2.2 beta!

                        So easy, yet effective.
                        Only one question:
                        I've got about 8 vlan's.
                        Do I have to put every vlan interface IP address in the "integration" and "acl" section?
                        Or is it possible to use a wildcard?

                        Cheers.

                        1 Reply Last reply Reply Quote 0
                        • T
                          tong
                          last edited by

                          @nextear:

                          Thanks so much for doing this!  It works great!  To automate the updates (per above)

                          • Install package Cron

                          • Install package Filer

                          • In WebGui, select Diagnostics/Filer and create file "/usr/local/bin/update-blacklist", permissions of 744

                          • In WebGui, Services/Cron create a new entry to run "/usr/local/bin/update-blacklist" periodically (I do once a week)

                          #!/bin/sh
                          
                          PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/"
                          
                          #mount as rw
                          /etc/rc.conf_mount_rw
                          
                          # Blacklist Removal
                          rm /var/squid/acl/blacklist.acl
                          
                          # Blacklist Download
                          fetch -qno /var/squid/acl/blacklist.acl "http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex&mimetype=plaintext&showintro="
                          
                          # Set Permissions
                          chown proxy:proxy /var/squid/acl/blacklist.acl
                          
                          #mount as ro
                          /etc/rc.conf_mount_ro
                          
                          # Restarting Squid
                          squid -k reconfigure
                          

                          Thanks again!

                          How do I add these:

                          
                          S1="http://pgl.yoyo.org/as/serverlist.php?hostformat=nohtml"  #44K
                          S2="http://mirror1.malwaredomains.com/files/justdomains"    #189K
                          S3="http://www.malwaredomainlist.com/hostslist/hosts.txt"   #97K
                          S4="http://winhelp2002.mvps.org/hosts.txt"              #620K
                          S5="http://hosts-file.net/hphosts-partial.asp"              #460K
                          S6="http://hostsfile.mine.nu/Hosts"                         #2641K
                          S7="http://support.it-mate.co.uk/downloads/hosts.txt"       #3851K
                          
                          

                          to the update list so that it grabs all the sites, sifts through them and deletes doubles, then block all of them?

                          I used to use these when my router was a "dumber" device running tomato firmware, and this combined list is well into the 800,000 range of blocked add sites.  I literally used to only see and add maybe once or twice a month, weather video or banner.

                          In case people are wondering these sites come from: http://www.linksysinfo.org/index.php?threads/all-u-need-ad-blocking.33191/
                          maybe it might be helpfull for some of the code too.  Unfortunately I'm nowhere near skilled enough to figure this out myself.

                          1 Reply Last reply Reply Quote 0
                          • K
                            kilobit
                            last edited by

                            @tong:

                            @nextear:

                            Thanks so much for doing this!  It works great!  To automate the updates (per above)

                            • Install package Cron

                            • Install package Filer

                            • In WebGui, select Diagnostics/Filer and create file "/usr/local/bin/update-blacklist", permissions of 744

                            • In WebGui, Services/Cron create a new entry to run "/usr/local/bin/update-blacklist" periodically (I do once a week)

                            #!/bin/sh
                            
                            PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/"
                            
                            #mount as rw
                            /etc/rc.conf_mount_rw
                            
                            # Blacklist Removal
                            rm /var/squid/acl/blacklist.acl
                            
                            # Blacklist Download
                            fetch -qno /var/squid/acl/blacklist.acl "http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex&mimetype=plaintext&showintro="
                            
                            # Set Permissions
                            chown proxy:proxy /var/squid/acl/blacklist.acl
                            
                            #mount as ro
                            /etc/rc.conf_mount_ro
                            
                            # Restarting Squid
                            squid -k reconfigure
                            

                            Thanks again!

                            How do I add these:

                            
                            S1="http://pgl.yoyo.org/as/serverlist.php?hostformat=nohtml"  #44K
                            S2="http://mirror1.malwaredomains.com/files/justdomains"    #189K
                            S3="http://www.malwaredomainlist.com/hostslist/hosts.txt"   #97K
                            S4="http://winhelp2002.mvps.org/hosts.txt"              #620K
                            S5="http://hosts-file.net/hphosts-partial.asp"              #460K
                            S6="http://hostsfile.mine.nu/Hosts"                         #2641K
                            S7="http://support.it-mate.co.uk/downloads/hosts.txt"       #3851K
                            
                            

                            to the update list so that it grabs all the sites, sifts through them and deletes doubles, then block all of them?

                            I used to use these when my router was a "dumber" device running tomato firmware, and this combined list is well into the 800,000 range of blocked add sites.  I literally used to only see and add maybe once or twice a month, weather video or banner.

                            In case people are wondering these sites come from: http://www.linksysinfo.org/index.php?threads/all-u-need-ad-blocking.33191/
                            maybe it might be helpfull for some of the code too.  Unfortunately I'm nowhere near skilled enough to figure this out myself.

                            Just wondering if you figured this out and if so if you wouldnt mind posting how. Thanks

                            1 Reply Last reply Reply Quote 0
                            • KOMK
                              KOM
                              last edited by

                              This is an old thread.  Lately, you can get the same results using a blacklist along with squidGuard.

                              1 Reply Last reply Reply Quote 0
                              • johnpozJ
                                johnpoz LAYER 8 Global Moderator
                                last edited by

                                Or you could just use blacklist in unbound..  That same yoyo.org link they listed has the list in unbound.. Just load the file into unbound and all the ad domains just get redirect to 127.0.0.1

                                An intelligent man is sometimes forced to be drunk to spend time with his fools
                                If you get confused: Listen to the Music Play
                                Please don't Chat/PM me for help, unless mod related
                                SG-4860 24.11 | Lab VMs 2.8, 24.11

                                1 Reply Last reply Reply Quote 0
                                • M
                                  Maxamoto
                                  last edited by

                                  I wasn't aware that unbound or SquidGuard offered the ability to replace ads with a transparent gif. Redirecting to 127.0.0.1 will leave errors all over the page where the ads used to be; replacing with a transparent gif at least keeps it looking clean. Aesthetics :)

                                  1 Reply Last reply Reply Quote 0
                                  • C
                                    C0RR0SIVE
                                    last edited by

                                    Squidguard has an option at General Settings, under Miscellaneous for "Clean Advertising"  Works pretty good for me.

                                    1 Reply Last reply Reply Quote 0
                                    • KOMK
                                      KOM
                                      last edited by

                                      Yes, it's amazing what you find when you take the time to look.

                                      1 Reply Last reply Reply Quote 0
                                      • M
                                        Mr. Jingles
                                        last edited by

                                        @johnpoz:

                                        Or you could just use blacklist in unbound..  That same yoyo.org link they listed has the list in unbound.. Just load the file into unbound and all the ad domains just get redirect to 127.0.0.1

                                        This is very interesting. How would one load the list in unbound with a script, similar to the way we can load it into Squid with the script?

                                        It would appear it needs to be merged with /var/unbound/access_lists.conf, but how?

                                        6 and a half billion people know that they are stupid, agressive, lower life forms.

                                        1 Reply Last reply Reply Quote 0
                                        • First post
                                          Last post
                                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.