Help us understand the problem. What is going on with this article?

vagrantがbridge接続できなかった時の対処法

More than 5 years have passed since last update.

概要

macでvagrant導入して開発環境構築したんですが、
いざ同一LANのデバイスからアクセスしようとしてみたらうまくいかなかった。

macのfirewallは切ってあるし、他のサーバ立ててみたら
リモートデバイスからアクセスできたので、vagrantの設定が問題でした。

試行錯誤してうまくいかなかったのでバージョンアップして再起動してどーーんで解決。
一応経緯をメモとして残しておきます。

メモ

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "centos64"

  config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box"

  config.vm.network :private_network, ip: "192.168.33.11"

  config.vm.network :public_network

  config.vm.synced_folder "./", "/vagrant", owner: 'vagrant', group: 'vagrant', mount_options: ['dmode=777', 'fmode=777']
  config.vm.provider :virtualbox do |vb|
    vb.gui = false
  end
end

networkでpublicからも接続できるよう選択

vagrant upのときににbridge接続するデバイスを選択。

en0を選択
Screen Shot 2014-05-17 at 18.17.26.png

vagrant内でのifconfig

eth0      Link encap:Ethernet  HWaddr 08:00:27:60:FC:47
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe60:fc47/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:802 errors:0 dropped:0 overruns:0 frame:0
          TX packets:691 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:69074 (67.4 KiB)  TX bytes:59586 (58.1 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:D6:BF:25
          inet addr:192.168.33.11  Bcast:192.168.33.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed6:bf25/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1752 (1.7 KiB)  TX bytes:900 (900.0 b)

eth2      Link encap:Ethernet  HWaddr 08:00:27:5B:7B:C7
          inet addr:192.168.100.106  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe5b:7bc7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:36 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6462 (6.3 KiB)  TX bytes:3042 (2.9 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

ホストOSのブラウザではeth1,eth2ともにアクセスできるのに
同一LANからeth2のアドレスを指定してもうまくいかない...

この辺りを参考にしていろいろいじってみるもだめでした。
http://www.h-fj.com/blog/archives/2013/10/31-103556.php

http://momijiame.tumblr.com/post/65525042320/vagrant-public-network-ip

http://hatacomp.hateblo.jp/entry/2013/07/27/132359

なのでOS再起動&vagrant/VirtualBoxバージョンアプ。

vagrant 1.2 -> 1.6
VirtualBox 4.2 -> 4.4

VirtualBox, Vagrantともにpackageをダウンロードしてアップグレードするだけ、
特に問題なくもでることなくバージョンアップできて、再びvagrant up

vagrantでのifconfig

[vagrant@localhost ~]$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:60:FC:47
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe60:fc47/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:529 errors:0 dropped:0 overruns:0 frame:0
          TX packets:374 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:56678 (55.3 KiB)  TX bytes:46760 (45.6 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:D6:BF:25
          inet addr:192.168.33.11  Bcast:192.168.33.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed6:bf25/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2920 (2.8 KiB)  TX bytes:1198 (1.1 KiB)

eth2      Link encap:Ethernet  HWaddr 08:00:27:5B:7B:C7
          inet addr:192.168.100.106  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe5b:7bc7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:54 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7858 (7.6 KiB)  TX bytes:1928 (1.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

routeの結果

vagrant@localhost ~]$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   *               255.255.255.0   U     0      0        0 eth2
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0
192.168.33.0    *               255.255.255.0   U     0      0        0 eth1
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
link-local      *               255.255.0.0     U     1004   0        0 eth2
default         192.168.100.254 0.0.0.0         UG    0      0        0 eth2

設定は同じそうですが。。。はたして

2014-05-17 18.42.46.png

無事デバイスからアクセスできました!
にっちもさっちも行かない時はバージョンアップして再起動してどーーんっすよ。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした