Domain – How to access machines inside a network via ssh from over the internet

binddomaindomain-name-systemnetworking

This is probably a really basic question for most of you guys out there. But i'm quite new to networking with linux etc. Heres the scenario:
I have 3 webservers inside a network. lets say they have the following host names and ip address:

server1 = 192.168.0.1
server2 = 192.168.0.2
server3 = 192.168.0.3

All trafic comes in to the router and DMZ is server1. eg: example.com will bring me to local host on server1 and i can ssh over the internet to server1 using my static ip address and example.com. What i want is that if i use server1.example.com it will go to server1, and server2.example.com will go to server2, etc.

I guess this is all sorted using DNS with BIND? Am i at least on the right track? Does anyone have any info how i can set this up or a link to a tutorial or something?

I realise i could change the ssh port for each server but this is not optimal because all traffic (http/ftp/ssh/etc) should be forwarded to for example server3 when server3.example.com is used.

Tunneling to each server via server1 is also not an option for me because users of server3 should not have access to server1.

Any help would be much appreciated! Thanks!

Best Answer

This is a grossly-simplified explanation, but what you want to do cannot be achieved without changing ports on the outside because the firewall that's in front of your 3 servers doesn't "care" what the hostname is; it only cares about IP addresses and ports and as such has no way of knowing what server it is that you want to connect to.

Now if you can burn a couple of extra public IP addresses, you can do 1:1 NAT (sometimes called "DMZ mode") so that server1, server2, server3 effectively have their own public IP addresses and then you can create server1.example.com to resolve to server1's NAT'ed public IP address and so on.

There might be an SSH daemon or reverse proxy out there that "understands" the SSH protocol enough to do this by hostname, but my guess is not (and perhaps someone well-versed in the SSH v2 protocol can elaborate).

Related Topic