OS X equivalent to ipconfig /registerdns?

15,476

Solution 1

You can use nsupdate, either in interactive mode or with a script like this one I made :

#!/bin/sh

# en0 = ethernet - en1 = airport - choose the right interface !
IPADDR=`/sbin/ifconfig en0 | grep 'inet ' | awk '{print $2}'`
HOSTNAME=`hostname -f`

# Optionally set the name server (if not present, it uses system default).
#echo server "${DNSSERVER}" > $TMPDIR/nsupdate

# Change > to >> if name server set.
echo update delete "${HOSTNAME}" A > $TMPDIR/nsupdate
echo update add "${HOSTNAME}" 86400 A "${IPADDR}" >> $TMPDIR/nsupdate
echo show >> $TMPDIR/nsupdate
echo send >> $TMPDIR/nsupdate

nsupdate $TMPDIR/nsupdate

This script simply delete any previous A record, then register a new one.

Solution 2

You can get DHCP to update DNS for you when it hands out a lease to a client, by enabling dynamic updates. Take a look at this KB article for details on how to set it up.

Share:
15,476

Related videos on Youtube

user1364702
Author by

user1364702

Sysadmin, Assister for Users of Technology, Writer of Words, and Flixer of Nets

Updated on September 17, 2022

Comments

  • user1364702
    user1364702 over 1 year

    Network is running a number of Mac's with Snow Leopard and having issues with DNS resolution (running Windows Active Directory environment with Windows DHCP handing out leases). Is there a way to get the Mac to force registration of the system name with the DNS server (or some way to get DHCP to register the name with the DNS server) the way Windows can be forced to do so with "ipconfig /registerdns"?

    Is there something inherent to the way Windows does DHCP/DNS that isn't quite standard?

  • Philip
    Philip about 14 years
    You can set an option on the DHCP server to update DNS for clients that do not support dynamic updates (MS assumes all non-windows computers do not support it).
  • Philip
    Philip about 14 years
    You also have to make sure the DNS server will accept non-secured updates. If the record already exists you may have to set permissions on the record so that the OSX client can update the record (or just delete the record).
  • chrish
    chrish almost 13 years
    When I execute 'hostname -f', I get "mycomputername.local" which doesn't seen to be good to use. I used: HOSTNAME=hostname -s and DOMAIN=networksetup -getsearchdomains ethernet | head -n 1 And then used "${HOSTNAME}.${DOMAIN}" in the update statements. I had to explicitly set the search domain since the one returned from DHCP (which show in gray text in the network preferences panel) is not returned by /usr/sbin/networksetup.