LoginSignup
23
24

More than 5 years have passed since last update.

Vagrantで、ゲストOSからホストのIPを取得する方法

Last updated at Posted at 2015-03-22

http://stackoverflow.com/questions/19917148/tell-vagrant-the-ip-of-the-host-machine
を参考にすると下記。

netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10

あとは記事のようにrubyでやるなら下記とか。

development:
  host: <%= `netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10` %>

【追記】これで取れるアドレスには終端に改行が含まれるかもしれない。その場合にはstrip!とか使う。

23
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
24