Hello everyone it’s me candle.
In this time we would like to use the login hook of Mac and automatically allocate the local ip address.
You can use the default 127.0.0.1 lolcal IP address on your Mac.
However when using it with docker, you need to prepare other local IP address separately.
You use Mac.
Check the IP address of lo0
Fist you check the IP address allocated to mac lo0 with ifconfig command.
You can see the 127.0.0.1
Make a sh file which allocates IP address
Let’s make the shell script file which allocates IP address.
Open the file and write this code.
#!/bin/bash sudo ifconfig lo0 alias 10.200.10.1/24
As a supplemental explanation, In general it seems to be allocated 127.0.0.2 or 127.0.0.3 etc.
However in my case, since I couldn’t use that IP address in docker, I choose the IP address written in the docker official page.
Register to Mac login hook
Grant execution permission to the created lo0ip.sh.
chmod u+x ~/.lo0ip.sh
Next change the executable user so that the root user can execute it.
suso chown root:wheel ~/.lo0ip.sh
The file state is like this.
Register to login hook.
sudo defaults write com.apple.loginwindow LoginHook ~/.lo0ip.sh
You can confirm it with this command.
sudo defaults read com.apple.loginwindow LoginHook
how does it work
Restart the Mac PC and run ifconfig command.
Using mac login hook, you can allocate any IP address without executing the IP address registration command every time.