Sunday, June 7, 2009

BSNL Broadband FTP Connectivity!

Bsnl is the 'de-facto' standard for most Broadband using homes, specially in my area. Known for it's cool speeds, abridged connectivity and easy availability from Bsnl landline makes it a very easy and optimum option for most junta.

Recently I was fiddling with the router/modem that the Bsnl guys supply with their Connection. It was pretty interesting to note that you have the option to allow access to some ports like FTP( 21 ), Telnet( 23 ) and even port forwarding.

I dont know if people have tried this thing but I was able to make my computer visible to the internet by a mix of Port Forwarding and Opening the FTP port for access. This guide shall take you through a detour as to how you can be in touch of your Desktop PC connected via a Bsnl Router/Modem anywhere in the world ;).

Know My IP

First thing to note about Bsnl connection is that your global IP( IP of the modem ) is Dynamically assigned by the Bsnl guys. This is helpful in using a smaller range of IP's to serve to a large number of users. Suppose Bsnl serves 1000 connections, but only 500 are online at a given time. If it uses Static IP's then it has to purchase 1000 such IP's! But if it assigns them Dynamically then only 500 shall do... reducing the production cost by 50 % ;)

So in order to access your computer through any Internet m/c you need to know your IP at that given instant. Hmm, I dont know a fixed way to do this, but if ur computer remains on for a particular session... the IP cannot change during that time! You can use www.knowmyip.com for the current session IP.

Typical Results
---------------------------------------------------------------------------------------------------------
Your ip is: 59.95.178.126
Your hostname is: 59.95.178.126

---------------------------------------------------------------------------------------------------------


Hence your IP is the above value! Bsnl has two typical ranges, this is the old modem/router range.

Locally Static IP

The computer which you use to connect to internet is inside the router's network, this is called subnetting whereby a group of computers connect to a common gateway for their internet requests! You can have a good overview here, rather DO HAVE A VIEW AT THIS: http://www.portforward.com/help/portforwarding.htm

You might skip the part from Port Forwarding but the rest is essential for understanding. Your task is to assign a Staic IP to your computer. Then you need to set your computer to a Static IP by the following: http://www.portforward.com/networking/static-xp.htm

For linux do the following:

1. $/sbin/ifconfig -- Note the information corresponding to the Internet Connection
2. vim /etc/network/interfaces

In the interfaces file locate the Ethernet number corresponding to the Internet connection, if it is presently on dhcp the entry will be like:

iface eth0(1) inet dhcp

In this case change this Dynamic Allocation to Staic by:

iface eth0(1) inet static
address
netmask
gateway

And restart networking by:

$/etc/init.d/networking restart

This will give you the Static IP required for the purpose!

Open the FTP/TELNET Ports on Router

The router by default will reject all incoming information that is not a reply to some query by you. But in case you want to access the computer from a remote place you need to tell the router to allow specific port to be open for access. In my router the following page is helpful, it's a bsnl router so log in by putting this in the browser address bar:

http://192.168.1.1/

Use admin:admin as the uname:pass, if you have urself changed it earlier use that pair instead!

Following pics are for UT300R2U Modem.


As you can see that the common services are blocked in here! If you have a page similar to this try unblocking the FTP/Telnet services so as to allow access from outside! This might be just a precautionary measure so that we do not get locked from router itself!

Port Forwarding

Follow the instructions from http://www.portforward.com/english/routers/port_forwarding/routerindex.htm for your specific router! Remember we will be doing a FTP login... hence forward the port 21 for now. Also allow all ports from outside to connect to your FTP port!

Setting Up the FTP

There are many lot Operating Systems and also solutions for a FTP server, my personal choice is vsftpd which is a lighweight FTP server for Linuxes, in case of Windows, try scratching the market for an appropriate solution :).

You need to configure your FTP server according to your own needs, generally you would like to keep anonymous login DENIED so that only authorized personnel( generally only YOU ) may access the resources! I would not go into the working of FTP server as it is not a part of this scope.

Testing the FTP

For testing the FTP there are two ways, one from your own computer or a computer inside the LAN of the router/modem and other is from an external network. The better of the two is to use the external network, but then you'll have to find a patient person to give instructions :P.

From within the computer

Ftp into the local computer set for port forwarding
--------------------------------------------------------------------------------------------------------
$ftp 192.168.1.4
Connected to 192.168.1.4.
220 (vsFTPd 2.0.7)
Name (192.168.1.4:sanket): sanket
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
--------------------------------------------------------------------------------------------------------
This output shows that your system is accepting FTP connections from local network.
Try to retrieve files,
--------------------------------------------------------------------------------------------------------
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x 2 1000 1000 4096 Jun 05 06:08 Desktop
<...>
drwxr-xr-x 24 1000 1000 4096 May 18 07:47 netbeans-6.5.1
-rw-r--r-- 1 1000 1000 11 May 19 19:17
<...>
226 Directory send OK.
ftp> get output
local: output remote: output
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for output (11 bytes).
226 File send OK.
11 bytes received in 0.01 secs (1.3 kB/s)
ftp>
------------------------------------------------------------------------------------------------------------

The file is saved to the folder from where u executed the FTP command!

Testing from external network is more essential!

Testing from External Network


Testing from external network shall require a external computer, maybe some friend who's willing to help you out. The procedure is pretty simple...

Get the external IP of your Router/Modem from http://www.knowmyip.com/
Tell ur friend to log into the system by,
$ftp

Rest checks are same as for an internal network!

Here are some snippets of my friend accessing my system from outside the network :)



Note that here while pasting file it gave 550 error! That is because my FTP server was set up so, please make sure your FTP settings are cool enough!




Saurav using FireFtp to do FTP transactions

No comments:

Post a Comment