Forum Discussion

James_78615's avatar
James_78615
Icon for Nimbostratus rankNimbostratus
Mar 15, 2010

Create zonefile records on GTM using TMSH

Hi,

 

 

Is it possible to create SOA records on the GTM using the command line tmsh?

 

 

I can create a new WIP with the following:

 

 

tmsh

 

gtm

 

create wideip test.example.com pools add { Test_Pool }

 

 

However, the above commands use the GTM hostname for the SOA details such as 'Master Server' and 'Email Contact'.

 

 

Instead of using the internal hostname, I want to create the SOA and NS records using a globally available domain name.

 

 

I can do this using Zonerunner from the web GUI but I want to be able to script it from the command line.

 

 

There is the following method that describes making modifications to the zonefile but I would prefer something from the tmsh that does not require manually freezing the zonefile:

 

https://support.f5.com/kb/en-us/solutions/public/5000/700/sol5739.html

 

 

Thanks

 

James

18 Replies

  • Mark_Crosland_2's avatar
    Mark_Crosland_2
    Historic F5 Account
    There is currently no tmsh interface into the zonerunner/named/bind database. It is on a roadmap.
    • TomL_122341's avatar
      TomL_122341
      Icon for Nimbostratus rankNimbostratus
      Hi, is this still on the roadmap or has this been released? I have been searching for an answer to this specific question and almost gave up until I found this thread. Thanks, Tom
  • Gents, I know that this isn't exactly what you're looking for, but if you're handy with iControl, you can add a second step to your plan and write/run a script that will change the SOA values for you. Check out Management::ResourceRecord::update_soa in the iControl wiki. I use scripts to add/delete/modify A and MX records now instead of the GUI.

     

    Even with the initial development time for the scripts, I've saved countless hours by not having to use the GUI. I can provide code samples in Perl because that's what I write in, but any other language and you're on your own.

     

    • jg_abaitua's avatar
      jg_abaitua
      Icon for Altostratus rankAltostratus
      Hello Faintly Lucky, can you please also let me see your perl scripts for managing DNS records over CLI?
    • neenee_208438's avatar
      neenee_208438
      Icon for Nimbostratus rankNimbostratus

      Same here, Faintly Lucky. Can you provide some perl samples?

       

  • Gents, I know that this isn't exactly what you're looking for, but if you're handy with iControl, you can add a second step to your plan and write/run a script that will change the SOA values for you. Check out Management::ResourceRecord::update_soa in the iControl wiki. I use scripts to add/delete/modify A and MX records now instead of the GUI.

     

    Even with the initial development time for the scripts, I've saved countless hours by not having to use the GUI. I can provide code samples in Perl because that's what I write in, but any other language and you're on your own.

     

    • jg_abaitua's avatar
      jg_abaitua
      Icon for Altostratus rankAltostratus
      Hello Faintly Lucky, can you please also let me see your perl scripts for managing DNS records over CLI?
    • neenee_208438's avatar
      neenee_208438
      Icon for Nimbostratus rankNimbostratus

      Same here, Faintly Lucky. Can you provide some perl samples?

       

  • I also wanted to control zonerunner. Specifically to create 'static' resource records like MX and TXT records. I stumbled across a little shell that seems to be what does the work for the configuration gui: zrsh. Variables, designated @VariableName@, are injected from my management tool- below are some examples of the format.

    @Zone@ = 'example.com'
    @EscapedZone@ = 'example\.com'
    @RecordType@ = 'MX'
    @DesiredRecords@ = '"external example.com. example.com. 3600 MX 10 smtp.example.com." "external example.com. example.com. 3600 MX 20 smtp1.example.com." "external example.com. example.com. 3600 MX 20 smtp2.example.com."'
    @Authority@ = 'dns.example.com'
    

    Here's the script I ended up with:

    !/bin/sh
    
    ZoneFile=/tmp/newzone.external.@Zone@.
    Zone=@Zone@
    RecordType=@RecordType@
    ZoneExists=0
    DesiredRecords=(@DesiredRecords@)
    Authority=@Authority@
    
     Check if zone exists
    echo "listzones" | zrsh | awk '{ print $2 }' | grep '^@EscapedZone@\.$' && ZoneExists=1
    
     If zone didn't exist, create it
    if [ $ZoneExists -eq 0 ]; then
       Create Zone File Defaults
      ISODate=`date +%Y%m%d`
    cat << EOF > ${ZoneFile}
      \$ORIGIN .
      \$TTL 500        ; 8 minutes 20 seconds
      ${Zone}.            IN SOA  ${Authority}. hostmaster.${Zone}. (
      ${ISODate}01 ; serial (YYYYMMDDVV)
                                      10800      ; refresh (3 hours)
                                      3600       ; retry (1 hour)
                                      604800     ; expire (1 week)
                                      60         ; minimum (1 minute)
                                      )
      \$TTL 0  ; 0 seconds
                              NS      ${Authority}.
      \$TTL 3600       ; 1 hour
      \$ORIGIN ${Zone}.
      \$TTL 0  ; 0 seconds
    EOF
    
      echo "addZoneFile external @Zone@. master db.external.@Zone@. \"${ZoneFile}\"" | zrsh
    
      rm -f ${ZoneFile}
    fi
    
     Strip existing static records
    echo "displayzone @Zone@." | zrsh | grep '@RecordType@' | awk '{ cmd=sprintf("echo ''delrr external %s %s %s %s %s %s'' | zrsh ", $1, $1, $2, $4, $5, $6); system(cmd) }'
    
     Set desired static records
    for i in "${DesiredRecords[@]}"; do 
      echo "addrr $i" | zrsh; 
    done
    
  • Does anyone knows how to create a slave zone with zrsh ??

     

    I have a hundreds of zone to create on my GTM as slave and I cannot resign myself to use the webUI !

     

    Except this article, I found no other example of use of zrsh.

     

  • It baffles me to this day how this has not been accomplished for going on 12+ years now. Especially with Automation. It is painful to use the iControl SOAP interface. It works, but we know it is being deprecated and what then ... SSH again?