So still working on getting all my data transferred into Identity Management. I have my host data in the base DNS configuration. But we never set up the reverse DNS zones until yesterday. The issue is that I have nearly 1600 entries that I need to populate into their respective reverse DNS zones and I do not want to have to do this manually. I have script that I used to initially import the hosts into IPA, but I need to modify this somehow to run again only this time also populate the reverse DNS zones.
[root@kdc1 LDAP]# more nis-hosts.sh
#!/bin/sh
IFS=$'\n'
for line in $(cat /root/LDAP/nis-map.hosts); do
IFS=' '
ipaddress=$(echo $line | awk '{print $1}')
hostname=$(echo $line | awk '{print $2}')
master=$(ipa env xmlrpc_uri | tr -d '[:space:]' | cut -f3 -d: | cut -f3 -d/)
domain=$(ipa env domain | tr -d '[:space:]' | cut -f2 -d:)
if [ $(echo $hostname | grep "\." |wc -l) -eq 0 ] ; then
hostname=$(echo $hostname.$domain)
fi
zone=$(echo $hostname | cut -f2- -d.)
if [ $(ipa dnszone-show $zone 2>/dev/null | wc -l) -eq 0 ] ; then
ipa dnszone-add --name-server=$master --admin-email=root.$master
fi
ptrzone=$(echo $ipaddress | awk -F. '{print $3 "." $2 "." $1 ".in-addr.arpa."}')
if [ $(ipa dnszone-show $ptrzone 2>/dev/null | wc -l) -eq 0 ] ; then
ipa dnszone-add $ptrzone --name-server=$master --admin-email=root.$master
fi
# Now create this entry
ipa host-add $hostname --ip-address=$ipaddress --force
ipa host-show $hostname
done
My problem is that this throws an error “Nameserver for reverse zone cannot be a relative DNS name.” Everything on my IPA server looks correct, so I don’t know if this script is trying to do something hinky or what. Could use some extra eyes to help me sort this out.