Wednesday, May 21, 2014

How to configure an FTP server in Packet Tracer




The File Transfer Protocol (FTP) is a standard network protocol used for the transfer of computer files between a client and server on a computer network.

 FTP employs a client-server architecture whereby the client machine has an FTP client installed and establishes a connection to an FTP server running on a remote machine. After the connection has been established and the user is successfully authenticated, the data transfer phase can begin.

Let’s now do FTP configuration in Packet Tracer:

1.Build the network topology.

FTP topology.PNG

2. Configure static IP addresses on the Laptop and the server.

LaptopIP address: 192.168.1.1  Subnet Mask: 255.255.255.0

ServerIP address: 192.168.1.2  Subnet Mask: 255.255.255.0

3. Now try using an FTP client built in the Laptop to send files to an FTP server configured in the Server.

From the Laptop’s command prompt, FTP the server using the server IP address by typing:

 ftp  192.168.1.2 

Provide the username(cisco) and password(cisco) [which are the defaults] for ftp login.

ftp from laptop.PNG

You are now in the FTP prompt .

PC0 has an FTP client which can be used to read, write, delete and rename files present in the FTP server.

The FTP server can be used to read and write configuration files as well as IOS images. Additionally, the FTP server also supports file operations such renamedelete and listing directory.

With that in mind, we can do something extra. So let’s do this:

4Create a file in the Laptop then upload it to the server using FTP.

To do this, open the Text Editor in the Laptop, create a file and give it your name of choice.

Type any text in the editor then save your file. e.g. myFile.txt.

5. Now upload the file from the Laptop to the server using  FTP. (An FTP connection has to be started first. But this is what we’ve done in step 3)

So to do an FTP upload, we’ll type:

 put MyFile.txt 

put MyFile to FTP directory.PNG

6. Once file upload is successful, go to the Server FTP directory to verify if the file sent has been received .  To do this, go to Server-> Services->FTP. Here look for MyFile.txt sent from the laptop.

MyFile.txt really send to sever.PNG

Something extra: To check other FTP commands supported by the FTP client running on the Laptop(or PC), you can  use a question mark (?) on the Laptop’s command prompt  as shown below:

All FTP commands supported

You can see the put command that we used to upload our file to the FTP server. Other commands listed include:

get-used to get(download) a file from the server.

For example: get MyFile.txt

delete– to delete a file in the FTP directory with the server

For example: delete MyFile.txt

Rename– used to Rename a file

cd – used to change directory.

For example, we can open an HTTP directory in the server by typing: cd /http. This will change the current directory from FTP directory to HTTP directory

Once the http directory is open, you can upload a file to the HTTP server. You’re now uploading a file to an HTTP folder(directory) using FTP.

For example: put MyFile.txt

To see this working, let’s  open an HTTP directory and upload(put) a file to it using FTP:

changing directory then put files to HTTP directory using FTP

You can now check up in the HTTP directory in the server and verify that the file uploaded from the Laptop(MyFile.txt) is well received:

MyFile.txt really send to HTTP server

Notice that we are uploading files to an HTTP Server directory using File Transfer Protocol.(FTP). This is what actually happens when you use an FTP client such as FileZilla client to upload files to a website. In our case here, we are using an FTP client built-in the Laptop.

This may interest you: The first FTP client applications were command-line programs developed before operating systems had graphical user interfaces, and are still shipped with most Windows and Linux operating systems. (Actually this is what we have been using this far). Many FTP clients(e.g. FileZilla) and automation utilities have since been developed for desktops, servers, mobile devices, and hardware. FTP has also been incorporated into productivity applications, such as HTML editors. 

Well done for reading this topic up to this point! You now have more than a foundation regarding working with FTP to upload, download, delete, rename…files.

If you’re okay so far, then let’s do something even more interesting…

We’ll create an html file in our Laptop, upload it to  HTTP server directory using FTP, then try to access the file from the Laptop’s browser.

So psych up and let’s move on!

On the Laptop, open the text editor, then type some markup(html) and save the file with the extension .html.  See all this below:

File2 HTML code

Save your file as an html file like this:

File2 html.PNG

Now  upload the file( File2.html) to the HTTP server using FTP. This is easy. We’ve already done it previously!

If you’re already in the HTTP directory, you just need to type: put File2.html. If no, first ftp  the server(ftp  192.168.1.2), provide the login username(cisco) and password(cisco); change the current directory to HTTP(cd /http) , and finally upload the html file onto the HTTP directory(put File2.html)

Sending File2. html to HTTP directory.PNG

Moving on…

Check whether the html file uploaded has been received in the HTTP directory:

Go to Server->Services-> HTTPThen look up for the file in the File Manager.

File2 HTML really uploaded into HTTP directory.PNG

Now edit index.html file in the HTTP directory so as to include a link to File2 that we’ve just uploaded. This will make File2 accessible from the Laptop’s browser. To do this, locate  index.html then click edit. Proceed to edit it as shown below. Then save and accept overwrite.Index.html editing to include File2 html.PNG

Finally, try to access the newly uploaded file from the Laptop’s browser.

So go to the Laptop’s browser and access the server using the server’s IP address. By doing this, the browser is making an http request to the server. The server will respond to the Laptop with the index.html file containing a link to File2  which we’ve uploaded from the Laptop using FTP.

Http response with File2.PNG

Click File2 link to view the contents of the file in the browser.

What a long post!!!.  Anyway, cheers!