[Ilugc] remotely accessing a machine on a lan with dynamic IP

  • From: 0@xxxxxxxxxxx (0)
  • Date: Wed, 08 Feb 2012 17:33:23 +0530

I maintain a server in a remote place. It is connected to a LAN - the
LAN is the usual poor man's LAN which uses the BSNL router as the dhcp
server. They have dynamic IP from bsnl. The machine the machine has a
fixed IP (192.168.1.123). The inward facing IP of the router is
192.168.1.1. Is it possible to ssh into this machine from outside, and
if so how?

This is pretty simple to do, I have been using it for a few years now.

There are three parts to the problem,

1. Accessing your Dynamic IP
2. Opening your SSH port
3. NAT Loopback

(1) Dynamic IP

Since the IP is dynamic, you need a domain name which can be updated 
periodically. There are several dynamic DNS providers, one of the 
popular ones is dyndns.org which is now dyn.com. They provide a couple 
of REST APIs which you can use to get your external IP and update the IP 
in your dyn.com account.

I have attached the shell script which you can use. Just modify the 
script with your newly created dyn.com account name and password.

(2) Port forwarding

BSNL modems are unpredictable when it comes to port forwarding but you 
can try it out. In the port forwarding table, just specify incoming port 
22 to be forwarded to IP (192.168.1.123) and port 22.

(3) NAT Loopback

This is just something you should know, it is not required. Even after 
the above setup, you might not be able to access your domain name 
directly from your internal network if the router doesn't support NAT 
loopback. AFAIK, linksys/cisco routers support this while the basic 
netgear routers don't. I don't know about BSNL modem/routers.

In case you are interested, the script does the following,

- gets your external ip
- resolves the domain name to the current ip
- if the current ip and external ip are different, issues an update.

Hope this helps.

-- 
0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: update_dyndns.sh
Type: application/x-shellscript
Size: 983 bytes
Desc: not available
Url : 
http://www.ae.iitm.ac.in/pipermail/ilugc/attachments/20120208/958088cb/attachment.bin
 

Other related posts: