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

    Adding DNS Resolver Addresses using a script

    Scheduled Pinned Locked Moved DHCP and DNS
    2 Posts 2 Posters 152 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.
    • georgelzaG
      georgelza
      last edited by

      Hi all

      Is there a way to script adding entries.

      If someone can point me at a example would be great, building Kubernetes clusters with multiple nodes and multiple interfaces and ye... doing it at ui is getting a bit :(

      G

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

        @georgelza how I would do it is include some text file that contains your entries

        Example

        [24.03-RELEASE][admin@sg4860.home.arpa]/var/unbound: cat newhosts.conf 
        local-data: "newhost.newdomain.tld. A 10.11.12.13"
        local-data: "otherhost.otherdomain.tld. A 10.11.12.14"
        [24.03-RELEASE][admin@sg4860.home.arpa]/var/unbound: 
        

        So you could script adding whatever records you want in there like the above.. you can create ptr records as well with local-data-ptr:

        And then have your script restart unbound so those are loaded..

        unbound.jpg

        edit: btw, not really sure what might happen to that text file you create with your records on an update to pfsense or even the unbound package.. So you might want to keep a copy handy of what you put in there.

        Another way would be directly editing the xml to put your hosts in there as overrides - but that seems more complex and possible corruption of your configuration of pfsenses overall xml.. The loading of text file seems way less intrusive and easier to accomplish with simple script and less risk of borking something up.

        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 2
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.