The simplest solution is to use a comtrol or similar device. We used many of these where the distance was great and or on virtual machines.
https://comtrol.com/ethernet-device-servers/devicemaster-panel-mount/devicemaster-rts-1port-db9
--please don't forget to upvote
and Accept as answer
if the reply is helpful--