Settings in Hyper-V
1. Go to Virtual Switch Manager
2. Create a new network virtual switch, the connection type is external network, select a network card
(I bought a USB card for the virtual machine to surf the internet, the motherboard comes with a network card for physical machine Internet access)
3. Set the virtual machine's network adapter to the newly created virtual switch
4. Start the virtual machine
Ubuntu Server Settings
1. Check if Hyper-V IC module is enabled
Lsmod|grep Hv_vmbus
If enabled there will be the following display
Hv_vmbus 65536 7 HV_BALLOON,HYPERV_KEYBOARD,HV_NETVSC,HID_HYPERV,HV_UTILS,HYPERV_FB,HV_STORVSC
2. If not, your Ubuntu version may be lower and need to be edited/etc/initramfs-tools/modules
Vi/etc/initramfs-tools/modules after appending
hv_vmbus
hv_storvsc
hv_blkvsc
hv_netvsc
after append save
Press ESC
: Wq
after saving, run Update-initramfs, and reboot the system
sudo update-initramfs–u
sudo reboot
3. Configure the NIC IP address, vi/etc/network/interfaces, add the following code
Static address mode (recommended)
#根据你的实际网路环境设置
auto eth0
iface eth0 inet static
address 192.168.1.122
netmask 255.255.255.0
Network 192.168.1.0
broadcast 192.168.1.255
Gateway 192.168.1.1
dns-nameservers 8.8.8.8
Dynamic Address mode
Auto eth0
iface eth0 inet DHCP
4. Set dns,vi/etc/resolv.conf, add
NameServer 8.8.8.8
5. Entry into force
sudo/etc/init.d/networking Restart
reboot
6. Testing
Ping www.baidu.com
or
wget http://www.baidu.com
You can connect to an extranet at this point, or you can connect to Ubuntu with tools such as FileZilla (SSH service is typically installed)
Use FileZilla to access Ubuntu, if you use the root account, you need to modify the vi/etc/ssh/sshd_config, otherwise there will be "authentication failed"
Locate the Permitrootlogin:withpassword
change to
Permitrootlogin:yes after saving and restart the
SSH Services service
ssh restart