Linux 虚拟机网络适配器从E1000改为VMXNET3

简介:

我们知道VMware的网络适配器类型有多种,例如E1000、VMXNET、 VMXNET 2 (Enhanced)、VMXNET3等,就性能而言,一般VMXNET3要优于E1000,下面介绍如果将Linux虚拟机的网络适配器类型从 E1000改为VMXNET3。本文测试环境如下

           操作系统   :Oracle Linux Server release 5.7

           虚拟机版本 :Vmware 5.1

如下所示,测试前,我们可以先看看网卡类型为e1000, 此版本的Linux似乎没有配置文件/etc/udev/rules.d/70-persistent-net.rules。只有配置文件60-net.rules.具体信息请见下图

clip_image001

clip_image002

 

方法1:在vSphere Client中更改适配器类型

我们通过vSphere Client客户端,添加网络适配器2(适配器类型为VMXNET3),然后删除网络适配器1,重启服务器

clip_image003

重启后,在/etc/sysconfig/network-scripts/下,你会看到有ifcfg-eth0和ifcfg-eth0.bak两个配置文件,系统自动生成了新的配置文件并将原来的配置文件重命名了

clip_image004

如下所示,新生成的配置文件ifcfg-eth0是动态获取IP,需要重新配置网络信息,重启网络服务即可即可解决问题。

[root@localhost ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
# VMware VMXNET3 Ethernet Controller
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:50:56:af:09:7b
 
[root@localhost ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0.bak 
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:50:56:AF:45:19
ONBOOT=yes
IPADDR=192.168.9.24
GATEWAY=192.168.9.8
NETMASK=255.255.255.0

注意,在我多次测试验证过程中,如果服务器没有安装Vmware Tools,那么在操作过程中就会遇到“Device eth0 does not seem to be present, delaying initialization”,查看当前的eth设备,你会发现只有lo设备。怎么都搞不定。这个可不像Linux 克隆虚拟机引起的“Device eth0 does not seem to be present, delaying initialization”那样轻松搞定

[root@localhost1 ~]# ls /sys/class/net/
 
lo
 
[root@localhost ~]# 

clip_image005

 

方法2:修改.vmx 文件来更改适配器类型

1:关闭LNTEST虚拟机。

2:选择LNTEST,单击右键选择“从清单中移除”

clip_image006

3:在数据存储浏览器中找到LNTest对应的目录,找到LNTest.vmx文件。找到参数ethernet1.virtualDev(有可能为ethernet0)将其值从"e1000"改为"vmxnet3"

clip_image007

 

image

vmotion.checkpointFBSize = "4194304"
softPowerOff = "TRUE"
tools.syncTime = "FALSE"
unity.wasCapable = "FALSE"
tools.remindInstall = "TRUE"
migrate.hostlog = "./LNTest-d958ff0f.hlog"
ethernet1.virtualDev = "vmxnet3"
ethernet1.pciSlotNumber = "32"
ethernet1.startConnected = "TRUE"
ethernet1.allowGuestConnectionControl = "TRUE"
ethernet1.features = "1"
ethernet1.wakeOnPcktRcv = "TRUE"
ethernet1.networkName = "VM Network"
ethernet1.dvs.switchId = ""
ethernet1.present = "TRUE"
ethernet1.addressType = "generated"
config.readOnly = "FALSE"
ethernet1.generatedAddress = "00:0c:29:0f:63:7e"
ethernet1.generatedAddressOffset = "10"
ethernet0.present = "FALSE"

4: 选择vmx文件,将其“添加到清单”,然后重启电源,一切搞定,都不需要修改任何网络配置信息。

clip_image009

 

方法3:使用PowerCLI修改网络适配器类型

PowerCLI,即VMware vSphere PowerCLI 是一款功能强大的命令行工具来修改。 这个方法没有实际验证过,不过看其介绍,似乎是最简单的一种方法。

 

Change the Adapter Type with PowerCLI

The easiest method to change the adapter type is by using this little PowerCLI command. Just replace <VM> with your virtual machines name. You can run this script without disruption while the virtual machine is running but it’s not active until you have powered off the virtual machine. A reboot does not activate the configuration.

Get-VM -name "<VM>" | Get-NetworkAdapter | Where { $_.Type -eq "E1000"} | Set-NetworkAdapter -Type "vmxnet3"

Prior to change please make sure that your operating system contains the vmxnet3 driver or you have installed the VMware Tools. To check the required kernel module type “modprobe vmxnet3“. If you don’t get an error message you should be fine.

  

相关文章
|
1月前
|
安全 Linux 网络安全
Web安全-Linux网络协议
Web安全-Linux网络协议
63 4
|
12天前
|
Linux 网络安全
Linux虚拟机与主机和Xshell的连接问题解决
Linux虚拟机与主机和Xshell的连接问题解决
31 1
|
12天前
|
网络协议 安全 Ubuntu
Linux中网络连接问题
【10月更文挑战第3天】
24 1
|
18天前
|
虚拟化 网络虚拟化 网络架构
虚拟机 VMware Workstation 16 PRO 的网络配置
虚拟机 VMware Workstation 16 PRO 的网络配置
53 2
|
1月前
|
KVM 虚拟化
KVM虚拟机的桥接网络
文章主要介绍了KVM虚拟机的NAT和桥接网络类型的工作原理、配置方法以及如何进行网络模式的切换。
32 3
KVM虚拟机的桥接网络
|
1月前
|
安全 Unix Linux
Xshell和Xftp的下载和在linux虚拟机中的使用
这篇文章介绍了Xshell和Xftp的下载、安装和使用方法,包括如何在Linux虚拟机中使用它们进行远程连接和文件传输。
Xshell和Xftp的下载和在linux虚拟机中的使用
|
17天前
|
监控 Linux 测试技术
Linux系统命令与网络,磁盘和日志监控总结
Linux系统命令与网络,磁盘和日志监控总结
40 0
|
17天前
|
监控 Linux 测试技术
Linux系统命令与网络,磁盘和日志监控三
Linux系统命令与网络,磁盘和日志监控三
33 0
|
1月前
|
机器学习/深度学习 安全 网络协议
Web安全-Linux网络命令
Web安全-Linux网络命令
28 1
|
1月前
|
网络协议 Linux
Linux 网络配置
了解基本命令与权限后,如何让Linux系统联网?可通过编辑`/etc/sysconfig/network-scripts/`下的`ifcfg-ethX`文件配置网卡,其中`ethX`代表第X块网卡。对于DHCP自动获取或静态IP,需设置`BOOTPROTO`参数,并指定IP、子网掩码和网关等。配置完成后,运行`/etc/init.d/network restart`重启网络。DNS可在`/etc/resolv.conf`中设置,添加`nameserver`行即可,无需重启网卡。配置好后,可用`ifconfig`查看IP信息,并通过远程工具如SecureCRT连接服务器。
59 0