34-FTP and TFTP Operation

Download


Chapter 1  FTP and TFTP Configuration

1.1  FTP Configuration

1.1.1  Introduction to FTP

FTP (file transfer protocol) is commonly used in IP-based networks to transmit files. Before World Wide Web comes into being, files are transferred through command lines, and the most popular application is FTP. At present, although E-mail and Web are the usual methods for file transmission, FTP still has its strongholds.

As an application layer protocol, FTP is used for file transfer between remote server and local host. FTP uses TCP port 20 and 21. Port 20 is used for control information, and port 21 is used for data. Basic FTP operations are described in RFC 959.

FTP-based file transmission is performed in the following two modes:

l           Binary mode, which is used for program file transfer.

l           ASCII mode, which is used for text file transfer.

An Ethernet switch can act as an FTP client or an FTP server in an FTP implementation.

l           FTP server

An Ethernet switch can operate as an FTP server to provide file transmission services for FTP clients. You can log into a switch operating as an FTP server by running an FTP client program on your PC to access the files on the FTP server. To accept login requests, an FTP server must be assigned an IP address.

Table 1-1 describes the configurations needed when a switch operates as an FTP server.

Table 1-1 Configurations needed when a switch operates as an FTP server

Device

Configuration

Default

Description

Switch

Enable the FTP server function

The FTP server function is disabled by default

You can run the display ftp-server command to view the FTP server configuration on the switch.

Perform authentication-/authorization-related configuration

Configure user names, passwords, and the work directory.

Configure the connection idle time

The default idle time is 30 minutes.

PC

Log into a switch operating as an FTP server through an FTP client application.

 

  Caution:

The FTP-related functions require that the route between a FTP client and the FTP server is reachable.

 

l           FTP client

A switch can operate as an FTP client, through which you can access files on FTP servers. In this case, you need to establish a connection between your PC and the switch through a terminal emulation program or Telnet and then execute the ftp X.X.X.X command on your PC (X.X.X.X is the IP address of an FTP server).

Table 1-2 describes the configurations needed when a switch operates as an FTP client.

Table 1-2 Configurations needed when a switch operates as an FTP client

Device

Configuration

Default

Description

Switch

Run the ftp command to log into a remote FTP server directly

To log into a remote FTP server and manipulate files and directories on it, you need to obtain a user name and password first.

FTP server

User names, passwords, and the corresponding permissions are configured.

 

1.1.2  FTP Configuration: A Switch Operating as an FTP Server

I. Prerequisites

A switch operates as an FTP server. A remote PC operates as an FTP client. The network operates properly, as shown in Figure 1-1.

Figure 1-1 Network diagram for FTP configuration

II. Configuration procedure

Table 1-3 Configure an FTP server

Operation

Command

Description

Enter system view

system-view

Enable the FTP server function

ftp server enable

Required

By default, the FTP server function is disabled.

Set the connection idle time

ftp timeout minutes

Optional

The default connection idle time is 30 minutes.

 

&  Note:

l      Only one user can access an S7500 switch at a given time when the latter operates as an FTP server.

l      FTP services are implemented in this way: An FTP client sends FTP requests to the FTP server. The FTP server receives the requests, perform operations accordingly, and return the results to the FTP client.

l      To prevent unauthorized accesses, an FTP server disconnects a FTP connection when it does not receive requests from the FTP client for a specific period of time known as the connection idle time.

l      An S7500 operating as an FTP server cannot receive a file whose size exceeds its storage space. A client attempting to upload such a file will be disconnected from the FTP server due to lack of storage space on the FTP server.

 

III. Authentication and authorization configuration

An FTP server authenticates an FTP client by the user name and the password it provides. When an FTP client passes the authentication, the authorization is done by allocating the FTP client a work directory. An FTP server provides services to the FTP clients that are both authenticated and authorized.

The configurations such as configuring user name, password, the way to display passwords, service type are performed on FTP servers. Refer to the information about the local-user, local-user password-display-mode, password, and service-type commands in the AAA&RADIUS&HWTACACS&EAD part of this manual for more.

IV. Displaying FTP server configuration

After the above configurations, you can run the display command in any view to display the information about the FTP server and verify your configurations.

Table 1-4 Display FTP server information

Operation

Command

Description

Display the information about FTP server configurations on a switch

display ftp-server

These commands can be executed in any view.

Display the currently online FTP client

display ftp-user

 

1.1.3  Configuration Example: A Switch Operating as an FTP Server

I. Network requirements

A switch operates as an FTP server and a remote PC as an FTP client.

l           Create a user account on the FTP server with the user name “switch” and password “hello”. The work directory assigned for FTP clients is the root directory of the flash.

l           Configure the IP address 1.1.1.1 for a VLAN interface on the switch, and 2.2.2.2 for the PC. Ensure the route between the two is reachable.

The switch application named switch.bin is stored on the PC. Upload it to the FTP server through FTP to upgrade the application of the switch, and download the switch configuration file named config.cfg from the switch to backup the configuration file.

II. Network diagram

Figure 1-2 Network diagram for FTP configurations

III. Configuration procedure

1)         Configure the switch

# Log into the switch. (You can log into a switch through the Console port or by Telneting to the switch. See the Login part of this manual for detailed information.)

<H3C>

# Start the FTP service on the switch and create a user account and the corresponding password.

<H3C> system-view

[H3C] ftp server enable

[H3C] local-user switch

[H3C-luser-switch] password simple hello

[H3C-luser-switch] service-type ftp ftp-directory flash:/

2)         Run an FTP client application on the PC to connect to the FTP server. Upload the application named switch.bin to the root directory of the Flash memory of the FTP server, and download the configuration file named config.cfg from the FTP server. The following takes the command line window tool provided by Windows as an example.

# Enter the command line window and switch to the directory where the file switch.bin is located. Assume that the file resides in C:\.

C:\>

# Access the Ethernet switch through FTP. Input the user name “switch” and password “hello” to log in and enter FTP view.

C:\> ftp 1.1.1.1

Connected to 1.1.1.1.

220 FTP service ready.

User (1.1.1.1:(none)): switch

331 Password required for switch.

Password:

230 User logged in.

ftp>

# Upload the switch.bin file.

ftp> put switch.bin

200 Port command okay.

150 Opening ASCII mode data connection for switch.bin.

226 Transfer complete.

# Download the config.cfg file.

ftp> get config.cfg

200 Port command okay.

150 Opening ASCII mode data connection for config.cfg.

226 Transfer complete.

ftp: 3980 bytes received in 8.277 seconds 0.48Kbytes/sec.

This example uses the command line window tool provided by Windows. When you log into the FTP server through another FTP client, refer to the corresponding instructions for operation description.

 

  Caution:

l      If the available space of the flash of the switch is not enough to hold the file to be uploaded, you need to move the files that are not in use from the flash to other place to make room for the file.

l      H3C series switch is not shipped with FTP client applications. You need to purchase and install it by yourself.

 

3)         After uploading the application, you can update the application on the switch.

# Use the boot boot-loader command to specify the uploaded file (switch.bin) to be the startup file used when the switch starts the next time, and restart the switch. Thus the switch application is upgraded.

<H3C> boot boot-loader switch.bin

<H3C> reboot

 

&  Note:

For information about the boot boot-loader command and how to specify the startup file for a switch, refer to the System Maintenance and Debugging part of this manual.

 

1.1.4  FTP Configuration: A Switch Operating as an FTP Client

I. Basic FTP client configuration

The function for a switch to operate as an FTP client is implemented by an application module built in the switch. Thus a switch can operate as an FTP client without any configuration. You can perform FTP-related operations (such as creating/removing a directory) by executing FTP client commands on a switch operating as an FTP client. Table 1-5 lists the operations that can be performed on an FTP client.

