Skip to content

Instantly share code, notes, and snippets.

@chukaofili
Last active June 30, 2018 15:17
Show Gist options
  • Select an option

  • Save chukaofili/35a10074d8e8e1c10d8e5fe7e27062de to your computer and use it in GitHub Desktop.

Select an option

Save chukaofili/35a10074d8e8e1c10d8e5fe7e27062de to your computer and use it in GitHub Desktop.
Persistent LoopBack Alias

Loopback Alias

Creates an alias on the loopback interface (lo0) with the IP 200.0.0.1 on Mac OS X.

Installation

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

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

You can confirm the alias was created with ifconfig:

$ ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
		options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
		inet 127.0.0.1 netmask 0xff000000
		inet6 ::1 prefixlen 128
		inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
		inet 200.0.0.1 netmask 0xffffff00
		nd6 options=201<PERFORMNUD,DAD>
<?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.200.0.0.1</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/sbin/ifconfig</string>
<string>lo0</string>
<string>alias</string>
<string>200.0.0.1</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