OS X: Add a loopback alias

To add then delete a loopback IP addresse (like on OS X:

sudo ifconfig lo0 alias
sudo ifconfig lo0 -alias

Useful when you wish to map multiple local domain names in /etc/hosts to various virtual local hosts.

The changes will vanish after a restart, but a comment on the source article describes how to keep the changes permanently.

Source: Aaron Douglas

References about loopback addresses: