VirtualBoxのネットワーク設定

開発環境をVirtualBoxで構築するときのネットワークの設定めもです。

  • ホストOS: MacOSX

  • ゲストOS: Ubuntu14.04LTS (開発環境)

VirtualBoxのネットワーク設定

アダプター1
  • 割り当て: NAT

  • ポートフォワーディング: | ssh | TCP | | 2222 | | 22 |

アダプター2
  • 割り当て: ホストオンリーアダプター

Ubuntuのnetwork/interfacesを編集する

$ vi /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

# The secondary network interface (Host-only)
auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0

$ /etc/init.d/networking restart

ホストOS→ゲストOSにアクセスする

SSH

Terminal

$ ssh -l [ユーザー名] [ホストのIP] -p 2222
Samba

Finderの「サーバーに接続...」で smb://192.168.56.101 にアクセスする

WEBrick

$ bundle exec rails s -b 0.0.0.0
で起動して、http://192.168.56.101:3000 にアクセスする