Cookie
Electronic Team, Inc. uses cookies to personalize your experience on our website. By continuing to use this site, you agree to our cookie policy. Click here to learn more.

COM port in Virtual Machine —
VMware, VirtualBox and Hyper-V COM port passthrough



If you have a serial port console, modem or any other COM-based peripheral connected to your computer and need to connect this device to virtual machine, you can do this with a Serial Server software. While some virtualization apps let you connect to your host’s serial devices after you just make some additional configurations, adding COM ports to virtual machine can be quite troublesome. Continue reading to find out how to forward COM ports to virtual environment.

Contents


The easiest way to access COM in Virtual Machine

Serial to Ethernet Connector is a powerful network solution that makes virtual machine COM port passthrough possible.

Serial Server software is designed to create virtual copies of real serial ports and with the help of SEC, you can establish a client connection from your guest OS to a serial port of any computer connected to your network. Оnce a serial device is attached to the hardware port, the device will appear in your guest system like it was connected physically.
Sec logo

Serial to Ethernet Connector

4.9 Rank based on 52+ users, Reviews(86)
Download 14-day fully-functional trial period
Serial over Network Connector

Even if your computer has physical serial ports, there are times you need to communicate with peripheral devices that are remotely located and do not present the possibility of a direct connection. Here again, Serial Server software can solve your problem. The same virtualization technology that allows you to access serial devices without a COM port lets you establish RS232 over IP connectivity to network-attached equipment. Once connected, you have the same level of control over the device as if it was directly connected to your computer.

Serial to Ethernet Connector can be used in many scenarios to enable network communication between your serial devices. This capability increases the value of POS equipment, medical instruments, and industrial control systems by enabling them to be accessed by anyone in your organization no matter where they are physically located.

Some of the uses of this specialized virtualization software solution include:

  • Connecting to COM ports from within virtual environments like Virtual Box, VMware, and allows Hyper-V serial port passthrough;
  • Creating multiple virtual RS232, RS422, and RS485 ports that your system can use like physical interfaces;
  • Sharing serial devices on Windows and Linux machines over IP networks. Support is also provided for ARM-based devices;
  • Enabling two-way communication over UDP/IP from virtual or physical COM ports. Serial to Ethernet Connector (SEC) works over any distance, so it doesn’t really matter where a COM port device is located physically. Once you install the app on the server, to which a required device is attached, and client computers, you can connect virtual serial ports over IP and communicate with the device remotely.

How to add COM ports to virtual machines

To be able to redirect COM ports to Hyper-V virtual machines, you will need to have Serial to Ethernet Connector installed on the local and remote computers. It will virtualize the COM ports and connect them with the virtual machine instance.

How to connect COM ports with SEC

On the host computer:

Download and install Serial to Ethernet Connector.

Launch it and go to the "Server connection" tab and specify the host’s COM port, to which the device is attached, as well as a TCP port to listen on.

Click “Create server connection”.

On your guest operating system:

Install the software, launch it and head to the “Client connection” tab.

Specify the host’s IP address and the TCP port you selected for the “server connection”.

Choose the name for your virtual machine’s COM port and enable the “Create as virtual serial port” option.

Click “Create client connection to enable Hyper-V COM port redirection.

This is it! Once you create a client connection, the app links your virtual serial port to the real COM interface of the host system. As a result, you can forward virtual COM port over Ethernet to Hyper-V and access a serial device connected to this port right from your virtual machine.

Hyper-V native method - Hyper-V COM port passthrough

Now let’s consider how to set up Hyper-V serial port passthrough. To be able to work a serial port in Hyper-V virtual machine, you should do as follows:

In Hyper-V Manager:

Hyper-V COM port passthrough

Right-click the required virtual machine and open its “Settings”;
Go to the “Hardware menu” and select the serial port you need (let it be COM1);
Click on the radio button “Named pipe”;
Now, type the pipe name (e.g. COM1);
Hyper-V will show the named pipe path (like \\.\pipe\COM1).
Connect to the named pipe using the path you got earlier. A serial client (like Putty) will help you do this.
Also, you may need to run As Admin for your terminal client.
To show a list of all named pipes that you currently use, run the following command in a PowerShell terminal:
[System.IO.Directory]::GetFiles("\\.\\pipe\\")
To check if a certain named pipe exists, use: [System.IO.Directory]::GetFiles("\\.\\pipe\\").Contains("\\.\\pipe\\COM1")

PipeDream for Hyper-V:

connect COM ports in Hyper-V

PipeDream is a software solution that assists in creating connections between virtual machines and COM ports residing on the virtualization hosts. PipeDream offers Hyper-V's named pipe support, meaning that there’s no need to connect to the network. All you need to do is specify the pipe name in Hyper-V and use PipeDream to redirect a serial device to your guest OS.

Open Hyper-V Manager, go to Settings of the required virtual machine and choose COM1 or COM2 from the list of available hardware.
The selected serial port will be used by your guest virtual machine for connecting to the host’s serial device.
Then, configure the virtual serial port to communicate through a named pipe:

click on “Named pipe” and type the name "PipeDream".
After that, just run PipeDream on the host computer to connect your serial device to the guest VM.

Forward serial ports to VMware Workstation

