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