WinXP host与VirtualBox CentOS5.5 Guest联网及ssh远程
估计对很多人来说这已不算新鲜的了,所以也许对大多数人都没有用,权作自己动手后总结了。
一.联网
系统软件配置:
host: WinXP sp3 + VirtualBox
guest: CentOS5.5
连接方式选择
我选择的方式为host-only networking,其他的两种(bridged networking和internal networking)
我没有尝试。但按VirtualBox的说法,这种方式是上面两种方式的混血。如bridged一样,多个虚拟机
(我只装了一个)和host之间可以彼此通信,就像连到了一台物理以太网交换机。同internal
networking一样,不需要使用host上的物理网卡,并且guest无法与host外部通信(比如internet吧)
,因为他们没有连到物理网卡。
总的来说,这种方式比较容易理解。
设置方法
1.VirtualBox界面下,设置-网络,在出现的窗口下拉框中选择host-only那一项,确定。
2.设置VirtualBox内置的DHCP服务
先说一下VB的方法,那就是使用VBoxManage dhcpserver命令。
VBoxManage dhcpserver add -ifname
其中,hostonly_if_name可以通过下面的命令获得:
VBoxManage list hostonlyifs
但我不是这样做的,我使用的是windows下常用的控制面板方法,即
控制面板-网络-在“virtualbox host-only network"下右键-属性-Internet协议(TCP/IP)-属性-自动
获得IP地址。
这样设置完成以后,host上运行vboxmanage list dhcpservers结果如下:
D:\Program Files\Oracle\VirtualBox>vboxmanage list dhcpservers
Oracle VM VirtualBox Command Line Management Interface Version 3.2.8
(C) 2005-2010 Oracle Corporation
All rights reserved.
NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter
IP: 192.168.56.100
NetworkMask: 255.255.255.0
lowerIPAddress: 192.168.56.101
upperIPAddress: 192.168.56.254
Enabled: Yes
host上ipconfig结果:
D:\Program Files\Oracle\VirtualBox>ipconfig
Windows IP Configuration
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . : router
IP Address. . . . . . . . . . . . : 192.168.0.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1
Ethernet adapter 无线网络连接:
Media State . . . . . . . . . . . : Media disconnected
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.56.102
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
guest上ifconfig:
[oracle@localhost ~]$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:0C:5F:E0
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe0c:5fe0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1297 errors:0 dropped:0 overruns:0 frame.:0
TX packets:1138 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:132363 (129.2 KiB) TX bytes:156083 (152.4 KiB)
Interrupt:10 Base address:0xd020
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1855 errors:0 dropped:0 overruns:0 frame.:0
TX packets:1855 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2011476 (1.9 MiB) TX bytes:2011476 (1.9 MiB)
经过这样配置,host和guest就可以ping通了。如果ping有问题,关掉windows防火墙试一试。
二. ssh到guest
对ssh只是刚接触,所以没有发言权。CentOS5.5安装好后就自带了sshd服务并自动运行。
host方面,只需要到http://www.putty.org/下载putty程序,在winxp下运行,在弹出的小窗口中输入
guest的ip地址,然后输入guest系统的用户和密码登陆就可以了。
参考:
1.VirtualBox帮助
2.www.linuxquestions.org
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24131851/viewspace-674685/
,如需转载,请注明出处,否则将追究法律责任。