Table 1-5 Basic FTP client configuration

Operation

Command

Description

Enter FTP client view

ftp [ cluster | remote-server [ port-number ] ]

Specify to transfer files in the ASCII mode

ascii

Optional

By default, files are transferred in ASCII characters.

Specify to transfer files in the binary mode

binary

Optional

Specify to transfer files in the passive mode

passive

Optional

By default, the passive mode is adopted.

Change the work directory on the remote FTP server

cd pathname

Optional

Change the work directory to the parent directory

cdup

Optional

Get the local work directory on the FTP client

lcd

Optional

Display the directories on the FTP server

pwd

Optional

Create a directory on the remote FTP server

mkdir pathname

Optional

Remove a directory on the remote FTP server

rmdir pathname

Optional

Delete a specified file

delete remotefile

Optional

Query a specified file

dir [ filename ] [ localfile ]

Optional

Query a specified remote file

ls [ remotefile ] [ localfile ]

Optional

Download a remote file

get remotefile [ localfile ]

Optional

Upload a local file to the remote FTP server

put localfile [ remotefile ]

Optional

Switch to another FTP user

user username [ password ]

Optional

Establish a control connection to the FTP server

open { ip-address | server-name } [ port ]

Optional

Terminate the current FTP connection without exiting FTP client view

disconnect

Optional

Terminate the current FTP connection without exiting FTP client view

close

Optional

Terminate the current FTP connection and quit to user view

quit

Optional

Terminate the current FTP connection and quit to user view

bye

Optional

Display the on-line help on a specified command concerning FTP

remotehelp [ protocol-command ]

Optional

Enable debugging for FTP

debugging

Optional

Enable the verbose function

verbose

Optional

The verbose function is enabled by default.

 

1.1.5  Configuration Example: A Switch Operating as an FTP Client

I. Network requirements

A switch operates as an FTP client and a remote PC as an FTP server.

l           Create a user account on the FTP server with the user name “switch” and password “hello”, and authorize the user “switch” with read and write permissions on the directory named “switch” on the PC.

l           Configure the IP address 1.1.1.1 for a VLAN interface on the switch, and 2.2.2.2 for the PC. Ensure the route between the two is reachable.

The switch application named switch.bin is stored on the PC. Download it to the switch through FTP to upgrade the switch application, and upload the switch configuration file named config.cfg to the PC to backup the configuration file.

II. Network diagram

Figure 1-3 Network diagram for FTP configuration

III. Configuration procedure

1)         Perform FTP server–related configurations on the PC, that is, create a user account on the FTP server with user name “switch” and password “hello”. (For detailed configuration, refer to the configuration instruction relevant to the FTP server software.)

2)         Configure the switch.

# Log into the switch. (You can log into a switch through the Console port or by Telneting to the switch. See the Login part of this manual for detailed information.)

<H3C>

 

  Caution:

If the available space of the flash of the switch is not enough to hold the file to be uploaded, you need to move the files that are not in use from the flash to other place to make room for the file.

 

# Connect to the FTP server using the ftp command. You need to provide the IP address of the FTP server, the user name and the password as well.

<H3C> ftp 2.2.2.2

Trying ...                                                                     

Press CTRL+K to abort                                                          

Connected.                                                                      

220 WFTPD 2.0 service (by Texas Imperial Software) ready for new user          

User(none):switch                                                             

331 Give me your password, please                                              

Password:                                                             

230 Logged in successfully      

[ftp]

# Run the put command to upload the configuration file named config.cfg to the FTP server.

[ftp] put config.cfg

# Run the get command to download the file named switch.bin to the flash of the switch.

[ftp] get switch.bin

# Run the quit command to terminate the FTP connection and quit to user view.

[ftp] quit

<H3C>

# Run the boot boot-loader command to specify the downloaded file (switch.bin) to be the startup file used when the switch starts the next time, and then restart the switch. Thus the switch application is upgraded.

<H3C> boot boot-loader switch.bin

