DNS Registration Parallel to Windows registration

Lhsachs
Contributor II

Another \- NOT A CASPER ISSUE \- but one hopefully I'm the only one facing###

We are in a dynamic dns project here so users can get to their systems via its name. The goal is to parallel what they are planning to do in the windows world on the Mac. What they are planning to do in windows - in the Advanced TCP/IP Settings (windows) - on the DNS Pane:

Radio button - Append these DNS suffixes (in order) mycompany.com prod.mycompany.com client.mycompany.com

Have the dns suffiix for the connection be: client.mycompany.com,
Register this connection's address in dns (checked) Use the connection's dns suffix in dns registration (checked)

I have no problem getting the search domains to systems.

I don't know how to get these systems to register with DNS (yet)
There are 10.6 and 10.7 clients around the company.

This command below fails under 10.6, /usr/bin/net doesn't exist in 10.7:
/usr/bin/net -n mycomputer -W client.mycompany.com -P ads register

I found a nsupdate script that I haven't got working yet...

Anyone out there have a solution?

1 ACCEPTED SOLUTION

Lhsachs
Contributor II

After a bunch of work, I have an answer and thought I'd share it with all... It is easy to get the info from the mac, harder to script to nsupdate... I was able to work it line by line until I realized all I had to do was create a text file with the commands needed and nsupdate the text file. Updated so you don't try to update your dns if away from the company's network. The kicker - a launchd plist in /Library/LaunchDaemons activates the script on startup, login, or if there are changes in /Library/Preferences/SystemConfiguration

#!/bin/sh
##1st get the domain you are on##
vdomain=`cat /var/run/resolv.conf | awk '/domain/ {print $2}'`
echo $vdomain

##if not on mycompany.com domain exit##
if [ $vdomain != "mycompany.com" ]; then
        echo "we are not in kansas"
        exit 0
else
        echo "run the mycompany.com script"
fi

computernm=`scutil --get ComputerName`
echo $computernm
ipaddr=`/sbin/ifconfig en0 | awk '/inet / {print$2}'`
echo $ipaddr
##if $ipaddr empty - go for en1###
if [ -z "$ipaddr" ]; then
    echo "get en1"
    ipaddr=`/sbin/ifconfig en1 | awk '/inet / {print$2}'`
    echo "$ipaddr en1"
fi
dnsdelete="update delete $computernm.client.mycompany.com A"
echo $dnsdelete
#echo "update add $computernm.client.mycompany.com 86400 A $ipaddr"
dnsupdate="update add $computernm.client.mycompany.com 86400 A $ipaddr"
#echo $dnsupdate

echo $dnsdelete > /tmp/nsupdate
echo $dnsupdate >> /tmp/nsupdate
echo send >> /tmp/nsupdate
echo quit >> /tmp/nsupdate

#cat /tmp/nsupdate
nsupdate -v /tmp/nsupdate
echo "dns updated"

View solution in original post

7 REPLIES 7

talkingmoose
Moderator
Moderator

Your DNS server needs to allow registration either by clients or by DHCP on behalf of clients. Search suffixes don't really have anything to do DNS registration that I'm aware.

In our environment the act of binding a Mac to Active Directory automatically adds a record to DNS with Mac's host name plus our Active Directory domain. Active Directory domains and network domains that are assigned by DHCP aren't always the same.

Lhsachs
Contributor II

Well, in this environment not all systems are bound to AD...and I can't do forward and reverse lookups on systems that I know are bound to AD...

I attempting to tame a wild horse.....

and I've been requested to do as stated above - send a registration - as per the plan for windows clients...

Lhsachs
Contributor II

Well, in this environment not all systems are bound to AD...and I can't do forward and reverse lookups on systems that I know are bound to AD...

I attempting to tame a wild horse.....

and I've been requested to do as stated above - send a registration - as per the plan for windows clients...

talkingmoose
Moderator
Moderator

So then, do you know if your DNS servers accept DHCP registrations made on behalf of your clients? I think you'll need this enabled if you're not binding your Macs to your Windows domain.

Lhsachs
Contributor II

Major point of information - NO systems have dns record now. That is why the choice was made above - so, there is a need to register the macs using the client.mycompany.com

  1. I've been told that DNS servers accept DHCP registrations on behalf of clients
  2. All systems imaged or re-imaged using Casper are bound to AD
  3. All users are admins....(herding cats..)
  4. Working hard to have customers buy in to using Casper (via wiki pages, and when assisting - and needing to deliver software)

Looking for a command to register with systems with dns...(planning to use launchd to run it so dns is updated)

talkingmoose
Moderator
Moderator

Hmm... If that doesn't do it then something is more than likely configured wrong on the server side and not the Mac side. If you try to ping a Mac from a Windows machine using just the host name or its FQDN then are you not getting a response?

If DNS isn't getting your registration then use the command line nsupdate and see if that works for you. I really don't think you should need to use this but I don't know your environment either.

Lhsachs
Contributor II

After a bunch of work, I have an answer and thought I'd share it with all... It is easy to get the info from the mac, harder to script to nsupdate... I was able to work it line by line until I realized all I had to do was create a text file with the commands needed and nsupdate the text file. Updated so you don't try to update your dns if away from the company's network. The kicker - a launchd plist in /Library/LaunchDaemons activates the script on startup, login, or if there are changes in /Library/Preferences/SystemConfiguration

#!/bin/sh
##1st get the domain you are on##
vdomain=`cat /var/run/resolv.conf | awk '/domain/ {print $2}'`
echo $vdomain

##if not on mycompany.com domain exit##
if [ $vdomain != "mycompany.com" ]; then
        echo "we are not in kansas"
        exit 0
else
        echo "run the mycompany.com script"
fi

computernm=`scutil --get ComputerName`
echo $computernm
ipaddr=`/sbin/ifconfig en0 | awk '/inet / {print$2}'`
echo $ipaddr
##if $ipaddr empty - go for en1###
if [ -z "$ipaddr" ]; then
    echo "get en1"
    ipaddr=`/sbin/ifconfig en1 | awk '/inet / {print$2}'`
    echo "$ipaddr en1"
fi
dnsdelete="update delete $computernm.client.mycompany.com A"
echo $dnsdelete
#echo "update add $computernm.client.mycompany.com 86400 A $ipaddr"
dnsupdate="update add $computernm.client.mycompany.com 86400 A $ipaddr"
#echo $dnsupdate

echo $dnsdelete > /tmp/nsupdate
echo $dnsupdate >> /tmp/nsupdate
echo send >> /tmp/nsupdate
echo quit >> /tmp/nsupdate

#cat /tmp/nsupdate
nsupdate -v /tmp/nsupdate
echo "dns updated"