2

I have linux server behind NAT but i can farward the port to LAN computer.

How can do that so that at least i can ssh

4 Answers4

2

The standard port for ssh is 22.

You have to tell your router to forward a port (22, tcp) to your linux machine's IP. This is usually in a section called 'NAT' or 'Servers' in your router's configuration.

Most OSs have a firewall installed as standard. So you may have to open port 22 on your server machine's software firewall as well. (try 'ipkungfu' for a fairly simple interface to set up a linux firewall)

Loopo
  • 415
  • 1
  • 9
  • 20
  • Don't forget the part about setting your server to a static IP internally. Otherwise you'll risk eventually having the machine "disappear" after coming back up from a power outage. – Bart Silverstrim Apr 30 '10 at 11:22
  • A static IP *outside* the DHCP pool, that is. – Bart Silverstrim Apr 30 '10 at 11:22
  • What about if we have two or more machines behind the NAT and we want to be able to SSH them all. – AFA Med Nov 10 '17 at 17:16
  • you can assign a different port on your firewall and forward it to the second machine e.g. incoming tcp on port 10022 (or any other port you like) goes to internal ip of second ssh server port 22 (depending on your firewall you can set the port of the internal machine or configure your ssh to listen on port 10022) – Loopo Nov 14 '17 at 02:29
1

Reverse SSH if you dont have access to the router

1

You have to use DNAT.

gogiel
  • 261
  • 1
  • 3
0

On the device which is doing the NAT you need to setup port forwarding.

This will forward incoming traffic on the chosen port to a particular server behind the NAT device.

How you set this up will depend on what device it is.

Coops
  • 5,967
  • 1
  • 31
  • 52