首先要登入自己的虚拟机,这里以ubuntu为例. 配置两块网卡,一块eth0为NAT模式,另一块为eth1仅主机模式 # 进入网卡配置页面vi /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback
看所有网卡(包括未启动的) ifconfig -a 或者 ip link 查看当前网卡配置,打开配置文件/etc/network/interfaces 设置静态IP(dhcp 为动态获取,static 为静态获取) sudo vim /etc/network/interfaces 修改成如下内容: auto enp0s3 iface ens33 inet static #设置静态IP,动态的是将static修改为dhcp,如果设置为动态IP无法设置虚拟网卡 address 172.16.2.95