Upload
chatchai-jantaraprim
View
1.255
Download
1
Embed Size (px)
Citation preview
PSU-LUG/Sysadmin
VirtualBox Networking
Chatchai J2013-02-28
VirtualBox Networking
● เนอหาทงหมด เรยบเรยงจาก
http://www.virtualbox.org/manual/ch06.htmlChapter 6: Virtual Networking
VirtualBox Manual
Virtual Networking Hardware
● อปกรณ เลยนแบบการทำางานของ hardware
– AMD PCNet PCI II (Am79C970A)
– AMD PCNet FAST III (Am79C973, the default)
– Intel PRO/1000 MT Desktop (82540EM)
– Intel PRO/1000 T Server (82543GC)
– Intel PRO/1000 MT Server (82545EM)
● ใชงานไดกบ OS ทม driver สำาหรบ hardware
จรงๆ เหลาน (แทบทก OS) – DOS?, Mac OSX?
Virtual Networking Hardware (cont)
● และ– Paravirtualized network adapter (virtio-net).
● สำาหรบ OS ทรองรบการทำางานเปนแบบ Virtualized
– รองรบทง Linux, Windows รนใหม (ใชงานในปจจบน)
– Win2K ,XP ,Vista ม driver ให Download
● http://www.linux-kvm.org/page/WindowsGuestDrivers
Virtual Networking Hardware (cont)
● ขอด– ไมตอง emulate การทำางานของ hardware ทไมจำาเปน
● แนะนำาใหใช virtio สำาหรบ Virtual Network Device ถา Guest OS support
– ไมจำากดวาจะตองเปน VirtualBox
● ถาตองเลอก– virtio > Intel Pro > AMD PCI
Networking Mode
● Not attached● Network Address Translation (NAT)● Bridged networking● Internal networking● Host-only networking● Generic networking
Networking Mode (cont)
Networking Mode (cont)
● Not attached
– ม NIC แตไมตอกบเครอขายใดๆ
Networking Mode (cont)
● Network Address Translation (NAT)
– default (ใช VirtualBox NAT engine)
– NIC1 => 10.0.2.0/24, NIC2 => 10.0.3.0/24● guest IP 10.0.X.15● host IP 10.0.X.2
– Gateway– DHCP Server– using host's DNS (/etc/resolv.conf)
Networking Mode (cont)
● Network Address Translation (NAT)
– Network ของแตละ VM แยกเปนอสระจากกน
Networking Mode (cont)
● Network Address Translation (NAT)
– การใหบรการโดย guest กบ host ภายนอก จะตองใช port forwarding
$ VBoxManage modifyvm "VM name" \ natpf1 "guestssh,tcp,,2222,,22"
– สำาหรบ ssh connection เขาไปท guest$ ssh p 2222 host
Networking Mode (cont)
● Network Address Translation (NAT)– SomeLimitation
● ICMP packet● UDP Broadcast● Support mainly TCP & UDP● Forward port on host < 1024
Networking Mode
● Bridged networking
– ใช host interface driver สำาหรบ filter data สงใหกบ VM interface
– การ config จะตองเลอกวา จะ bridge กบ interface ใหนของ host
Networking Mode (cont)
● Bridged networking
Networking Mode (cont)
Bridge Networking (cont)
Bridge Networking (cont)
Bridge Networking (cont)
● bridge กบ wired interface บน Virtualbox จะใชวธการตางกบ wireless interface
– ถามปญหา ลองเปลยนจาก wireless → wired
● สำาหรบ Linux
– Bridge บน wireless support เฉพาะ IPv4
– Bridge อาจจะมปญหากบ VLAN (ขนอยกบ hardware ทใช)
Networking Mode (cont)
● Internal networking
– implement แบบเดยวกบ bridge
– แตไมเชอมตอกบ network ภายนอก– ใชเปน “internal network” ระหวาง guest VM ดวยกน
(Virtual Switch)
– ถาตองการตอออกภายนอก อาจใช VM ทตออยกบ internal
network น เพอทำาหนาทเปน router/gateway
– ระบ network ดวยชอ
Internal networking
Internal networking (cont)
Internal networking (cont)
Internal networking (cont)
Internal networking (cont)
● โดยทวไปจะใช network config แบบ static สำาหรบ guest
● หรอ setup guest ตวนง ใหเปน DHCP Server
● ถาจะใช internal dhcp server จะตองใช VboxManage
$ VBoxManage dhcpserver add netname <network_name>
Networking Mode (cont)
● Host-only networking
– คลาย internal network
– สำาหรบ guest VM ทตอ host-only network เดยวกนสอสารดวยกน– เพม virtual interface ทตว host ซงตอกบ host-only network
– จะตองสราง host-only network interface ขนมากอน
Host-only networking
● สราง host-only network interface
● VirtualBox Manager → Preference
→Network→Add host-only network (INS)
● vboxnet0 (สรางโดย default)
● vboxnet1
● บน host
$ /sbin/ifconfig a
Host-only networking (cont)
Host-only networking (cont)
Host-only networking (cont)
cj@nilanont64:~$ ifconfig a
...
vboxnet0 Link encap:Ethernet HWaddr 0a:00:27:00:00:00 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Host-only networking (cont)
Host-only networking (cont)
Host-only networking (cont)
● host-only สามารถ กำาหนด ip address
(สำาหรบ vboxnetX interface) หรอ enable
DHCP Server (สำาหรบ vboxnetX virtual
network) ได โดยใชEdit host-only network (space)
host-only networking (cont)
Networking Mode (cont)
● Generic networking
– สำาหรบ Advanced Networking
● ผมกยงไมเคยใช – เลยไมรจะแนะนำายงไง (ฮา)
VirtualBox Networking
คำาถาม?