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

$ sudo ifconfig lo0 alias
$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    inet netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet netmask 0xffff0000          ### <-- WANTED!!!
    nd6 options=201<PERFORMNUD,DAD>

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.

1 Answer 1


Generally speaking, you can create the persistent alias in Network in System Preferences.

enter image description here enter image description here

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"> 
  <key>RunAtLoad</key> <true/> 

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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .