2回くらいハマったので自分用メモ
問題
ホストマシンからVagrantで立ち上げたUbuntuに, private_networkで指定したアドレスでアクセス出来ない. sshは繋げる.
$ vagrant up
Configuring and enabling network interfaces...
/Applications/Vagrant/embedded/gems/gems/net-scp-1.1.2/lib/net/scp.rb:392:in `await_response_state': Using /home/vagrant/.rvm/gems/ruby-2.0.0-p247 (RuntimeError)
...
Configuring and enabling network interfaces...
のあとスタックトレースが出るが, VM自体は立ち上がっている状態.
host $ ping 192.168.33.18
PING 192.168.33.18 (192.168.33.18): 56 data bytes
Request timeout for icmp_seq 0
解決
VirtualBoxでの設定が必要な気もするがとりあえずUbuntu上だけで解決するための手順をメモ.
まず, ifconfig
で確認するとeth0とloしかない. ここにeth1を追加したい.
host $ cat Vagrantfile
config.vm.box = "ubuntu"
config.vm.network :private_network, ip: "192.168.33.18"
...
vm $ sudo vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
+ auto eth1
+ iface eth1 inet static
+ address 192.168.33.18 # <== Vagrantfileに書いたIPと合わせる
+ netmask 255.255.255.0
vm $ sudo /etc/init.d/networking restart
これでprivate_networkが意図通り動くようになった.
host $ ping 192.168.33.18
PING 192.168.33.18 (192.168.33.18): 56 data bytes
64 bytes from 192.168.33.18: icmp_seq=0 ttl=64 time=0.321 ms