To add an alias interface in osx on the loopback interface with the ip 127.0.0.2 run the command

sudo ifconfig lo0 alias 127.0.0.2

then, to remove it again run the command

sudo ifconfig lo0 -alias 127.0.0.2