Using the sample script 
 I’m trying to use hosts that are in various states meaning they could be 
powered off or disconnected, in our 2 campuses. We maintain a “master” 
/etc/hosts file just to document how are static IP’s are assigned. When I try 
to use the script I get asked for the zone name for each host. We use the DNS 
of the university rather than running one on the FreeIPA Fedora 25 server. This 
is a new install so I can redo this as needed. Here’s what I get:

./ nisname
Zone name: 
ipa: ERROR: 'name' is required
awk: cmd. line:1: {print $3 "." "." nisname 
awk: cmd. line:1:                  ^ syntax error

Zone name: subdomain
ipa: ERROR: DNS is not configured

Note I’m using our real domain and subdomain from above. The script is below. 
Can I hard code our domain and/or sub-domain some where in the script to get 
around the Zone name being prompted for each host?

# 1 is the nis domain, 2 is the nis master server
ypcat -d $1 -h $2 hosts | egrep -v "localhost|" > 
/dev/shm/nis-map.hosts 2>&1 
for line in $(cat /dev/shm/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) 
        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 
        ptrzone=$(echo $ipaddress|awk -F. '{print $3 "." $2 "." $1 
        if [ $(ipa dnszone-show $ptrzone 2>/dev/null|wc -l) -eq 0 ]; then   
                ipa dnszone-add  $ptrzone --name-server=$master 
        # Now create this entry  
        ipa host-add $hostname --ip-address=$ipaddress 
        ipa host-show $hostname 

Manage your subscription for the Freeipa-users mailing list:
Go to for more info on the project
  • ... Robert Kudyba
    • ... Rob Crittenden
      • ... Robert Kudyba
        • ... List dedicated to discussions about use, configuration and deployment of the IPA server.

Reply via email to