You can add up to 4 serial connections to VMware Workstation. This allows you to share different serial devices and make them available to the VM. The virtual interfaces that are created can redirect data to the physical serial ports, files or a named pipe. This is especially useful for debugging, where the virtual port can send data to the host or to other connected VMs.

VMware Workstation

Here is how to add serial ports in VMware Workstation:

Shut down the virtual machine
Select the VM and choose ‘VM > Settings”
Select “Add” from the “Hardware” tab
Select “Add Hardware” wizard and choose “Serial Port”
Click “Finish”
Select the destination of the serial port output
You can direct the output to the VMware host’s physical serial port.
Create a connection between virtual sessions or between a virtual session and the host with a named pipe.
Use any file on the host as an output file. You can create a new file or select an existing one by simply typing the name in the directory.

If you have opted for a named pipe output, you’ll need to adjust your configurations according to your operating system as follows:

Linux Hosts

Add a UNIX socket name in the text box. The name must be the same on the client and the server and should look like this: /tmp/socketname

Windows host

You can enter a customized name or leave it as the default setting. The pipe name must be the same on both the client and the server, and it must follow the naming convention of \\.\pipe\.

When transmitting data between the server and the virtual machine, always configure the sender by selecting the “This End is the Server” option, and setting the receiver as “The Other End is the Application”.

If you want the VMware Workstation to connect to the serial port when the VM is turned on, select the “Connect at Power On” option.

Bear in mind when there are a number of virtual machines connected, the first VM will usually be the server.

Now to configure other VMs, simply repeat this process. If you are configuring the named pipe, you must define the client by selecting ‘This End is the Client”.

You’re now well on your way to redirecting serial ports in VMware. You can access different serial devices from any virtual session allowing you to have a wider, more valuable resource pool to share across your organization.

Setting up COM port forwarding with VirtualBox

As a VirtualBox user, you might wonder how to configure virtual serial ports on VirtualBox and if there’s a native method to do this.

Basically, you can use VirtualBox to add virtual COM ports to your guest OS. In the native scenario, once you enable a virtual serial port, your guest operating system is presented with a UART device allowing the reception and transmission of serial data. All you need to do is configure VirtualBox serial port passthrough. However, it should be mentioned that the configuration procedure largely depends on which OS your host runs.

VMware Workstation

To create a VirtualBox virtual serial port, you can either use the VBoxManage command or the Settings tab. But keep in mind that one of these methods lets you configure no more than four virtual COM interfaces for each guest OS.

In view of this, you will need to adjust the Port Mode and Port Number, where the Port Number is the COM port seen by the VM and the Port Mode is the COM port status. It can be “Disconnected”, “Connected to Host Device”, or “Connected to Host Pipe”:

Disconnected indicates that the device can be recognized by the guest system but will work like no cable is connected.

Connected to Host Device means that the VM’s port is linked to the COM port residing on the host. In Windows, this port will traditionally have a name like COM1. On Linux, it can be called, for example, /dev/ttyS0.
In this case, all data going through the virtual port will be forwarded by VirtualBox to the physical port and device attached to it.

Connected to Host Pipe is used when the Oracle VM VirtualBox is set to establish a connection between the virtual COM port and one of the host’s software pipes.

Try Serial to Ethernet Connector Now
14-day free trial

Depending on the host operating system this means the following:

On Windows, the data is transmitted over a named pipe. The pipe name is registered as \\.\pipe\ with serving for the machine identification.

On macOS, it will be a local domain socket. As for the socket filename, it should be chosen to allow the VirtualBox user to have certain privileges for creating and writing it. Commonly the tmp is chosen.

On Linux, some multiple tools connect to a local domain socket or develop one in the server mode. Socat is a widely used one which is available across distributions.

If you want to create a direct link between two guest systems, you should consider configuring one of them to develop a socket or pipe and the other one to connect to it.

Raw File: The virtual serial port data can be saved to a file, which is especially helpful for diagnostic purposes. The user can select any file if they have enough privileges to write and create.

TCP Socket: This is used when there's a need to redirect serial data over the TCP/IP protocol. It can take on the role of a client or act as a server. With this option, you can connect directly to a remote computer from a guest OS over TCP.

TCP Server: to use this option, you need to uncheck the current Pipe/Socket checkbox and provide the port number in the address field. You can select 23 or 2023 as the port number. But if you use a UNIX-like system be sure to choose the port number that is more than 2024.

TCP Client: when it’s required to establish a virtual null-modem connection over LAN or the Internet, on the other end there should be a connection over TCP with specified “hostname: port” in the Path/Address field. After you check the box "Connect to Existing Pipe/Socket", the TCP socket will be able to work as a client.

As is seen from this guide, you can configure four COM ports for each guest OS. As for port numbers, you can select multiple ones.

In this brief tutorial, we’ve considered the simplest and most common ways of using VirtualBox to share COM ports and connect to the host’s devices. As you can see, with the dedicated software Serial to Ethernet Connector, you can easily access local peripherals in your VirtualBox virtual machine like they were attached directly to the guest system.

small logo Serial to Ethernet Connector
#1 at Serial Port Software
Serial to Ethernet Connector
Access remote serial port over IP Network for Windows
Get a download link for your desktop
Submit your email address to get a link for quick download on your desktop and get started!
or