I want to forward Microsoft Remote Desktop on a Linux Server, assume that the remote Windows host is 192.168.1.100
, I want to run:
socat TCP4-LISTEN:3389,fork TCP4:192.168.1.100:3389
socat UDP4-LISTEN:3389,fork UDP4:192.168.1.100:3389
It works fine when I start the service by hand in the shell, but I want to start it with systemd
, and log into /var/log/socat-rdp.log
.
After some trials I can run the service like this:
[Unit]
Description=Socat RDP Forwarding Service
After=network.target
[Service]
Type=forking
User=root
ExecStart=/bin/sh -c "/usr/bin/socat TCP4-LISTEN:3389,fork TCP4:192.168.3.153:3389 > /var/log/socat-rdp.log 2>&1 & /usr/bin/socat UDP4-LISTEN:3389,fork UDP4:192.168.3.153:3389 > /var/log/socat-rdp.log 2>&1 &"
ExecStop=/bin/kill $MAINPID
[Install]
WantedBy=multi-user.target
This configuration starts and runs normally, but when I stop the service with systemctl stop socat-rdp
it returns error code 1, although socat
process is killed as normal.
Are there any better solutions?