joppot

コピペで絶対動く。説明を妥協しない

ソフトウェア

Allocate lo0 IP address using Mac login hook automatically

投稿日:

Pocket

Abstract

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.


Precondition

You use Mac.

Check the IP address of lo0

Fist you check the IP address allocated to mac lo0 with ifconfig command.

ifconfig

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.

touch ~/.lo0ip.sh

Open the file and write this code.

#!/bin/bash

sudo ifconfig lo0 alias 10.200.10.1/24


Save it.

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.

ifconfig



Conclusion

Using mac login hook, you can allocate any IP address without executing the IP address registration command every time.

スポンサードリンク

If you think this article is good, share it please

-ソフトウェア
-,

執筆者:


comment

Your email address will not be published. Required fields are marked *

関連記事

Atom imports React component using import-js 2.2.0

Abstract Hello everybody it’s me candle. In this time we will import the component path into the file using import-js and Atom automatically. React recommends to write one component in one file, when development becomes to be big, the number of component increase. If you use 10 components with one Container, you need to write 10 import statements. import-js helps us from such troublesome work. Precondition Already exist React web environment I recommend you use the react project created by create-react-app command which I wrote the before article. Atom was installed in your computer.

Limit the number of text characters in wordpress article index by plugin

English 日本語 Abstract Hello everybody, It’s candle. Nowadays, when I used free themes for wordpress at the company, I noticed that. Many free theme use the_content function which expands all the contents of individual articles in the article list, and it is very irritating. However, editing a free theme is troublesome. We use the “Advanced Excerpt” plugin to limit the number of characters displayed in the article list and make it easy to see. We use the free theme “twentyeleven” as a sample. Before After Premise There is a wordpress.

Fix emacs powerline character gets corruption(mojibake) on Mac standard terminal or iTerm2

Abstract Hello everyone it’s me candle. In this time I will show you how to fix emacs powerline character corruption(mojibake). I am referring to this site. https://griffio.github.io/utils/2016/01/26/Spacemacs-OSX-Term/ I will explain both iterm2 and mac standard terminal. In my case I launch the Emacs with iterm2, the arrow of powerline gets garbled. Let’s fix. Precondition You use emacs Your emacs was installed powerline. You use emacs with iTerm2 or mac standard terminal.

How to prevent preview from scrolling back to top in Atom’s Markdown

English 日本語 Abstract Hello everyone, it’s candle. Atom has a markdown preview function from the beginning. When markdown’s sentence becomes long, every time you edit it, the preview back to the top. And, you have to scroll every time to check. It is so tough, we will put a plug-in that will automatically adjust the preview. Premise Atom has been installed

Build flycheck + eslint environment supporting to react + es6 in Emacs.

Abstract Hello everyone it’s me candle. In this time let’s build emacs + eslint. There are many other syntax check packages such as jsHint, jsxHint, etc which check the coding rule of javascript. According to web info, these packages seem to be unable to adapt well with the latest javascript writing format such as React and es6. Nowadays eslint became to be mainstream. It has become used not only in emacs but also everywhere. I’m also emacs user, try it! I’m not a node JS and Elisp professional, it may contains useless writing or wrong writing. Please go easy on …

Profile


I work in the venture company as a CTO. I start to write program in University, first I learned java, C++ and PHP. In the company, I'm developing web services by Rails. I do like to automation.

スポンサードリンク

Archives