Ubuntu with HyperV

Enable fullscreen or custom screen size

– documentation official …

We need to set the EnableEnhancedSessionMode to true to enable xrdp.
To rollback, set it to false.

Read value of the EnableEnhancedSessionMode property :
Get-VMHost | fl -Property EnableEnhancedSessionMode

Get all properties of a VM :
Get-VM myVm | Select-Object *

Set value of the EnableEnhancedSessionMode property :
Set-VMHost -EnableEnhancedSessionMode $false

or on the specific VM :

Set-VM -VMName <your_vm_name> -EnhancedSessionTransportType HvSocket

Set a static ip for the VM (Debian based or RedHat based)

On the HyperV host

By default, the ip of the Virtual network used for HyperV, along the ip of the VM (Ubuntu here) are dynamic.
It may caused some issues if application installed (example : Kubernetes) or other VM/client of the network need to identify the machine with always the same ip address value.
To fix that we need to create a gateway (192.168.0.1) along a NAT with a static IP address (192.168.0.0/24) which the proxy is in the range.

On PowerShell :
1) Create a virtual network named SwitchName :
New-VMSwitch -SwitchName "SwitchName" -SwitchType Internal
2) Retrieve the ifIndex value of the new network :
Get-NetAdapter
3) Create a static ip address for the VM :
New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex <INDEX>
4) Create a NAT for 192.168.0.0 :
New-NetNat -Name MyNATnetwork -InternalIPInterfaceAddressPrefix 192.168.0.0/24

On the VM side : Uuntu

We specify the static ip for the VM (rather ip provided by DHCP) along the gateway:
cd /etc/netplan/
sudo nano 01-network-manager-all.yaml

We replace the content with that :

network:
  version: 2
  renderer: networkd  
  ethernets:
    eth0:
      addresses:
      - 192.168.0.2/24
      gateway4: 192.168.0.1
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.4.4
      dhcp4: no

Apply the changes :
sudo netplan apply

On the VM side : RHEL

We specify the static ip for the VM (rather ip provided by DHCP) along the gateway:
Edit /etc/sysconfig/network such as :

# Created by anaconda
NETWORKING=yes
GATEWAY=192.168.0.1
NETWORKING_IPV6=no
IPV6INIT=no

Edit /etc/sysconfig/network-scripts/ifcfg-eth0 such as :

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static # we don't want dynamic IP
DNS=8.8.8.8  #PRIMARY GOOGLE DNS
DNS2=8.8.4.4 #SECONDARY GOOGLE DNS
GATEWAY=192.168.0.1 
IPADDR=192.168.0.5
NETMASK=255.255.255.0
NM_CONTROLLED=yes
NAME=eth0
UUID=93362f70-8dd3-4a27-bf66-6f1449259d5e #ALREADY DEFINED
DEVICE=eth0
ONBOOT=yes

Apply the changes :
systemctl restart network

FAQ

Problem : no internet access
Solution : check that /etc/resolv.conf refers valid nameserver (such as google dns : 8.8.8.8 or 8.8.4.4)

Ce contenu a été publié dans Non classé. Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *