pfSense DNS cache refresh interval

  • Is there a way to change the DNS cache refresh interval in pfSense ?

    Here is the issue I'm running into. pfSense is setup with a host alias to and a firewall rule to that destination.

    The issue I'm running into is that endpoint ( updates it's DNS fairly quickly, meaning that when a request from an app server goes to that endpoint it uses the most up to date entry but since pfSense is delayed it blocks the traffic (since it doesn't have the latest record).

  • LAYER 8 Global Moderator

    I show the ttl at 300 seconds.. from SOA, the default for filterdns updates is 300 seconds as well.

    You sure that is what your problem?

  • Rebel Alliance Developer Netgate

    It isn't that updates their DNS quickly, they return random results. You'll (almost?) never get the same result from a client and from the firewall even if they make the request at nearly the same time. You cannot reasonably use a hostname like that in an alias.

    Some people have taken addresses from the result of a DNS query and hardcoded them in host overrides, which can help, but will break if the hardcoded addresses ever stop being used by the site in question.

  • @jimp said in pfSense DNS cache refresh interval:

    It isn't that updates their DNS quickly, they return random results

    Your right I see it now they rotate their IP with each check and as John mentioned their TTL is 300.

    I see your point regarding keeping things in sync. Thanks for your thoughts, I will think about creating a solution on my side.

    Kudos to you guys for the fast responses.

  • This post is deleted!

  • LAYER 8 Global Moderator

    That is for "entries in the infrastructure host cache" defaults to 15 minutes. That has nothing to do with how long actual records looked up are cached.. Which will all be based upon the actual TTL on the record.

    He should not go messing with those numbers unless he actually understands what it does.

    It will have ZERO effect on the problem he is seeing. Which is the IPs given out by rotate all the time every time you do a query

    I am currently show these
    ; IN A

    ;; ANSWER SECTION: 300 IN A 300 IN A 300 IN A 300 IN A 300 IN A 300 IN A

    And each time a normal client resolves they will get 1 of those and they change - and they will change over time as well and depending on where exactly you do the query from, etc.

  • @johnpoz If pfSense cache for host aliases honors TTL, this case can then be resolved with a common caching layer.

    Any idea of pfSense honors the TTL when it refreshes the cache for host aliases ?

  • LAYER 8 Global Moderator

    I have never checked into the details of how filterdns does it? I would think it just loads the IPs into the table.

    And it just re resolves them every 300 seconds per the filterdns cmd line... I created a test alias with in it.. As you can see the table lists all the IPs I currently show for them.


    Lets say you query and you get a ttl of 90 seconds... I don't think the table entry would go away at the end of 90 seconds.

  • @johnpoz said in pfSense DNS cache refresh interval:

    I don't think the table entry would go away at the end of 90 seconds

    By go away you probably mean refresh :)

    According to the doc the default refresh interval for filterdns is 300 seconds like you mentioned.

    So my idea of using TTL with a common cache layer will not work unfortunately, too bad because it would be a clean solution.

    Perhaps I can trigger a refresh and build an automated process to do it. The doc doesn't have good info on filterdns, I'll try to dig into the code and see if I can find the command that triggers the refresh.

  • LAYER 8 Global Moderator

    No I am saying my guess, is that I look up that is in my alias that has a ttl of 10 seconds.. It puts that into the table.. That table will contain that IP forever, until filterdns updates it..

    That would be a guess!! But simple enough to test.. Let me put in a record that has say a 60 second ttl... And see if it is removed from the table after 60 seconds.. Even though filterdns only updates ever 300 seconds.

  • LAYER 8 Global Moderator

    Ok I just put in this host for test alias

    It as a rediculously low ttl of 60 seconds. Which I have complained to them about.. Its a domotz thing that just queries all day long for this - and since its ttl is so freaking short its a lot of freaking queries ;)

    Anyway - so I put this in alias..

    I then look in the table couple min latter - way past the ttl, and its still in the table.. Once something is put in the table it doesn't just remove itself once any sort of TTL would of expired.

  • @johnpoz said in pfSense DNS cache refresh interval:

    Once something is put in the table it doesn't just remove itself once any sort of TTL would of expired.

    Right, it doesn't honor the TTL. It appears to be hard coded to 300 seconds, during my test when I wait 300 seconds it refreshes the table with the new IP.

  • LAYER 8 Global Moderator

    So how do you think that is some sort of problem? The ttl of the records is 300 when you get them direct, only if you were getting your info from a forwarder could you get a lower ttl, which would mean you would just have to query it again when that ttl expired..

    You sure you just don't have a problem with using different ways to resolve so you would be getting different answers between what pfsense lookups and what your clients do - causing a mismatch in where the clients want to go and what is in your alias.

    If your forwarding you could for sure get some way different IPs then if you locally resolved..

    ; IN A

    ;; ANSWER SECTION: 270 IN A 270 IN A 270 IN A 270 IN A 270 IN A 270 IN A

    ;; Query time: 2 msec
    ;; SERVER:

    Asking for it..

    ; IN A

    ;; ANSWER SECTION: 258 IN A 258 IN A 258 IN A 258 IN A 258 IN A 258 IN A

    ;; Query time: 23 msec
    ;; SERVER:

  • LAYER 8 Global Moderator

    with the new IP.

    You mean the large list of IPs? Your table for only lists 1 IP?

  • @johnpoz

    Maybe I'm not thinking about this right but here is what I see happening during some tests.

    1. pfSense filterdns does a DNS lookup for and gets a TTL of 64 seconds max TTL is 300 seconds but depending on when you query it can be anything from 0 to 300.

    1. Since PfSense filterdns waits 300 seconds hard coded it will just wait and not honor the 64 TTL it originally received.

    2. App Server does a DNS query (separate than pfSense filterdns) for and gets a TTL of 64 seconds, it honors the 64 seconds and queries again when it expires.

    This creates a disconnect between pfSense and the App Server.

    There is one more point here in that you mentioned Google randomly returns IP addresses so for that case using a common DNS layer will ensure that the same IP is returned and managed based on the TTL.

    However, since pfSense filterdns does not honor TTL and just has a hard coded 300 seconds that will not work because of the disconnect that happens I mentioned above.

    It's possible I'm not thinking about something right but at the moment that is what I see.

  • @exocomp said in pfSense DNS cache refresh interval:

    pfSense filterdns does a DNS lookup for and gets a TTL of 64 seconds max TTL is 300 seconds but depending on when you query it can be anything from 0 to 300.

    This point above is interesting, if I query the the authoritative server ( for I get a TTL of 300 (which is the raw value). However, if I query a Non-authoritative server say (google public dns) I get the time remaining until the next refresh which could be anything from 0-300. I'm not sure what's going on there, I'll need to read up on how that works.

  • LAYER 8 Global Moderator

    When you ask a forwarder or upstream resolver if you will like its going to hand you the TTL of whats left on its cache... When you query authoritative you will always get the actual TTL the owner of the domain has set..

    fans of forwards don't normally understand this.. One of the many reasons why its better to resolve vs forward.. Which pfsense does out of the box for reasons ;)

    People say oh will when I forward I get a faster response, etc.. Well yeah - your just getting what is cached.. Could actually be WRONG for you based upon your IP and region, etc. And its also going to be a TTL that is less then what the owner wanted since its just whats left in the cache, unless there was no cache and it resolved it? Then you going to have to wait the time for it to resolver or forward plus the added time to query it where ever it is, etc. And if the TTL is not full, its possible it could be something really short and now your just going to have to query again way before you should have to, etc.

    If your clients are only asking pfsense for dns, no matter what pfsense does with the answers it gets back should be fine - My guess is you have your clients using different dns than pfsense or both? And you don't know where they are getting their answers from or what, etc. or if your using proxy in explicit mode it would do the queries, etc.

  • This post was really helpful in pointing me in the right direction and got to learn more about how pfSense host alias DNS works and a little more about DNS in general, I was able to come up with a solution given the need.

    Thanks for taking the time to help out.

  • LAYER 8 Global Moderator

    Any time - I could discuss DNS for hours and hours ;) So if you ever have any questions about DNS just post a thread I will more then likely see it and comment..

    The problem of when a firewall updates its aliases is problem with pretty much every firewall have worked with in the last 30 years when client might use or get something different. When there is more than 1 IP for some fqdn.. Be it based upon geo location of the query or some sort of roundrobin, or from a cache that resolves from a different location then the firewall/user, etc.

    It's not just pfsense that such issues can be seen that is for sure.. Blocking of url based stuff is normally done better with a proxy where the proxy so you can base the filter on the actual uri being requested vs the IP of said fqdn in the url.. Proxy also allows for filtering on path or other words in the url and not just the hostname portion, etc.

    DNS based lookups and blocking of the IP work fine when its static sort of IPs returned, but when your wanting to talk to something hosted on a CDN that returns lots of different IPs for the same fqdn then yeah you can run into complications.

Log in to reply