using virtualbox nat and shared folder
DESCRIPTION
How to use Virtualbox NAT port forwarding and folder sharingTRANSCRIPT
YingShiuan Pan
如何透過 NAT 連線到 guest OS
如何使用分享資料夾
Ying-Shiuan Pan
YingShiuan Pan
如何透過 NAT 連線到 guest OS
Where is the VM profile? openssh server What is NAT? Add port forwarding rule Try to connect to guest Os 疑難排解
Reference
YingShiuan Pan
Where is the VM profile?
Windows XP C:\Documents and
Settings\???\.VirtualBox
Linux /home/???/.VirtualBox
each VM's profile in .VirtualBox/Machines/VM_name
VM_name.xml
YingShiuan Pan
ssh server
安裝 $ sudo apt-get install openssh-
server
啟動 ssh server ( 也許需要 ) $ sudo /etc/init.d/ssh restart
測試 $ ssh localhost
YingShiuan Pan
What is NAT?
鳥哥 http://linux.vbird.org/linux_server/0250simple_firewall.php
YingShiuan Pan
Check your NIC type
YingShiuan Pan
Plan your port forwarding rule
What is the name of your guest OS? eg. Ubuntu 904
Which port in host OS? eg. 32790
Which port in guest OS? eg. 22
YingShiuan Pan
add port forwarding rule
Windows: 開始 → 執行 → cmd cd "\Program Files\sun\VirtualBox"
Linux 應用程式 → 附屬應用程式 → 終端機 (cht) Applications Accessories Terminal (eng)→ →
YingShiuan Pan
add port forwarding rule $ VBoxManage setextradata "VM_name"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
$ VBoxManage setextradata "VM_name" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
$ VBoxManage setextradata "VM_name" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 32790
YingShiuan Pan
add port forwarding rule
"VM_name" the name of the virtual machine
pcnet the NIC type
Intel PRO... (82540em) → e1000 PCnetFAST (Am79c973) → pcnet
guestssh the name of the rule
TCP, 22, 32790 protocol, guest OS port, host OS port
YingShiuan Pan
add port forwarding rule
YingShiuan Pan
Try to connect to guest OS (1)
YingShiuan Pan
Try to connect to guest OS (2)
YingShiuan Pan
YingShiuan Pan
疑難排解
從 guest OS 無法連到自己的 ssh 確認 guest OS 的 ssh 是否打開
從 guest OS 連線到自己試試看
從 host 無法連線到 guest 確認 port forwarding rule 是否正確
查看該 VM 的 profile (.xml) 檢查 guest OS 的防火牆是否被打開了
關掉他
YingShiuan Pan
疑難排解
從其他電腦無法連線到 guest OS 是否使用 IP 分享器
外界電腦連入需要作 IP 分享器的 port forwarding設定
是否 host OS 的防火牆擋住了外面連線 視不同的防火牆作設定
YingShiuan Pan
Reference
http://logkeep.blogspot.com/2007/09/virtualboxnatportforwarding.html
http://blog.yam.com/flyzc/article/15137400 http://koukaipan.pixnet.net/blog/post/23993776
YingShiuan Pan
如何使用分享資料夾
Install VirtualBox Guest Addiction first Plan your shared folder Add your shared folder Mount your shared folder
YingShiuan Pan
Plan your shared folder
Directory in host OS /data/vbox_shared (a)
Directory in guest OS /mnt/vbox_shared (b)
The name of the shred directory vbox_shared (c)
YingShiuan Pan
Add your shared folder
(a)
(c)
YingShiuan Pan
Mount the shared folder
Create mount point $ sudo mkdir /mnt/vbox_shared
Do mount $ sudo mount -t vboxsf
vbox_shared /mnt/vbox_shared
test $ cd /mnt/vbox_shared $ ls
(b)
(c)
(b)
(b)
YingShiuan Pan
screenshot