Skip to content

Instantly share code, notes, and snippets.

@166MMX
Forked from brandt/README.md
Created February 19, 2020 14:41
Show Gist options
  • Save 166MMX/7b4ef0a9af64108f07f37a9ffef5e8cf to your computer and use it in GitHub Desktop.
Save 166MMX/7b4ef0a9af64108f07f37a9ffef5e8cf to your computer and use it in GitHub Desktop.
Creates a loopback alias with IP 127.0.0.2 at startup on Mac OS X

Loopback Alias

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

Installation

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

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
       	options=3<RXCSUM,TXCSUM>
       	inet6 ::1 prefixlen 128
       	inet 127.0.0.1 netmask 0xff000000
       	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
       	inet 127.0.0.2 netmask 0xff000000
       	nd6 options=1<PERFORMNUD>
<?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.runlevel1.lo0.127.0.0.2</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/sbin/ifconfig</string>
<string>lo0</string>
<string>alias</string>
<string>127.0.0.2</string>
</array>
<key>StandardErrorPath</key>
<string>/var/log/loopback-alias.log</string>
<key>StandardOutPath</key>
<string>/var/log/loopback-alias.log</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment