This tutorial shows how to make your DNS server contain up-to-date DNS CNAME values, according to which workstation the user is logged in.
Example: User foo uses Windows station bar. The administrator would like to access his PC for doing some tasks via VNC, SMB etc. As it is more comfortable to lease DHCP IPs to workstations and users might often change their workstations, it would be quite useful to have a CNAME foo.yourdomain.local to quickly access the right computer.
Note: The solution below is not a useful way for every local network, as it could be used improperly, e.g. important existing DNS CNAMEs could be overwritten. So make sure you can trust your local users not to use it for improper tasks.
- Create a network share which every user has write access to, e.g. \\myserver\user_pc
- In the Windows group policy object of your choice, add a startup script „user_pc.bat“ with this content:
Shell12echo %username% > \\files\gposoftware\user_pc\pc\%computername%.txtecho %computername% > \\files\gposoftware\user_pc\user\%username%.txt
(The second line is optional, but it may be useful)
- Test it; you should get text files as soon as users log on.
- Download dnsupdater and place it into a directory, e.g. on your domain controller.
- Edit the config file: Enter the path where the text files are created and updated, your local domain name, etc.
- Run the .exe file and watch your DNS server entries. The application watches the textfile directory. When a file gets new content, it updates the CNAME entry on the server.
- If it works, you can run the .exe as a Windows service, e.g. with NSSM
Note: Dots in Windows usernames like „firstname.lastname“ are removed for the CNAME entry („firstnamelastname.yourdomain.local“).