ksaitoの日記

日々試したことの覚え書き

ネットワークのNAT関連の設定

移転しました。

自動的にリダイレクトします。

ゲストOSのネットワークがNATの場合、ホストOS以外からの接続はできません。
ポートフォアードを設定することでホストOS以外のマシンから接続することができるようになります。
VirtualPCユーザマニュアルこのwikiを参考に設定しました。

VBoxManageコマンドの設定

VBoxManagerコマンドで設定します。
設定は、すべて~/.VirtualBox/Machines/ゲストOS名/ゲストOS名.xmlに書き込まれるようです。

$ VBoxManage setextradata "debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
$ VBoxManage setextradata "debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
$ VBoxManage setextradata "debian" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
$ cd ~/.VirtualBox/Machines
$ grep pcnet debian/debian.xml 



$

接続

ゲストOSが動いている場合は、停止してVirtualBoxも再起動します。
VBoxManagerコマンドで設定したHostPortに指定したホストOSのポートに接続すると、GuestPortに指定したゲストOSのポートにフォアードされます。

$ hostname
ubuntu
$ ssh -p 2222 localhost
xxxx@localhost's password:
Linux debian 2.4.18-bf2.4 #1 Son Apr 14 09:53:28 CEST 2002 i686 unknown

Most of the programs included with the Debian GNU/Linux system are
freely redistributable; the exact distribution terms for each program
are described in the individual files in /usr/share/doc/*/copyright

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat May 24 02:32:45 2008 from 2.2.0.10.in-addr.arpa
$ hostname
debian
$