Creates an alias on the loopback interface (lo0) with the IP 127.0.0.2 on macOS.
- Install the plist to:
/Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
- Set mode:
sudo chmod 0644 /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
- Set owner:
sudo chown root:wheel /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
- 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>
under this line:
<string>127.0.0.2</string>
i added+used this one more line:
<string>up</string>
and, under these 2 lines:
<key>StandardOutPath</key>
<string>/var/log/loopback-alias.log</string>
i also added+used these 2 more lines:
<key>UserName</key>
<string>root</string>
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 127.0.0.2 -c 1
if displayed Property-List (plist) cannot start/load the alias based net-interface 127.0.0.2, then, in "Terminal" try below 2 commands:
sudo launchctl unload -w /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
sudo launchctl load -w /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
to stop the net-interface, in Terminal you can use below command:
/sbin/ifconfig lo0 inet 127.0.0.2 -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.127.0.0.2.plist
sudo launchctl load -w /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist