I configured our Linux servers to offer Samba service. The Samba servers were joined to our Active Directory, so that users could use the Windows machines to access the Samba servers without authentication. This worked quite well for several weeks, until the day my users reported that they could no longer access the Samba servers. I checked the Samba service, and it was still running fine. I found out later that the problem was not the Samba server; it was the DNS registration. What went wrong with the DNS registration was that all the entries regarding the Samba servers were gone. The users had to re-register again.
To prevent this problem from happening again, I wrote a simple script to register them and edited the crontab to run them automatically. The script requires expect package. You’ll have to install it before you can run the script. Here is the listing of the script.
#!/usr/bin/expect spawn ntpdate 0.us.pool.ntp.org spawn net ads dns register -U your_username expect "password:" send "your_passwd\r" expect eof
The first spawn command is optional. The purpose is to synchronize your computer’s time with the NTP server. You do not have to do it if your computer’s time is accurate.
This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.