Index ¦ Archives ¦ Atom ¦ RSS

Accessing your home computer from the internet

networkingI recently bought a computer to use at home for development. Sometimes I have to access stuff (code, pictures, bittorrent) on my machine when I am away from home. I keep my machine running all the time and recently upgraded my internet connection from 128 kbps to 512 kbps. If you are in Bangalore, India, Airtel offers unlimited bandwidth at 512 kbps for Rs 1499 (\$38) a month.

Since I had the essentials in place, I started setting up things to make my machine accessible from anywhere. These are the goals I had in mind.

  1. A domain name - to access my machine without having to remember an ip
  2. ssh access - so I could login and muck around
  3. http access - so I could host a mini-site with photos etcetera

How do I manage with a dynamic ip?

The problem with having an ADSL connection provided by Airtel (and most other internet service providers) is that the ip changes every time you reboot the modem. This is quite a pain even if you can keep your modem turned on all the time. My initial plan was to set up a script on my machine which would ping my website every once in a while to update the ip address. With this I could visit a special page on my website which would list the latest ip address of my home machine.

Dynamic DNS

dyndns.orgI was about to implement this when I came across Dynamic DNS. Dynamic DNS is a mechanism similar in some sense to the one I described above. Basically, your ADSL modem connects to a DNS server every time it gets a new ip and registers it. The DNS server is configured to resolve a domain name to this ip when a DNS request comes in from anywhere on the internet. This is a wonderful solution because most ADSL modems come with this functionality built into the firmware (my Beetel 220BX does too).

To get started, you will have to register an account with one of the Dynamic DNS service providers. DynDns.org, TZO, No-IP are the popular players. You can find a comprehensive listing here. I chose DynDNS.org. After you create an account, goto “Host services” and select “Add new Hostname”. Choose a sub-domain and domain here and click on “Create Host”.

Now you will have to configure your modem/router with this information. Your modem’s web interface will usually be 192.168.0.1 or 192.168.1.1. In case you have a Beetel modem, open IP_ADDRESS/main.html (eg: http://192.168.1.1/main.html). Here choose DNS > Dynamic DNS and fill in the details as shown (username and password are your Dyndns account details). Save the settings and you are done!

You should be able to access the web admin page of your modem using you DynDNS domain name (for me using the domain from my home network does not work for some reason, but I can access from outside).

Getting SSH access working

I am assuming that your computer is directly connected to the ADSL modem. You will have to install an ssh server. I have Ubuntu installed, so I installed OpenSSH server.

sudo apt-get install openssh-server openssh-client

Now that the SSH server is running, you have to allow access to this port through your modem from the internet. By default all incoming connections except 80 and a couple of others are blocked on my modem (as is the case with most modems). You have to tell your modem to allow access to port 22 and also to forward requests coming to your ip at 22 port to port 22 of your computer. Here is how you do it.

First configure the firewall on the model to let through connections to port 22. Goto the web admin page of the modem and navigate to Advanced Setup > Security > IP filtering > Incoming. Click on the “Add” button and set filter name to “ssh” and destination port to 22. “Save/Apply” now.

At this stage, incoming ssh requests are allowed but there is no ssh server available on the modem to handle them, so we must tell it to forward these requests to your computer where the server is setup. Navigate to Advanced Setup > NAT > Virtual Server. Click on “Add” here. Select “Custom server” and type “ssh”. In the server ip address provide the ip address of you computer. You will see a row of input boxes below for port numbers. Fill all the boxes in the first row with 22. For protocol choose “TCP/UDP”. Click “Save/Apply”. You are done. All ssh requests will now be forwarded to the ssh server running on your computer.

modem web admin
login Login box for ADSL modem web admin page

adding host to dyndns
account Adding a host in DynDns.org account

modem dyndns
setup Setting up Dynamic DNS on the modem

SSH port forwarding modem
setup Port forwarding for SSH

Setting up HTTP access

You will need a web server on your computer. If you have Ubuntu, it is straight-forward to set up Apache.

sudo apt-get install apache2

apache You can customize the web site now by editing files in /var/www. Now you have allow access to the web server from the internet. The issue here is that port 80 which is the default port for http is used by the web admin page for the modem. So we have to settle for some other port. I chose 8080. Follow the steps for ssh (replacing 21 by 8080), but in the port forwarding step, set destination ip to 80 instead of 8080. This should get things working.

You are now on the internet, Baby!

You can now access you machine using ssh at your-sub-domain.dyndns.org and visit you personal webpage at http://your-sub-domain.dyndns.org:8080. Enjoy!

Additional links

on the internet

© Prashanth Ellina. Built using Pelican. Theme by Giulio Fidente on github.