Domain – CentOS7 – DNS register only succeeds every third time

active-directorycentos7domaindomain-name-system

I have a CentOS 7.2 installation used for VDI, which is joined automatically into Microsoft 2008 R2 Domain (DCs are 2012 R2) at provisioning by using a bash script. AD join with the command "net ads join -U 'Administrator%Passw0rd'" is successful (verified with "net ads testjoin", "net ads info" and "wbinfo -u"). DNS registration is unsuccessful.
The DNS registration directly during the join fails with "DNS update failed!".
Registering the linux manually using "net ads dns register -U 'Administrator%Passw0rd'" succeeds only every third time:

[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'                                                                                                                                                       DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_UPDATE_FAILED
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_GSS_ERROR
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
Successfully registered hostname with DNS
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_UPDATE_FAILED
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_GSS_ERROR
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
Successfully registered hostname with DNS
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_UPDATE_FAILED
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_GSS_ERROR
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
Successfully registered hostname with DNS
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_UPDATE_FAILED
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_GSS_ERROR
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
Successfully registered hostname with DNS
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_UPDATE_FAILED
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
DNS Update for vw-centos7-001.lab.mycompany.ch failed: ERROR_DNS_GSS_ERROR
DNS update failed!
[root@vW-CentOS7-001 administrator]# net ads dns register -U 'Administrator%Passw0rd'
Successfully registered hostname with DNS
[root@vW-CentOS7-001 administrator]#

The issues persists if I define a specific domain controller (-S) when running "net ads dns register" as well as master_kdc in krb5.conf.
There is nothing regarding dns or register in the Samba log files (" egrep -iR 'dns|register' /var/log/samba/").
Why does it fails two out of three times?
What do I have to do that I do not need to register it three times in my script?

Best Answer

Ensure you have multiple DNS servers configured

Add DHCP_HOSTNAME=<hostname_of_machine> in /etc/sysconfig/network-scripts/ifcfg-eth0 file (if the interface is in fact eth0).

Run service network restart.

Run net ads join -U administrator command.

Also; In the /etc/hosts file can you confirm the 127.0.0.1 entry has your intended hostname.. for example 127.0.0.1 mymachine.mycompany.com mymachine