您现在的位置是:首页 >技术杂谈 >Linux Mint下VM网络的配置网站首页技术杂谈
Linux Mint下VM网络的配置
OS LinuxMint 21.1
参考文档:
https://netplan.io/examples
在Linux Mint下安装VMWare,设置虚拟网卡为vmnet0和vmnet1
问题:
1 在重启OS后,ifconfig 发现vmnet0和vmnet1都不见了。
2 并且ls -l /dev/vm* 看不到vmnet0和vmnet1 。
3 打开虚拟机的网络高级编辑器后,保存后,ifconfig可以看到vmnet0和vmnet1的IP。但是不是自己分配的240的那个地址
4 保存关闭虚拟机的高级编辑器后,ls -l /dev/vm*可以看到vmnet0和vmnet1。但是ifconfig看到的ip不是分配的240的IP
解决方法
1 在高级编辑器中,设置net1和net8的网段,保存
2 配置网卡,路径/etc/netplan/1-network-manager-all.yaml
3 应用网卡配置 sudo netplan apply
应用网卡配置后,/dev/目录下查看网卡信息
adminuser@adminuser-Inspiron-7472:/usr/bin$ ls -l /dev/vm*
crw------- 1 root root 10, 120 Apr 16 15:14 /dev/vmci
crw------- 1 root root 10, 121 Apr 16 15:14 /dev/vmmon
crw------- 1 root root 119, 0 Apr 16 15:18 /dev/vmnet0
crw------- 1 root root 119, 1 Apr 16 15:18 /dev/vmnet1
adminuser@adminuser-Inspiron-7472:/usr/bin$
网卡的配置信息
adminuser@adminuser-Inspiron-7472:/etc/netplan$ more 1-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
vmnet0:
dhcp4: no
addresses: [192.168.2.240/24]
vmnet1:
dhcp4: no
addresses: [10.10.10.240/24]
adminuser@adminuser-Inspiron-7472:/etc/netplan$
应用网卡后,查看ip地址,net0和net1的地址为 2.240和10.240 。
adminuser@adminuser-Inspiron-7472:/usr/bin$ ifconfig -a
enp2s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 50:9a:4c:d0:3d:14 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 782 bytes 132277 (132.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 782 bytes 132277 (132.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vmnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.240 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::250:56ff:fec0:0 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:c0:00:00 txqueuelen 1000 (Ethernet)
RX packets 60469 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 40034 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vmnet1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.10.240 netmask 255.255.255.0 broadcast 10.10.10.255
inet6 fe80::250:56ff:fec0:1 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:c0:00:01 txqueuelen 1000 (Ethernet)
RX packets 10 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 202 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.248 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::a6cc:2ab0:b503:cd26 prefixlen 64 scopeid 0x20<link>
ether d4:6a:6a:a1:08:eb txqueuelen 1000 (Ethernet)
RX packets 10648 bytes 4822816 (4.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6467 bytes 1827701 (1.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
adminuser@adminuser-Inspiron-7472:/usr/bin$
遗留问题
当OS启动后,使用ifconfig查看网卡信息,vmnet0和vmnet1还是没有的,当然查看/dev/vm* 也查看不到vm网卡的信息
临时解决方法,
1 打开vm的高级网络编辑器,然后不做任何设置,保存。这个时候ifconfig可以看到vmnet0和vmnet1的地址,但是地址是1,而不是240 。而且/dev/目录下有vm网卡设备
2 sudo netplan apply执行,执行后,再次ifconfig查看网卡信息,vmnet0和vmnet1是240地址。
具体是什么原因,暂时不是很清楚。临时使用这种方法处理。
难道是重启OS后,默认不加载vm网卡,需要手工打开这个网卡,然后刷新网卡配置信息?
END