negative zero

My server setup 2

2022 September 23

[networking] [tech]


Last month, I wrote about how I have my server set up. I had the awkward inability to forward traffic from the host to the VMs:

The biggest issue with this setup is that there are no instructions on the host to forward incoming traffic to VMs. This means that I can't connect over LAN, and if I end up again with an internet plan that supports hosting a server, I won't have an easy way to port forward from the router.

Well, now I have a solution for that! Someone from my school suggested I could use a simple TCP packet forwarding program. With the help of a tool called socat, I'm now forwarding traffic from the host to the VMs as needed.

Here's what the command looks like:

# socat TCP-LISTEN:443,fork TCP:192.168.122.80:443

This listens on port 443 and forwards this traffic to 192.168.122.80 on port 443. As someone on Reddit suggested, I made some SystemD services for this, for example /etc/systemd/system/socat-443.service:

[Unit]
Description=Forwards 443 to 192.168.122.80:443

[Service]
ExecStart=/usr/bin/socat TCP-LISTEN:443,fork TCP:192.168.122.80:443

[Install]
WantedBy=multi-user.target

Now I can connect over LAN! Hooray!