Create file /Library/LaunchDaemons/yourname.plist with the following content:
<plist version="1.0"> <dict> <key>Label</key> <string>Your Label</string> <key>ProgramArguments</key> <array> <string>/sbin/ifconfig</string> <string>lo0</string> <string>alias</string> <string>127.0.0.2</string> <string>netmask</string> <string>255.255.255.0</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
and reboot the machine.
Latest posts by saki (see all)
- Ext, Angular, React, and Vue - 27. June 2019
- The Site Resurgence - 11. February 2018
- Configuring ViewModel Hierarchy - 19. June 2015
I rarely comment, however after browsing a bunch of remarks on How to add an IP address to loopback interface on Mac | Saki’s Blog. I actually do have 2 questions for you if it’s okay.
Could it be just me or does it look like some of these responses look as if they are coming from brain dead visitors?
😛 And, if you are posting on additional online social
sites, I’d like to follow you. Would you make a list of every one of your social networking sites like your twitter feed, Facebook page or linkedin profile?
127.0.0.2 myhost.local myhost
to /etc/hosts is not enough as it doesn’t create IP on lo adapter. I’ve tested it right now on SL 10.6.5.
I should have explained better: The point here is not if mask is “usual or not” neither if I have to reboot or not. Sure I do not need to reboot as it is enough to run command:
sudo ifconfig lo0 127.0.0.2 netmask 255.255.255.0
The whole point is how to make this change permanent so I do not need to run this command after each reboot. Therefore the reboot in the original post: to verify that everything went right.
With the release of Snow Leopard, there is a watcher on /etc/hosts…
just do your edits there, like under any other *nix, and the changes will get picked up immediately.
SL will also automatically update other places like /private/etc/hosts afterwards.
First, netmask for loopback interface usually is 255.0.0.0.
Second, reboot just to add address sounds very oldfashioned.
Third, at least under linux, one could use any 127.x.y.z addresses without setting any alias at all. I often use ssh -L 127.x.y.z:2222:10.x.y.z:22 user@gw commands to access boxes behind firewall when VPNs do not work. And I don’t have to setup any aliases. lo0 does the magic.