Skip to Content

Reply to comment

How to use the changeip command to modify the FQDN of a Mac OS X Server

I was recently faced with having to change the domain name on a Mac OS X Server. If I had to do this on a Windows machine, it would be a relatively simple process using a GUI interface. However, on a Mac server, there isn't (as of version 10.6.8) a way to change the fully qualified domain name (FQDN) via a GUI. Thankfully, there is a way to change the domain settings using the CLI and it's a piece of cake.

The changeip command was created to allow administrators to change the ip address and FQDN in static config files on a Mac OS X Server. For example, if you setup the DNS and iCal services, instead of manually updating the config files associated with these services, simply running the changeip command updates the files for you. 

The syntax for the command is as follows:

sudo changeip 10.1.2.3 10.3.2.1 old.name.local new.domain.local

This command would assume you wanted to change the IP address from 10.1.2.3 to 10.3.2.1 and the fqdn from old.name.local to new.domain.local. If you want to keep the IP address the same and simply change the fqdn, the syntax would be as follows:

sudo changeip 10.1.2.3 10.1.2.3 old.name.local new.domain.local

If you only want to change the IP address, simply omit the fqdn's from the end of the command and only list the old and new IP addresses.

For reference, the help message and man page for the command are listed below:

osx:~ admin$ changeip
See the man page ("man changeip") for full details.

Usage: changeip -h
       Print this help message.

Usage: changeip -checkhostname
       Validate current IP & hostname with DNS.

Usage: changeip (oldip) (newip)
       Change IP addresses in supported configuration files, e.g.
         changeip 10.0.1.10 10.0.1.12

Usage: changeip (oldip) (newip) [(oldhost) (newhost)]
       Change IP addresses and host names in supported files, e.g.
         changeip 10.0.1.10 10.0.1.12 server10.example.com server12.example.com

/usr/sbin/changeip must be run as root


MAN Page:

NAME
     changeip -- Change service configuration files with hard-coded IP
     addresses

SYNOPSIS
     changeip [-v] [-d path] old-ip new-ip [old-hostname new-hostname]

     changeip -checkhostname

     changeip -h

DESCRIPTION
     changeip is used to manually update configuration records when a
     server's IP address or hostname changed in a way that affected services
     were unable to properly process, for example when the server is behind
     a NAT device and the WAN identity changed.

     In typical usage, this command is used by an administrator to correct
     affected services when a server's network information changes.
     changeip can be invoked before the change is applied; in such an invo-
     cation, the arguments consist of the server's current and pending IP
     addresses, and optionally the existing and new host name.  Their usage
     and valid values include:
     old-ip        If the IP address has not yet been changed, this is the
                   existing IP address of the server. If the IP has already
                   been changed, this is the previous address. (This is the
                   value that will be replaced in the server's relevant con-
                   figuration files.)
     new-ip        If the IP address has not yet been changed, this is the
                   IP address that will be assigned to the server. If the IP
                   has already been changed, this is the existing IP
                   address. This value will replace old-ip in the machine's
                   configuration.
     old-hostname  As with old-ip, the existing or previous fully qualified
                   domain name ("FQDN" or sometimes "DNS name") for this
                   server. If only the IP address was affected, this argu-
                   ment and the next may be omitted.
     new-hostname  If old-hostname was provided, this argument must also be
                   provided. The machine's fully qualified domain name and
                   related service configuration will be set to this value.

     Once the tool has successfully completed, the administrator must change
     the machine's network settings in the Network Control Panel to match
     new-ip (if new-ip is not the current IP) and immediately reboot the
     server.

     The second invocation, -checkhostname, provides a diagnostic tool that
     compares the current IP address and hostname to the information
     returned by DNS.

     The final invocation prints usage information.

     changeip must be run as root.

OPTIONS
     The following options are available:
     -d path      Iterate over the executables in path instead of the
                  default /usr/libexec/changeip.

     -h           Print usage summary and exit.

     -v           Run verbosely, that is with additional diagnostic output.

FILES & FOLDERS
     /usr/sbin/changeip
           -   daemon
     /usr/libexec/changeip/
           -   directory containing service-specific tools

EXAMPLES
     This would be a typical invocation for a server redeployment:
           changeip 192.0.0.12 192.0.1.10 old.example.com new.example.com

     It is also possible to leave the host name intact and only change the
     IP address:
           changeip 192.0.0.12 192.0.1.10

     Its complement could be used to change only the host names, perhaps
     because the DNS tables have been changed:
           changeip 192.0.0.12 192.0.0.12 old.example.com new.example.com
     Note how the IP addresses are required, but that they are identical.

DIAGNOSTICS
     The changeip utility exits 0 on success, and >0 if an error occurs.

     changeip must be run as root.  Because changeip modifies system-wide
     resources, it must be executed by the root user.

     Invalid IP Address:  One of the IP address arguments was invalid.

SEE ALSO
     dscl(1), DirectoryServiceAttributes(7), DirectoryService(8), scutil(8)

KNOWN ISSUES
     The script does not perform the actual change of IP address; this is by
     design.

HISTORY
     A version of changeip has been present in Mac OS X Server since at
     least version 10.3 (Panther).

     In 10.6 (Snow Leopard), changeip no longer manipulates the directory
     and therefore no longer takes a directory URL as an argument.

Your rating: None Average: 2 (1 vote)

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
To prevent automated spam submissions leave this field empty.


Dr. Radut