Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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
1
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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.

1
Comments on this Answer
Comment made 2 months ago by san2hosh 57

Gilles MOULIN did you find answer for your question?

0
Comment made 2 months ago by Gilles MOULIN 12

no offically supported solution... only scripts.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
There is currently no tmsh interface into the zonerunner/named/bind database. It is on a roadmap.
0
Comments on this Answer
Comment made 07-Oct-2013 by TomL 0
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
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Bump - I have the same question as Tom.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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.

0
Comments on this Answer
Comment made 20-Aug-2014 by Nylgia 0
I would be interested in the perl scripts. Thanks!
0
Comment made 18-Jan-2015 by jg.abaitua 1
Hello Faintly Lucky, can you please also let me see your perl scripts for managing DNS records over CLI?
0
Comment made 20-Jul-2016 by neenee 0

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

0
Comment made 2 months ago by san2hosh 57

Hey Lucky. Can you please provide your pearl script for managing the DNS records through CLI.

0