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

    Unbound redirect to a picture

    Scheduled Pinned Locked Moved General pfSense Questions
    5 Posts 4 Posters 3.2k 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.
    • R
      ren22
      last edited by

      hi

      i am using unbound (Thx to the Dev's) to block some bad domains like ads.com

      i am using the redirect rules to directing the query to 127.0.0.1

      local-zone: "ads.com" redirect
      local-data: "ads.com A 127.0.0.1"
      

      everything works so far great but in the browser
      now it looks ugly if your on a page with frames and inside there is 404not found messages.

      is there any way to display just a white 1x1px image, and not 404notfound mesages, or so without putting any webserver aditional to pfsense?

      regards

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

        strange….

        my new redirecting test:

        local-zone: "ads.com" redirect
        local-data: "ads.com A 127.0.0.1/1x1.gif"
        

        or

        local-zone: "ads.com" redirect
        local-data: "ads.com A https://127.0.0.1/1x1.gif"
        

        i tried to redirect it to another host but the i cant start unbound cause the logs of unbound pints out this:

        Mar  7 21:52:19 pfsense unbound: [57058:0] error: Bad local-data RR ads.com A 127.0.0.1/1x1.gif
        Mar  7 21:52:19 pfsense unbound: [57058:0] fatal error: Could not set up local zones
        Mar  7 21:52:25 pfsense unbound: [73875:0] warning: did not exit gracefully last time (57058)
        Mar  7 21:52:25 pfsense unbound: [73994:0] error: error parsing local-data 'ads.com A https://127.0.0.1/1x1.gif': Syntax error, could not parse the RR's rdata
        

        any idea how to redirect to http(s)://host/image.gif ?

        regards

        1 Reply Last reply Reply Quote 0
        • D
          doktornotor Banned
          last edited by

          OMG. This is a DNS server. You need to set up a webserver to serve 1x1.gif as default (index) page, not stick whacky invalid stuff into DNS server A records!

          P.S. On that note, 127.0.0.1 is not a good choice for this purpose since you'd obviously have to have the webserver running on all the client machines.

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

            While its not a issue redirecting say anything.ads.com to some webserver.  if your just hitting say http://something.ads.com/ your webserver could serve up default page say index.html that only has a 1x1.jpg or something.

            What about if the url is say https://something.ads.com/somepath/dir/ad.html ?  Since this does not exist on whatever webserver you point to your webserver would normally return 404, and your browser might bark that the SSL on the https isn't trusted.  So you would need to make sure your browsers trust whatever ssl cert your using..

            Its normally easier to just run a ad blocking addon in your browser to block ads.  Or just have your dns not return anything vs redirecting to something else.

            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
            • jimpJ
              jimp Rebel Alliance Developer Netgate
              last edited by

              @johnpoz:

              What about if the url is say https://something.ads.com/somepath/dir/ad.html ?  Since this does not exist on whatever webserver you point to your webserver would normally return 404, and your browser might bark that the SSL on the https isn't trusted.  So you would need to make sure your browsers trust whatever ssl cert your using..

              That's still up to the web server. It's quite easy in Apache to have it answer any request with a specific file via mod_rewrite or similar. Other web server software probably has a similar mechanism. Beyond the scope of the forum here, but it turns up easy in a google search, or just look at what CMS packages like Wordpress use in their .htaccess files.

              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

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