0

Hello I recently asked a question about running multiple websites on different servers on the same network here multiple servers running the same thing, how? I have researched about setting up a reverse proxy and it works no problem, now I want to be able to do the same thing but for other services such as SSH etc. I know this isn't exactly possible using the HTT protocol, but is there any other way of doing it? If not I am wondering how I can go about getting IP addresses on my network? I have a VPS that I can buy IP's for would I be able to map these extra IP's to servers here? Would that only be possible by using a VPN or something or is there better ways of going about it? Thanks for any help in advance, you guys do a great job here.

3
  • Are you looking for port forwarding? That is, forward ports on your public IP address to your private network. Sep 21, 2014 at 12:45
  • Hi, thanks for the answer Tero. Nope this isn't quite what I need, although port forwarding would work, I would need to change the ports for different applications on each server, I want to be able to use the same ports on each server, and access each server from different domain names, e.g SSH running on port 22 on 2 servers, one server accessed from s1.example.com and the other server accessed from s2.example.com, this is easy to do for apache using reverse proxy but doesn't work the same for other applications as far as I am aware.
    – Lee Work
    Sep 21, 2014 at 13:06
  • 1
    You cannot do this, since SSH doesn't know anything about host names, it only deals with IP addresses. In HTTP/HTTPS protocols there are hostname fields, which allow many hostnames to be hosted on same ports / IP addresses. Sep 21, 2014 at 17:41

2 Answers 2

0

I believe you want what is often called 1:1 NAT ("1 to 1 Network Address Translation"). Its prime purpose is is map a range of TCP/UDP ports from one address to another.

In Linux Netfilter (iptables), you would use the -j NETMAP target in the -t nat table's -A PREROUTING chain:

   NETMAP
       This  target allows you to statically map a whole network of addresses
       onto another network of addresses.  It can only be used from rules  in
       the nat table.

       --to address[/mask]
              Network  address to map to.  The resulting address will be con-
              structed in the following way: All ’one’ bits in the  mask  are
              filled  in  from  the new ‘address’.  All bits that are zero in
              the mask are filled in from the original address.

Since you seem to be referring to a single host to map to, your mask will be a /32.

Hope that helps, Cameron

1
  • Thanks, this is what I need I think from researching a little about it. Although it would be much simpler if I just buy some static IP's from my ISP to achieve the same (sort of) thing, so I am going to do that. Thank you all for your help, much appreciated.
    – Lee Work
    Sep 22, 2014 at 13:17
0

You are looking for NAT (network address translation... discarded due the extra ip addr cost), or PAT (port addr translate... discarded due the same port limitation). The other option is using a socks proxy that clients could setup to their client applications.

For example with ssh:

ssh [email protected] -D 9050

ssh user@internal-server -o "/usr/bin/nc --proxy-type socks4 --proxy localhost:9050 %h %p"

Finally you could be looking for a VPN solution like openvpn that pushes routes to your authenticated clients and that could access all server ports.

Hope this answer helps you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .