3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vagrantで建てたWEBサーバーへ、別PCから検証用にアクセスさせる為の設定(ブリッジ接続)

Last updated at Posted at 2017-05-12

Vagrantファイルの編集

以下IPを 192.168.1.111 にセットする前提で。

config.vm.network "public_network", ip: "192.168.1.111" 

public_network を指定して、 hostsファイルにドメインとともにIP追記しておきたいので固定IPを指定してあげる。
もちろん他マシンとIP被らないように。

設定反映させる

vagrant reload

起動中に下記のようにどこに接続するか聞かれるようになる

==> develop: Attempting graceful shutdown of VM...
==> develop: Clearing any previously set forwarded ports...
==> develop: Clearing any previously set network interfaces...
==> develop: Available bridged network interfaces:
1) en0: Wi-Fi (AirPort)
2) en1: Thunderbolt 1
3) en2: Thunderbolt 2
4) p2p0
5) awdl0
6) bridge0
==> develop: When choosing an interface, it is usually the one that is
==> develop: being used to connect to the internet.
    develop: Which interface should the network bridge to? 1
    
# 上記例は1を選択

起動したら確認

vagrant ssh

# 以下vagrant内


[vagrant@develop ~]$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:CE:08:3D
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fece:83d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:490 errors:0 dropped:0 overruns:0 frame:0
          TX packets:332 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:51628 (50.4 KiB)  TX bytes:43514 (42.4 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:75:74:A0
          inet addr:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: 2408:211:af60:4f00:a00:27ff:fe75:74a0/64 Scope:Global
          inet6 addr: fe80::a00:27ff:fe75:74a0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:682 (682.0 b)  TX bytes:1536 (1.5 KiB)

eth1 の inet addr:192.168.1.111 と指定したIPになっていればOK。これで別PCからも検証できると。。

3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?