I have this setup:
(Host) FreeBSD 9.2 host server running VirtualBox with another
(Guest) FreeBSD guest server. I have set up port forwarding on the
Host to the
Guest like this:
VBoxManage modifyvm "Guest" --natpf1 "guestssh,tcp,,9201,,22" VBoxManage modifyvm "Guest" --natpf1 "guestmysql,tcp,,9202,,3306" etc ...
This works fine. I can for example
ssh -p 9201 user@localhost just fine.
Also I have a domain (let's say
example.com) with DNS adress record pointing to the
Host ip. And this also works as expected
ssh -p 9201 email@example.com.
Beside the main domain I have subdomains like
mysql.example.com. Now I need incoming traffic from those domains to be forwarded to specifc ports on the virtual machine. So
ssh.example.com:22 -> localhost:9201 mysql.example.com:3306 -> localhost:9202
For SSH this is easily achieved on a single *nix clinet by setting up
~/.ssh/config like this:
Host ssh.example.com Port 9201
But I need to forward services other then SSH as well (like MySQL, VNC, HTTP, etc.). Plus the ports may change as I'll add new Virtual Machines for specific services.
So my question is: how can I configure the
Host machine to forward incoming traffic
I've tried to set up firewall for this, but this was obviously wrong way to go, as the domain names resolve to ip adresses. Setting up a SSH forwarding with
ssh -L is also a bad idea. So what else is left?
EDIT: I can acces the raw DNS record and reconfigure it, so I was thinking maybe if I can bind some kind of information to the domain and catch it with a proxy software on the