<H3C> reboot

 

&  Note:

For information about the boot boot-loader command and how to specify the startup file for a switch, refer to the System Maintenance and Debugging part of this manual.

 

1.2  TFTP Configuration

1.2.1  Introduction to TFTP

Compared with FTP, TFTP (trivial file transfer protocol) features simple interactive access interface and no authentication control. It simplifies the interaction between servers and clients remarkably. TFTP is implemented on UDP. It transfers data through UDP port 69. Basic TFTP operations are described in RFC1986.

TFTP transmission is initiated by clients, as described in the following:

l           To download a file, a client sends read request packets to the TFTP server, receives data from the TFTP server, and then sends acknowledgement packets to the TFTP server.

l           To upload a file, a client sends writing request packets to the TFTP server, sends data to the TFTP server, and then receives acknowledgement packets from the TFTP server.

 

&  Note:

l      Before performing TFTP-related configurations, you need to configure IP addresses for the TFPT client and the TFTP server, and make sure the route between the two is reachable.

l      A switch can only operate as a TFTP client.

 

Figure 1-4 Network diagram for TFTP configuration

Table 1-6 describes the operations needed when a switch operates as a TFTP client.

Table 1-6 Configurations needed when a switch operates as a TFTP client

Device

Configuration

Default

Description

Switch

Configure an IP address for the VLAN interface of the switch so that it is reachable for TFTP server.

TFTP applies to networks where client-server interactions are comparatively simple. It requires the routes between TFTP clients TFTP servers are reachable.

You can log into a TFTP server directly for file accessing through TFTP commands.

TFTP server

The TFTP server is started and the TFTP work directory is configured.

 

1.2.2  TFTP Configuration

I. Prerequisites

A switch operates as a TFTP client and a remote PC as the TFTP server. The network operates properly, as shown in Figure 1-4.

II. Basic TFTP configurations

Table 1-7 Basic TFTP configurations

Operation

Command

Description

Download a file through TFTP

tftp { cluster | tftp-server } get source-file [ dest-file ]

Optional

Upload a file through TFTP

tftp { cluster | tftp-server } put source-file [ dest-file ]

Optional

Enter system view

system-view

Specify the ACL adopted when a switch attempts to connect a TFTP server

tftp-server acl acl-number

Optional

 

1.2.3  TFTP Configuration Example

I. Network requirements

A switch operates as a TFTP client and a PC as the TFTP server.

l           The TFTP work directory is configured on the TFTP server.

l           The IP address of a VLAN interface on the switch is 1.1.1.1. The port through which the switch connects with the PC belongs to the VLAN. The IP address of the PC is 1.1.1.2.

The application named switch.bin is stored on the PC. Download it to the switch through TFTP, and upload the configuration file named config.cfg to the work directory on the PC to backup the configuration file.

II. Network diagram

Figure 1-5 Network diagram for TFTP configuration

III. Configuration procedure

1)         Start the TFTP server and configure the work directory on the PC.

2)         Configure the switch.

# Log into the switch. (You can log into a switch through the Console port or by Telneting to the switch. See the Login part of this manual for detailed information.)

<H3C>

 

  Caution:

If the available space of the flash of the switch is not enough to hold the file to be uploaded, you need to move the files that are not in use from the flash to other place to make room for the file.

 

# Download the switch application named switch.bin from the TFTP server to the switch.

<H3C> tftp 1.1.1.2 get switch.bin switch.bin

# Upload the switch configuration file named config.cfg to the TFTP server.

<H3C> tftp 1.1.1.2 put config.cfg config.cfg

# Use the boot boot-loader command to specify the downloaded file (switch.bin) to be the startup file used when the switch starts the next time, and restart the switch. Thus the switch application is upgraded.

<H3C> boot boot-loader switch.bin

<H3C> reboot

 

&  Note:

For information about the boot boot-loader command and how to specify the startup file for a switch, refer to the System Maintenance and Debugging part module of this manual.