VirtualBox Serial Port Passthrough: The Extended 2020 Guide


Content

  1. Accessing serial ports in VirtualBox
  2. How to share COM ports with VirtualBox VMs
  3. Setting up COM port forwarding with VirtualBox

Accessing serial ports in VirtualBox


Given that virtual machines usually don’t fully support communications with host’s serial interfaces or their configuration may be rather complicated, it will be a good idea to use a dedicated third-party solution capable of redirecting COM ports to VirtualBox.

Serial over Network provides the ability to access serial ports in VirtualBox with nothing more than a couple of clicks. Thanks to advanced port virtualization technology that powers the app, it can redirect RS232, RS422 and RS485 interfaces to any guest OS over LAN or the Internet.

Sec logo

Serial to Ethernet Connector

4.9 Rank based on 52+ users, Reviews(86)
Serial to Ethernet Connector


How to share COM ports with
VirtualBox VMs


Here's a simple way to enable VirtualBox COM port passthrough using Serial to Ethernet Connector:

On your host computer with a serial device attached:

  1. Install Serial to Ethernet Connector and launch it;
  2. In the main menu, select New connection > Server connection;
  3. Adjust the port sharing settings: specify the COM port to which your serial peripheral is connected physically and the TCP port that will be used for the connection with your virtual machine;
  4. Click Create connection. This will make the COM port accessible over the network on the VirtualBox instance.

Now, to enable serial port in VirtualBox, do the following:

  1. On your guest OS, install the app and select New connection > Client connection in the main menu;
  2. In the settings window, enter the desired name for your VirtualBox serial port and check the Create as virtual port option.
  3. Then, type the name of the host PC, on which you have just shared the serial device and the TCP port you are connecting to.
  4. Click Create connection.

Once you have finished with the VirtualBox serial port setup, the host’s serial device will appear in your virtual machine like it was physically connected to the guest OS. You get full access to the contents and functionality of the peripheral.

Corporate, OEM & Source code
Looking at redistributing our Serial Port Redirection Engine as a part of your product or considering Serial over Ethernet Connector software for an enterprise-wide deployment? We offer flexible and affordable corporate solutions designed to meet your needs.

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.

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:

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

  2. 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.

  3. 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.