Untitled Document

Chapter - 18 Networking Tools

In today's era the concept of standalone machines are gone , when there are too many users and machines they also need to talk to one another . UNIX / Linux has played a predominent role in the development of TCP/IP as a communication technology .The net is running on TCP/IP since 1983 . In this chapter we will see some tools used in TCP/IP network .


Basics about TCP / IP - 

You should know some networking jargon to understand TCP/IP . In a network a computer is known as a host , sometimes a node. Every host has a hostname which is unique throughut the network . To know your machine's hostname , use the hostname command .

   $ hostname 

where the first word ( here linux ) actually signifies the name of the host . mangadaku.com is the name of the domain to which the host belongs , we will see the domain later . Some systems omit the domain name from the output of the hostname command . When two or more TCP / IP networks are connected together , we have an internet .

IP Address -

Apart from hostname , every host in the network has an address called the IP address which is used by other machines to communicate it with . This address is a series of four dot-delimited numbers ( called octect ), which could typically look like this :

The maximum value of each octect is 255 . The IP address of a host is also independent of the networking hardware and is set at the time of booting by the system's startup scripts .TCP / IP applications can address a host by ots hostname as well as IP address :

   telnet linux

The network administrator sets the IP Address of a host to make it unique not only within the network , but also in all connected networks and if the network is connected to the Internet , it must be unique throughout the world.

ping:Checking The Network -

To operate in a network , a host must be equipped with a network interface card ( NIC ) that is the configured and assigned an IP address . You can then use ping to send packets to a machine known to be working in the network . The command send 56 bytes packets to a remote destination which answers back on receipt :

   # ping -s linux                                   solaris, Linux system doesn't need -s options 
   PING linux : 56 data bytes 
   64 bytes from linux.pdsit.becs.ac.in   ( ):  icmp_seq=0.  time=0. ms
   64 bytes from linux.pdsit.becs.ac.in   ( ):  icmp_seq=1.  time=0. ms
   64 bytes from linux.pdsit.becs.ac.in   ( ):  icmp_seq=2.  time=0. ms
   64 bytes from linux.pdsit.becs.ac.in   ( ):  icmp_seq=3.  time=0. ms
   -----earth PING Statistics-----
   4 packets transmitted , 4 packets received ,  0% packet loss
   round-trip (ms)  min/avg/max = 0/0/0

There has been no "packet loss" only confirms the connectivity between the local and remote hosts . "Pinging" a hsot doesn't require any server process to run at the other end.

telnet : Remote Login -

The telnet command , belonging to the DARPA command set , allows you to log on to a remote machine . If you have an account on a host in a local network ( on on the Internet ) you can use telnet with the hostnmae or IP address as argument :

   $ telenet
   Trying ...
   connected to
   Escape character is '^]'.
   Redhat Linux 5.0
   login : 

Enter your login id and passowrd to gain access to this machine .As long as you are logged in , anything you type is sent to the remote machine and your machine just acts as a dumb terminal . Any files you use or command that you run will always be on the remote machine . After you have finished , you can press [ctrl-d] or type exit to log out and return to your local shell .

The escape character lets you make a temporary escape to the telnet> prompt so you can execute a commandon your local machine . To invoke it , press [ ctrl-]] ( [ctrl and the ] ) . You can then use th ! with a UNIX command , say ls to list files on the local machine :

   $ [ctrl-]]
   telnet> !ls -l *.sam

A TELNET session is closed in the same way as any login session . Use [ ctrl -d ] or the command appropriate to the shell . If you are at the telnet> prompt , use quit , an internal command of telnet .

The reason why this service has been disabled on many hosts is that the passowrd is transmitted in clear text to the server . Also , the entire session can be intercepted and altered . Modern setups sue SSH for remote login .

ftp : File Transfer Protocol

DARPA's ftp coomand is used to transfer files between hosts .It offers a number of UNIX - like directory - oriented services and many of its commands have similar names . Like telnet , ftp can also be invoked with or without the address . This time , we wiil use the hostname :

   $ ftp linux 
   Connected to linux .
   220 linux FTP server ( Version ) ready .
   Name ( linux : mangesh ) : charlie                henry logs in as charlie 
   331 Password required for charlie .
   Password: ***********
   230 User charlie logged in .
   Remote system type is UNIX.
   Using binary mode to transfer files .
   ftp> _                                           The ftp prompt .

After establishing a connection with linux , ftp prompts for the username and passowrd . The local username is prompted as default ( mangesh ), and if you had pressed [ Enter ] , the system would have logged you in as mangesh . To quit ftp , break the connection with close and then enter bye or quit .

   ftp> close       You can skip this if you want 
   221  Goodbye.
   ftp. bye         You can use quit also 
   $ _

Basic File and Directory Handling

ftp has all of the basics facilities of file handling and directory commands on remote machines like - pwd , ls ,cd, mkdir and chmod . We can delete a single file ( delete ), multiple files (mdelete) or rename a file ( rename ). However, remember that all these commands apply only to the remote machine and not to the local machine .

If you have to use the operating system commands on local machine , use the ! in the usual manner . Since the ! down't work with the cd command , ftp offers the lcd ( local cd ) command to do the job . The following session tells most of the story :

   ftp> verbose        Turns off some ftp messages 
   Verbose mode off .
   ftp> pwd 
   257 "/homes/sales" is current directory .
   ftp> ls
   -rw-r--r--   1  sales     group        1498  Jul  25  18:34  exrc
   -rw-r--r--   1  sales     group          20  Jul  25  18:37  login.sql
   -rwxr-xr-x   1  sales     group      289312  Jul  25  18:22  perl 
   -rw-r--r--   1  sales     group     1457664  Jul  25  18:43  vb4cab.2
   ftp> mkdir reports 
   ftp> cd reports
   ftp> pwd 
   257 "home/sales/reports" is current directory .

   ftp> !pwd                                        This is on the local machine 
   ftp> delete exerc
   ftp> mdelete login.sql perl vb4*                 * is interpreted on remote macine 
   mdelete login.sql? y
   mdelete perl? y
   mdelete vb4cab.2? y 

Transfering Files -

The files are seen as two types - ascii ( text ) and binary . All executables ,graphics, word processing and multimedia files belong to the binary type . These file need special attention , so you should set the transfer mode to binary before intiating file transfer .

Uploading ( put an mput ) - If you are a web-developer , you will frequently need to upload your web pages and graphic files to your web site . The put command sends ( uploads ) a single file . logo.gif to the remote machine :

   ftp> binary
   200 Type set to I .
   ftp> put logo.gif         Copied Under same name 
   local:logo.gif remote: logo.gif 
   200 PORT command successful.
   150 Opening BINARY mode data connection for logo.gif .
   226 Transfer Complete .
   6152 bytes sent in 0.04 seconds ( 150.20 Kbytes/s )
 You can change your destination filename, and you can also copy multiple files with mput:
   put logo.gif old_logo.gif
   mput t*.sql                         * interpreted on local machine 

By default , mput behaves interactively and seeks confirmation for every file that has to be transferred . To make mput behaves noninteractively , run the prompt command before using mput .You will see the message Interactive mode off . prompt is toggle switch , the next invocation revese the previous mode .

Downloading ( get and mget ) - To download files from the remote machine , use the get and mget commands in a similar manner as their "put" counterparts . This time we will turn off all messages with verbose .

   ftp> verbose                    Turn off noise 
   ftp ls 
   drwxr-xr-x     14   888      999           4096  Jun  15  16:46   communicator 
   drwxr-xr-x      2   888      999             26  May  14  00:47   communicator_for_france
   -rw-r--r--      1   888      999         323393  Sep   7  17:22   ls -lR
   -rw-r--r--      1   888      999          28360  Sep   7  17:22   ls -lR.gz
   ftp> binary         Default on most systems 
   ftp> get ls -lR.gz
   ftp> _              No Statistics this time - file copied 

Like with put you can change your destination filename , and you can also copy multiple files with mget

   get ls -lR.gz netscape_filelist 
   mget t*.sql                                  * interpreted on remote machine 

The prompt setting that works with mput also works with mget in the same way .

Untitled Document Scroll To Top Untitled Document