System port forwarding

Discussions related to using VirtualBox on Linux hosts.
Post Reply
kiwi.paul
Posts: 2
Joined: 9. Apr 2019, 00:14

System port forwarding

Post by kiwi.paul »

I have seen a couple of posts on redirecting system ports (<1024) to a guest, basically you can't.
I think I have a good use case for this, because without it there is a great deal of complexity, or
perhaps y'all can provide a better solution?

I have a single IP address on which I wish to run a few VMs, one of which is a mail server.
I have a host set up with VirtualBox, but I need to redirect all mail port (25, 110, 587 etc etc) to
the guest running mail. Obviously none of the guest will be able to overlap with the ports they use,
so there can't be any other mail servers for example.

I cannot use Bridging because of the single IP address available.

What I have done, which is kinda complex, is to use iptables on the host to redirect all system ports
to high value ones - eg: 25 -> 8025.
Then using "VBoxManage modifyvm" I've port forwarded 8025 -> 25 in the guest.

This works fine, but as I start to add other application servers as guests, it kinda feels fragile
and prone to mistakes. Is there a better way?

Thanks for any advice you can give.
Cheers.
P
Post Reply