Hyper V Serial Port Redirector

Posted on by
Hyper V Serial Port Redirector Rating: 4,3/5 3772 votes

Solution for Terminal Server and Virtual Desktop Users. If you are Remote Desktop user, you can use your USB devices on remote Terminal Server or Virtual Machine as if they are plugged into it locally. Summary: Learn how to attach a device from your Hyper-V host to your VM by using a new feature of Windows Server 2016. Today we have a guest blogger, Rudolf Vesely, who has blogged here on previous occasions. Here is a link to his previous posts if you would like to read them.

PipeDream: Connecting serial hardware to virtual machines

If you are looking to connect serial hardware to virtual machines running under Hyper-V, PipeDream is the answer. PipeDream runs on the server that runs Hyper-V (the virtualization host) and acts as a bridge between a serial port and a virtual machine. PipeDream communicates data received from the serial hardware to a virtual serial port for the virtual machine, and vice-versa.

PipeDream runs on the server only without requiring any client side components. There is nothing to install on the virtual machine: no device drivers or other software. This maximizes compatibility with legacy operating systems and software, with operating systems such as XP or earlier readily supported.

With PipeDream, guest virtual machines can use serial ports on the virtualization host (or another computer). PipeDream works using Hyper-V's named pipe support, so it doesn't need a network to communicate: set the pipe name in Hyper-V, then run PipeDream to connect the serial device to the guest VM.

Disclaimer: PipeDream works with Microsoft's Hyper-V but is an independent software product. We are not affiliated with Microsoft, and our use of the term Hyper-V is not intended to indicate any endorsement from or affiliation with Microsoft Corporation.
Download

Version 2.4 is now available for download - click the button below to download a time-limited and fully-functional trial.

Most recent operating systems include the required Microsoft files. If PipeDream fails to start under your host operating system, please first install the Microsoft redistributables that are available here.

Installation

Simply extract the downloaded zip file and run the PipeDream executable (pipedream .exe). If you get an error message about missing components, run vc_redist.x64.exe (included) first, then re-run PipeDream.

PipeDream requires administrative privileges to save its configuration. To configure the proper settings for your serial device right click the PipeDream icon and select 'Run as administrator.'

Hyper V Serial Port Redirector
Serial device (link) settings

Every serial device is different and many are not plug-n-play. Getting your device to work properly requires knowing baud rate and flow control settings for your device. PipeDream defaults to 9600,N,8, 1 with DTR on and DSR enabled for both directions. If you have any trouble establishing or maintaining communication between the virtual machine and your serial device (such as data sitting in PipeDream's buffer without being sent to the device or PipeDream not reading serial data), we highly recommend checking that the serial settings for your device match the port settings in PipeDream. To do so, press the 'Change Settings' button in PipeDream.

Important: in addition to baud, stop and data bits, parity, and flow control, pay attention to the DTR and DSR settings as well. Many devices list the baud rate and flow control settings but are silent regarding DTR and DSR sensitivity. You may need to experiment with different settings to find the ones for your device.

Configuring Hyper-V for PipeDream
You can usually perform this installation on a live virtual machine, without needing to halt or shut it down.

Hyper-v Com Port Redirection

First, you need to setup a serial port for your guest virtual machine (vm).

Configuring for a Gen-1 virtual machine

Follow these steps if you are using a Gen-1 Hyper-V virtual machine:

  1. Start the Hyper-V Manager and bring-up the Settings for the guest vm where you want to connect the serial port.
  2. In the new window, select COM1 or COM2 from the hardware list on the left. This is the serial port where the virtual machine will be able to access your serial device. In other words, this port appears in the virtual machine and may be different from the physical serial port on the host.
  3. Attach the guest's serial port to a pipe named PipeDream, then press OK. To do this, click on Named pipe and enter 'PipeDream' for the pipe name, as shown in the picture. If your serial device is on a remote computer, check the Remote computer checkbox and enter the computer name.
Configuring for a Gen-2 virtual machine

If your virtual machine if Gen-2, then the pipe settings shown above are not configurable via the GUI - you will need to use Powershell commands instead. Open a Powershell session and then:

  1. Execute Get-VM, then copy the name of the virtual machine you want to connect to the serial port.
  2. Execute Set-VMComPort -Number <1 or 2, for serial port COM1 or COM2> -Path .pipePipeDream

To confirm the pipe was created, use Get-VMComPort. See the example screenshot below, for a virtual machine named SillyRabbit

License

Please contact us at support@makingtechhappen.com to obtain the full version of PipeDream.

Windows Server 2016 and Windows 10 adds the native ability for a NAT forwarding Hyper-V switch. This is really handful software-defined networking (SDN) or even lab environment. By default, there is no inbound access from the LAN to the virtual machines that are connected to an NAT-enabled (Internal) virtual switch. And you might want to access isolated virtual machines in your lab through RDP with your laptop. Actually, the old way was to create a specific virtual machine in this lab to act as a gateway. You can find more information in Microsoft documentation.

Hyper-v Serial Port Redirection

To create a new NAT switch using 172.16.0.1/16 subnet on your Hyper-V host, use these PowerShell commands:

Add-NetNatStaticMapping-NatNameNATnetwork-ProtocolTCP-ExternalIPAddress'0.0.0.0/24'-InternalIPAddress172.16.0.10-InternalPort3389-ExternalPort50000
Port

With this configuration, you will be able to connect to your isolated lab virtual machine (IP: 172.16.0.10) through your host “public” IP and the port 50000 using RDP without additional VM to configure.

Note
You will need to configure the firewall of the Hyper-V host (and even maybe your router if pointing to a public address) accordingly to the NAT mapping rule.