Skip to content

Instantly share code, notes, and snippets.

Last active July 10, 2022 18:48
What would you like to do?
Creates a loopback alias with IP at startup on Mac OS X

Loopback Alias

Creates an alias on the loopback interface (lo0) with the IP on macOS.


  1. Install the plist to: /Library/LaunchDaemons/com.runlevel1.lo0.
  2. Set mode: sudo chmod 0644 /Library/LaunchDaemons/com.runlevel1.lo0.
  3. Set owner: sudo chown root:wheel /Library/LaunchDaemons/com.runlevel1.lo0.
  4. Load: sudo launchctl load /Library/LaunchDaemons/com.runlevel1.lo0.

The alias will automatically be created at startup from then on.

You can confirm the alias was created with ifconfig:

/tmp ❯❯❯ ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
       	inet6 ::1 prefixlen 128
       	inet netmask 0xff000000
       	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
       	inet netmask 0xff000000
       	nd6 options=1<PERFORMNUD>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
Copy link

atErik commented Oct 18, 2017

under this line:              <string></string>
i added+used this one more line:      <string>up</string>

and, under these 2 lines:      <key>StandardOutPath</key>
i also added+used these 2 more lines:

to view list of all net-interfaces, in "Terminal" window use below command:
    /sbin/ifconfig  -a

it is better to ping a local net-interface IP-address, to find out if its working or not:
    /sbin/ping  -c  1

if displayed Property-List (plist) cannot start/load the alias based net-interface, then, in "Terminal" try below 2 commands:
    sudo  launchctl  unload  -w  /Library/LaunchDaemons/com.runlevel1.lo0.
    sudo  launchctl  load  -w  /Library/LaunchDaemons/com.runlevel1.lo0.

to stop the net-interface, in Terminal you can use below command:
    /sbin/ifconfig  lo0  inet  -alias
note: the "launchctl unload ..." command, will not stop the alias net-interface, so to stop it, use above command manually.

if net-interface is stopped, then to start the net-interface again, use below 2 commands:
    sudo  launchctl  unload  -w  /Library/LaunchDaemons/com.runlevel1.lo0.
    sudo  launchctl  load  -w  /Library/LaunchDaemons/com.runlevel1.lo0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment