<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Using the <a href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Identity_Management_Guide/migrating-from-nis.html#nis-import-hosts" class="">sample script</a> 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:<div class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">./nis-hosts.sh nisname <a href="http://subdomain.ourdomain.edu" class="">subdomain.ourdomain.edu</a></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Zone name: </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">ipa: ERROR: 'name' is required</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">awk: cmd. line:1: {print $3 "." <a href="http://subdomain.ourdomain.edu" class="">subdomain.ourdomain.edu</a> "." nisname ".in-addr.arpa."}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">awk: cmd. line:1:                  ^ syntax error</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Zone name: subdomain</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">ipa: ERROR: DNS is not configured</span></div></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">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?</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">#!/bin/sh</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(141, 141, 141); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class=""># 1 is the nis domain, 2 is the nis master server</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">ypcat -d </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$1</span><span style="font-kerning: none" class=""> -h </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$2</span><span style="font-kerning: none" class=""> hosts | egrep -v </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">"localhost|127.0.0.1"</span><span style="font-kerning: none" class=""> > /dev/shm/nis-map.hosts 2>&1 </span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">IFS=$</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">'\n'</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">for</span><span style="font-kerning: none" class=""> line </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">in</span><span style="font-kerning: none" class=""> $(cat /dev/shm/nis-map.hosts); </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">do</span><span style="font-kerning: none" class="">  </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        IFS=</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">' '</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        ipaddress=$(echo </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$line</span><span style="font-kerning: none" class="">|awk </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">'{print $1}'</span><span style="font-kerning: none" class="">) </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        hostname=$(echo </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$line</span><span style="font-kerning: none" class="">|awk </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">'{print $2}'</span><span style="font-kerning: none" class="">) </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        master=$(ipa env xmlrpc_uri |tr -d </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">'[:space:]'</span><span style="font-kerning: none" class="">|cut -f3 -d:|cut -f3 -d/) </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        domain=$(ipa env domain|tr -d </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">'[:space:]'</span><span style="font-kerning: none" class="">|cut -f2 -d:) </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">if</span><span style="font-kerning: none" class=""> [ $(echo </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$hostname</span><span style="font-kerning: none" class="">|grep </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(250, 250, 210);" class="">"\."</span><span style="font-kerning: none" class=""> |wc -l) -eq 0 ]; </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">then</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">                hostname=$(echo </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$hostname</span><span style="font-kerning: none" class="">.</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$domain</span><span style="font-kerning: none" class="">) </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">fi</span><span style="font-kerning: none" class="">  </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        zone=$(echo </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$hostname</span><span style="font-kerning: none" class="">|cut -f2- -d.) </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">if</span><span style="font-kerning: none" class=""> [ $(ipa dnszone-show </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$zone</span><span style="font-kerning: none" class=""> 2>/dev/null | wc -l) -eq 0 ]; </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">then</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">                ipa dnszone-add --name-server=</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$master</span><span style="font-kerning: none" class=""> --admin-email=root.</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$master</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">fi</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(250, 250, 210); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(240, 240, 240);" class="">        ptrzone=$(echo </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$ipaddress</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(240, 240, 240);" class="">|awk -F. </span><span style="font-kerning: none" class="">'{print $3 "." $2 "." $1 ".in-addr.arpa."}'</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(240, 240, 240);" class="">)  </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">if</span><span style="font-kerning: none" class=""> [ $(ipa dnszone-show </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$ptrzone</span><span style="font-kerning: none" class=""> 2>/dev/null|wc -l) -eq 0 ]; </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">then</span><span style="font-kerning: none" class="">   </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">                ipa dnszone-add  </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$ptrzone</span><span style="font-kerning: none" class=""> --name-server=</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$master</span><span style="font-kerning: none" class=""> --admin-email=root.</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$master</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(255, 160, 122);" class="">fi</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(141, 141, 141); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(240, 240, 240);" class="">        </span><span style="font-kerning: none" class=""># Now create this entry  </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        ipa host-add </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$hostname</span><span style="font-kerning: none" class=""> --ip-address=</span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$ipaddress</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(240, 240, 240); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">        ipa host-show </span><span style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(202, 83, 128);" class="">$hostname</span><span style="font-kerning: none" class=""> </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Consolas; -webkit-text-stroke-color: rgb(255, 160, 122); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">done</span></div><div class=""><span style="font-kerning: none" class=""><br class=""></span></div></span></div></body></html>