Virtualbox

10,805 views

Published on

virtualbox 分析

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
10,805
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
48
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Virtualbox

  1. 1. VirtualBox http://www.virtualbox.org/ <ul><li>Cfddream </li></ul><ul><li>2011-04-14 </li></ul>
  2. 2. <ul><li>为什么用? </li></ul><ul><ul><li>工作 </li></ul></ul><ul><ul><li>学习、研究 </li></ul></ul><ul><li>怎么用? </li></ul>
  3. 3. 搭建虚拟环境 <ul><li>OS </li></ul><ul><ul><li>Host -- Windows </li></ul></ul><ul><ul><li>Guest – Debian, Archlinux etc. </li></ul></ul><ul><li>Create </li></ul><ul><ul><ul><li>控制 -> 新建 -> 下一步 -> 下一步。。。 -> 完成 </li></ul></ul></ul><ul><ul><ul><li>载入 iso 镜像文件 </li></ul></ul></ul>
  4. 4. Start <ul><ul><li>Install os </li></ul></ul><ul><ul><ul><li>选择语言、设置键盘、设置 root 密码、创建新用户及密码、时区、分区(选择默认即可)、安装包、选择镜像 </li></ul></ul></ul>
  5. 5. Network - NAT <ul><ul><li>NAT 网络地址转换 (Network Address Translation) </li></ul></ul><ul><ul><li>Host IP: 192.168.1.102 </li></ul></ul><ul><ul><li>Guest IP: 10.0.2.15 </li></ul></ul><ul><ul><li>Gateway: 10.0.2.255 </li></ul></ul><ul><ul><li>DNS: 10.0.2.3 </li></ul></ul><ul><ul><ul><li>cfd@ubuntu:~$ ifconfig eth0 </li></ul></ul></ul><ul><ul><ul><li>eth0 Link encap:Ethernet </li></ul></ul></ul><ul><ul><ul><li>HWaddr 08:00:27:da:22:43 </li></ul></ul></ul><ul><ul><ul><li>inet addr:10.0.2.15 </li></ul></ul></ul><ul><ul><ul><li>Bcast:10.0.2.255 Mask:255.255.255.0… </li></ul></ul></ul><ul><ul><ul><li>Inter addr = ip 地址 bcast = 网关 mask = 子网掩码 </li></ul></ul></ul>
  6. 6. Net Host Guest 缺点:对公网不可见,只能通过 Host 做端口映射 / 转发 优点 : 不管主机是否连上网线,都可以通过端口转发进行通信。
  7. 7. Network – Bridged Adapter <ul><li>Bridged Adapter 桥接 </li></ul><ul><li>Host IP: 192.168.1.102 </li></ul><ul><li>Guest IP: 192.168.1.103 </li></ul><ul><li>Gateway: 192.168.1.255 </li></ul><ul><li>Mask: 255.255.255.0 </li></ul>
  8. 8. Net Host Guest Guest IP: 由 DHCP 自动分配,与主机同一网段。虚拟机与主机可以相互通信。也可以采用 固定 ip 的方式, 缺点:主机没联网,与虚拟机就不能进行通信。  优点:同一网段,可以直接通信。
  9. 9. Network - Host-Only <ul><ul><ul><li>Host IP: 192.168.56.1 </li></ul></ul></ul><ul><ul><ul><li>Server IP: 192.168.56.100 </li></ul></ul></ul><ul><ul><ul><li>Guest IP: 192.168.56.101 </li></ul></ul></ul><ul><ul><ul><li>Gateway: 192.168.56.255 </li></ul></ul></ul><ul><ul><ul><li>Mask: 255.255.255.0 </li></ul></ul></ul>cfd@ubuntu:~$ ifconfig eth0 eth0 Link encap:Ethernet HWaddr 08:00:27:da:22:43 inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
  10. 10. Net Host Guest Host-Only Guest 只能与 Host 相互通信,无法连外网, Guest 的网卡连接到 VirtualBox 的 vboxnet0 网卡, Host 与 Guest 共同使用 Host-Only 这张网卡,并且进行通信   缺点:虚拟机不能联网   优点:同一网段,可以直接通信。
  11. 11. Network - Internal 内部网络 <ul><li>虚拟机与外网完全断开 </li></ul>
  12. 12. 搭建 1-Host, N-Guests <ul><li>NAT: Guests 之间只能通过 Host 端口转发 </li></ul><ul><li>BA: Host 联网,才能建立通信 </li></ul><ul><li>HO: Guests 无法联网 </li></ul><ul><li>NAT+HO( 推荐 ): Guests 无需借助 Host 的端口转发 </li></ul>
  13. 13. NAT+HO Example Host : windows Guests : network : 同时开启双网卡          eth0(NAT) dhcp          eth1(Host-Only) dhcp/static ip
  14. 14. <ul><li>Guest1 : debian </li></ul><ul><li>Network config: /etc/network/interfaces </li></ul>NAT+HO Example Static: allow-hotplug eth0   iface eth0 inet dhcp auto eth1 iface eth1 inet static address 192.168.56.101 netmask 255.255.255.0 Dhcp: allow-hotplug eth0   iface eth0 inet dhcp allow-hotplug eth1   iface eth1 inet dhcp
  15. 15. NAT+HO Example <ul><li>Guest2 : Archlinux </li></ul><ul><li>Network config: /etc/rc.conf </li></ul>Dhcp: eth0=&quot;dhcp&quot; eth1=&quot;dhcp&quot; INTERFACES=(eth0 eth1) Static: eth0=&quot;dhcp&quot; eth1=&quot;eth1 192.168.56.102 netmask 255.255.255.0 broadcast 192.168.56.255&quot; INTERFACES=(eth0 eth1)
  16. 16. NAT+HO Example <ul><li>Commands : </li></ul><ul><li>检查通信: ping –c3 www.g.cn </li></ul><ul><li>编辑 network config: sudo vi /etc/network/interfaces </li></ul><ul><li>所有网卡状态: sudo ifconfig –a </li></ul><ul><li>某网卡状态: ifconfig eth0 </li></ul><ul><li>开启 / 关闭网卡: sudo ifconfig eth0 down | up </li></ul><ul><li>移动 vdi 虚拟磁盘,无法联网的 bug: sudo rm /etc/udev/rules.d/*-net.rules </li></ul><ul><li>路由: route –n </li></ul><ul><li>端口: netstart –lnpt </li></ul><ul><ul><ul><ul><li>联网: </li></ul></ul></ul></ul><ul><ul><ul><ul><li>debian -  /etc/init.d/networking stop | start | restart </li></ul></ul></ul></ul><ul><ul><ul><ul><li>archlinux -  /etc/rc.d/network stop | start | restart </li></ul></ul></ul></ul><ul><ul><ul><ul><li>sshd: </li></ul></ul></ul></ul><ul><ul><ul><ul><li>debian - sudo service sshd start | stop | restart </li></ul></ul></ul></ul><ul><ul><ul><ul><li>archlinux – sudo /etc/rc.d/sshd start | stop | restart </li></ul></ul></ul></ul><ul><ul><ul><ul><li>ssh: ssh –p 22 [email_address] | ssh –l cfd 192.168.56.101 </li></ul></ul></ul></ul>
  17. 17. NAT+HO Example <ul><li>Debian web server </li></ul><ul><li>sudo aptitude install -y apache2 </li></ul><ul><li>sudo aptitude install -y php5 </li></ul><ul><li>web dir: /var/www </li></ul><ul><li>Archlinux web server </li></ul><ul><li>https://wiki.archlinux.org/index.php/LAMP </li></ul>
  18. 18. NAT+HO Example <ul><li>Tools: </li></ul><ul><ul><li>Putty </li></ul></ul><ul><ul><li>secureCRT </li></ul></ul>
  19. 19. Thanks! <ul><li>cfddream [at] gmail [dot] com </li></ul><ul><li>My dotfiles By githum.com </li></ul><ul><li>virtualbox 笔记 .txt </li></ul>

×