How do I create a static permanent ifconfig alias? How do I get this ifconfig loopback alias change to persist after a restart?

$ sudo ifconfig lo0 alias 172.16.222.111
$ ifconfig
lo0: flags=8049&lt;UP,LOOPBACK,RUNNING,MULTICAST&gt; mtu 16384
    options=1203&lt;RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP&gt;
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 172.16.222.111 netmask 0xffff0000          ### &lt;-- WANTED!!!
    nd6 options=201&lt;PERFORMNUD,DAD&gt;


The only similar instructions I've found are for nonexistent OSX files on other *nix systems for files like /etc/network/interfaces or /etc/sysconfig/networking-scripts/ifcfg-eth0.
Generally speaking, you can create the persistent alias in Network in System Preferences.




However, the lo0 loopback device doesn't show up here.  For this special case, we need to utilize launchd to kick off a short script with the ifconfig command you used above.

Here is a sample .plist file, saved as com.user.lo0-loopback.plist (can be saved anywhere as it will be copied to the appropriate directory later).

&lt;?xml version="1.0" encoding="UTF-8"?&gt; 
&lt;!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd &gt; 
&lt;plist version="1.0"&gt; 
&lt;dict&gt; 
  &lt;key&gt;Label&lt;/key&gt; 
  &lt;string&gt;com.user.lo0-loopback&lt;/string&gt; 
  &lt;key&gt;ProgramArguments&lt;/key&gt; 
  &lt;array&gt; 
    &lt;string&gt;/sbin/ifconfig&lt;/string&gt; 
    &lt;string&gt;lo0&lt;/string&gt; 
    &lt;string&gt;alias&lt;/string&gt; 
    &lt;string&gt;172.16.222.111&lt;/string&gt; 
  &lt;/array&gt; 
  &lt;key&gt;RunAtLoad&lt;/key&gt; &lt;true/&gt; 
  &lt;key&gt;Nice&lt;/key&gt; 
  &lt;integer&gt;10&lt;/integer&gt; 
  &lt;key&gt;KeepAlive&lt;/key&gt; 
  &lt;false/&gt; 
  &lt;key&gt;AbandonProcessGroup&lt;/key&gt; 
  &lt;true/&gt; 
  &lt;key&gt;StandardErrorPath&lt;/key&gt; 
  &lt;string&gt;/var/log/loopback-alias.log&lt;/string&gt; 
  &lt;key&gt;StandardOutPath&lt;/key&gt; 
  &lt;string&gt;/var/log/loopback-alias.log&lt;/string&gt; 
&lt;/dict&gt; 
&lt;/plist&gt;


Next, move it to the /Library/LaunchDaemons/ directory so it's kicked off at boot (will be run as root) and set the correct permissions

$ cp com.user.lo0-loopback.plist /Library/LaunchDaemons/ 

$ chmod 0644 /Library/LaunchDaemons/com.user.lo0-loopback.plist 
$ chown root:wheel /Library/LaunchDaemons/com.user.lo0-loopback.plist


Then load it with launchctl

$ launchctl load /Library/LaunchDaemons/com.user.lo0-loopback.plist


Reboot and your lo0 loopback should have an alias IP assigned to it that will be persistent across reboots.