I've configured multiple IP Addresses on my Ubuntu ssh server. Now the server can be accessed by using any IP Address, from 192.168.0.51 to 192.168.0.99.
Depending on which IP Address someone uses to access this server, I want the request to be forwarded, to localhost, on a specific port. For example:
If I ssh on IP address 192.168.0.51 the ssh server should forward my request to localhost:5001
If I ssh on IP address 192.168.0.52 the ssh server should forward my request to localhost:5002
If I ssh on IP address 192.168.0.53 the ssh server should forward my request to localhost:5003
In essence this will actually forward the session to another host which is connected on this ssh server using reverse nat.
Maybe this ?
/sbin/iptables -t nat -A PREROUTING -d 192.168.0.51 -p tcp --dport 22 -j DNAT --to 127.0.0.1:5001
EDIT :
This ?
iptables -t nat -A PREROUTING -d 192.168.0.51 -p tcp --dport 22 -j REDIRECT --to-port 5001