22
 Ying-Shiuan Pan 如何透過 NAT 連線到 guest OS 如何使用分享資料夾 Ying-Shiuan Pan

using Virtualbox NAT and shared folder

Embed Size (px)

DESCRIPTION

How to use Virtualbox NAT port forwarding and folder sharing

Citation preview

Page 1: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

如何透過 NAT 連線到 guest OS

如何使用分享資料夾

Ying-Shiuan Pan

Page 2: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

如何透過 NAT 連線到 guest OS

Where is the VM profile? open­ssh server What is NAT? Add port forwarding rule Try to connect to guest Os 疑難排解

Reference

Page 3: using Virtualbox NAT and shared folder

  Ying­Shiuan 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

Page 4: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

ssh server

安裝 $ sudo apt-get install openssh-

server

啟動 ssh server ( 也許需要 ) $ sudo /etc/init.d/ssh restart

測試 $ ssh localhost

Page 5: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

What is NAT?

鳥哥 http://linux.vbird.org/linux_server/0250simple_firewall.php

Page 6: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

Check your NIC type

Page 7: using Virtualbox NAT and shared folder

  Ying­Shiuan 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

Page 8: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

add port forwarding rule

Windows: 開始 → 執行 → cmd cd "\Program Files\sun\VirtualBox"

Linux 應用程式 → 附屬應用程式 → 終端機 (cht) Applications   Accessories   Terminal (eng)→ →

Page 9: using Virtualbox NAT and shared folder

  Ying­Shiuan 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

Page 10: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

add port forwarding rule

"VM_name" the name of the virtual machine

pcnet the NIC type

Intel PRO... (82540em)  → e1000 PCnet­FAST (Am79c973)  → pcnet

guestssh the name of the rule

TCP, 22, 32790 protocol, guest OS port, host OS port

Page 11: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

add port forwarding rule

Page 12: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

Try to connect to guest OS (1)

Page 13: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

Try to connect to guest OS (2)

Page 14: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

Page 15: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

疑難排解

從 guest OS 無法連到自己的 ssh 確認 guest OS 的 ssh 是否打開

從 guest OS 連線到自己試試看

從 host 無法連線到 guest 確認 port forwarding rule 是否正確

查看該 VM 的 profile (.xml) 檢查 guest OS 的防火牆是否被打開了

關掉他

Page 16: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

疑難排解

從其他電腦無法連線到 guest OS 是否使用 IP 分享器

外界電腦連入需要作 IP 分享器的 port forwarding設定

是否 host OS 的防火牆擋住了外面連線 視不同的防火牆作設定

Page 17: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

Reference

http://log­keep.blogspot.com/2007/09/virtualbox­nat­port­forwarding.html

http://blog.yam.com/flyzc/article/15137400 http://koukaipan.pixnet.net/blog/post/23993776

Page 18: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

如何使用分享資料夾

Install VirtualBox Guest Addiction first Plan your shared folder Add your shared folder Mount your shared folder

Page 19: using Virtualbox NAT and shared folder

  Ying­Shiuan 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)

Page 20: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

Add your shared folder

(a)

(c)

Page 21: using Virtualbox NAT and shared folder

  Ying­Shiuan 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)

Page 22: using Virtualbox NAT and shared folder

  Ying­Shiuan Pan

screenshot