# How to NAT (Virtual Server) port 22 ?



## hamedx (Feb 9, 2010)

hi 
i have a dsl modem with (1) dynamic valid ip who will set in modem by isp and a PC that connected to dsl modem. i'd configure the NAT section in Modem Settings to forward ssh port 22 on the valid IP but after that its not work from the outside (Internet) with putty or other client software .

how can i reach that ?


----------



## DutchDaemon (Feb 9, 2010)

Do you see the connections on the network interface connected to the modem?
`# tcpdump -s 0 -pnli [i]interface[/i] port 22` (chnage _interface_ to the name shown in [cmd=]ifconfig -a[/cmd])

Is sshd listening on that interface?
`# sockstat -l4p22`


----------



## hamedx (Feb 10, 2010)

dear DutchDaemon
this is a result of that :

*TCPDump :*

```
listening on vr0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:06:49.962132 IP 192.168.2.100.22 > 192.168.2.22.4333: P 819051978:819052174(196) ack 869581616 win 65535
09:06:49.962278 IP 192.168.2.22.4333 > 192.168.2.100.22: . ack 196 win 65535
09:06:50.963023 IP 192.168.2.100.22 > 192.168.2.22.4333: P 196:344(148) ack 1 win 65535
09:06:50.963044 IP 192.168.2.100.22 > 192.168.2.22.4333: P 344:460(116) ack 1 win 65535
09:06:50.963165 IP 192.168.2.22.4333 > 192.168.2.100.22: . ack 460 win 65271
09:06:51.964266 IP 192.168.2.100.22 > 192.168.2.22.4333: P 460:592(132) ack 1 win 65535
09:06:51.964300 IP 192.168.2.100.22 > 192.168.2.22.4333: P 592:804(212) ack 1 win 65535
09:06:51.964450 IP 192.168.2.22.4333 > 192.168.2.100.22: . ack 804 win 64927
09:06:52.965537 IP 192.168.2.100.22 > 192.168.2.22.4333: P 804:936(132) ack 1 win 65535
09:06:52.965565 IP 192.168.2.100.22 > 192.168.2.22.4333: P 936:1148(212) ack 1 win 65535
09:06:52.965717 IP 192.168.2.22.4333 > 192.168.2.100.22: . ack 1148 win 64583
^C
11 packets captured
20 packets received by filter
0 packets dropped by kernel
```

*sockstat*

```
root     sshd       878   4  tcp4   *:22    *:*
```


by the way i had nat the IP Camera and MiFare Reader Devices with Specified Port through the modem on the dynamic ip addr and they are reachable on the net ,so, what should i do ? do i need to get the range of ip from my provider or this is gonna be work ?


----------



## DutchDaemon (Feb 10, 2010)

What are these hosts (192.168.2.100, 192.168.2.22)? If you connect from the outside (over the Internet), the public IP you're connecting from should show up as the source of the ssh connection.


----------



## hamedx (Feb 10, 2010)

today i bought range of 8 public ip(s) for my server , that private ip's (192.168.2.100 - 192.168.2.22) was for my pc and the bsd box that connected to each other.

everything solved after that , the only thing is i cannot login to my bsd box from the VPS Server (213.175.xxx.xxx) over ssh..
should i ask in this topic about this matter or create a new one ?


thanks for reply and your always kindly help


----------

