88221247 2014-06-09
在Hyper-V虚拟机中,正常安装完CentOS、RedHat等Linux操作系统之后,网络是不正常的。因为CentOS和RedHat等Linux操作系统是不能识别Hyper-V的虚拟网络的。
要想使虚拟机能够正常识别Hyper-V虚拟网络,需要安装微软的Linux集成服务工具。
下载链接: Linux Integration Services v2.1 for Windows Server 2008 Hyper-V R2 - 中文(简体)
下面介绍安装过程(以CentOS X64 为例):
1.
正常安装CentOS操作系统,安装完毕后,挂在镜像文件,安装adjtimex 软件包
[root@localhost ~]# mount /dev/cdrom /tmp
[root@localhost ~]# mount /dev/cdrom /tmp/
[root@localhost ~]# rpm -ivh /tmp/CentOS/adjtimex-1.20-2.1.x86_64.rpm
如果不安装该软件包的话,后面编译集成服务工具时,会提示"Your system DOES NOT support the timesource driver" 错误.
2.
解压集成服务工具,解压后包含一个pdf 帮助文件和一个名为"LinuxIC v21"的iso文件
3. Hyper-V虚拟机->设置->IDE控制器->DVD驱动器->图像文件,定位到解压出来的ISO镜像文件,
如图示
4. 启动虚拟机,打开终端程序,执行集成服务工具的编译安装
4. 启动虚拟机,打开终端程序,执行集成服务工具的编译安装
[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# mkdir -p /opt/linux_is_v2.1
[root@localhost ~]# cp -R /mnt/* /opt/linux_is_v2.1/
[root@localhost ~]# cd /opt/linux_is_v2.1/
[root@localhost linux_is_v2.1]# ls
docs LICENSE-DUAL-BSD-GPL LICENSE-GPL Makefile README scripts src
[root@localhost linux_is_v2.1]# make
[root@localhost linux_is_v2.1]# make install
5. 安装完毕后,打开网卡配置文件,vi "/etc/sysconfig/network-scripts/ifcfg-eth0" ,配置网络信息
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Microsoft Corporation Hyper-V Network Adapter
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:15:5d:01:2e:04
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.1.71
GATEWAY=192.168.1.1
TYPE=Ethernet
vi /etc/resolf.conf 文件,配置DNS网络信息.
配置完毕后,重启网卡。
6. 验证网络连通性:
PING polaris.sina.com.cn (202.108.33.60) 56(84) bytes of data.
64 bytes from 202.108.33.60: icmp_seq=1 ttl=243 time=3.51 ms
64 bytes from 202.108.33.60: icmp_seq=2 ttl=243 time=3.46 ms
64 bytes from 202.108.33.60: icmp_seq=3 ttl=243 time=2.75 ms
64 bytes from 202.108.33.60: icmp_seq=4 ttl=243 time=3.50 ms
64 bytes from 202.108.33.60: icmp_seq=5 ttl=243 time=2.86 ms
64 bytes from 202.108.33.60: icmp_seq=6 ttl=243 time=3.40 ms
64 bytes from 202.108.33.60: icmp_seq=7 ttl=243 time=5.94 ms
64 bytes from 202.108.33.60: icmp_seq=8 ttl=243 time=2.99 ms
64 bytes from 202.108.33.60: icmp_seq=9 ttl=243 time=2.77 ms
--- polaris.sina.com.cn ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 7998ms
rtt min/avg/max/mdev = 2.756/3.469/5.948/0.930 ms
[root@localhost ~]#
可以看到,网络已经可以正常通讯。