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 ports
20 and 21 for data transfer and control command transfer respectively. Basic
FTP operations are described in RFC 959.
FTP-based file transmission is performed in
the following two modes:
l
Binary mode for program file transfer.
l
ASCII mode for text file transfer.
An Ethernet switch can act as an FTP client
or the FTP server in FTP-employed data transmission:
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 files on the FTP server. Before you log into the FTP server, the
administrator must configure an IP address for it.
Table 1-1describes 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.
|
|
Configure the authentication information
on the FTP server
|
—
|
Configure user names and passwords.
|
|
Configure the connection idle time
|
The default idle time is 30 minutes.
|
—
|
|
PC
|
Log into the switch 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
operates files and directories on it, you need to obtain a user name and
password first.
|
|
FTP server
|
Enable the FTP server and configure the
corresponding information including user names, passwords, and user authorities
|
—
|
—
|
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 configurations
Following configurations are performed on
the FTP server:
l
Creating local users
l
Setting local user passwords
l
Setting the password display mode for the local
user
l
Configuring service types for the local users
(For the information about these
configurations, refer to these commands in “AAA-RADIUS-HWTACACS”
module: local-user, local-user password-display-mode, password,
and service-type.)
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
minute
|
Optional
The default connection idle time is 30
minutes.
|
l
Only one user can access an S3100-SI 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.
To log into an FTP server, a user needs to
provide a user name and a password for being authenticated, and the FTP server
authorizes the FTP client by providing the information about work directory. FTP
services are available to users only when they pass the authentication and
authorization.
After the above
configurations, you can run the display command in any view to view the
running information of the FTP server and verify your configurations.
Table 1-4 Display and debug an FTP server
|
Operation
|
Command
|
Description
|
|
Display the information about an FTP
server
|
display ftp-server
|
These commands can be executed in any
view.
|
|
Display the information about FTP clients
|
display ftp-user
|
I. Network requirements
A switch and a PC operate as an FTP server
and an FTP client.
l
Create a user account on the FTP server, with
the user name being switch, password being hello, and the permission to access
the root directory of the Flash assigned to the user account.
l
The IP address of a VLAN interface on the switch
is 1.1.1.1. The IP address of the PC is 2.2.2.2. And the route between the two
is reachable.
The PC uploads the application named switch.bin
to the FTP server through FTP and downloads the 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 Chapter “Log
into an Ethernet Switch” for detailed information.)
<H3C>
# Start the FTP service on the switch and create
a user account.
<H3C> system-view
System View: return to User View with
Ctrl+Z.
[H3C] ftp server enable
[H3C] local-user switch
[H3C-luser-switch] password simple
hello
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 and download the configuration file named config.cfg
from the FTP server.
# Enter the command line window and switch
to the directory where the file switch.bin is located. In this example it is in
the root directory of 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.
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 available space on the Flash memory of the
switch is not enough to hold the file to be uploaded, you need to delete files
from the Flash memory 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
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”
module of this manual.
1.1.4 FTP Configuration: A Switch Operating as an FTP Client
The function for a switch to operate as an
FTP client is implemented by an application module built in the switch. 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 FTP client operations
|
Operation
|
Command
|
Description
|
|
Enter FTP
Client view
|
ftp [ remote-server [ port-number ] ]
|
—
|
|
Specify to transfer files in ASCII
characters
|
ascii
|
Optional
By default, files are transferred in
ASCII characters.
|
|
Specify to transfer files in binary
streams
|
binary
|
Optional
|
|
Set the data transfer mode to passive
|
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 be the
parent directory
|
cdup
|
Optional
|
|
Get the local work path on the FTP client
|
lcd
|
Optional
|
|
Display the work directory 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 the specified files
|
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
|
|
Rename a file on a remote host.
|
rename remote-source
remote-dest
|
Optional
|
|
Switch to another FTP user
|
user username
[ password ]
|
Optional
|
|
Connect to a remote FTP server
|
open remote-server
[ port-number ]
|
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 control
connection and data connection
|
bye
|
Optional
|
|
Display the on-line help on a specified command
concerning FTP
|
remotehelp
[ protocol-command ]
|
Optional
|
|
Enable verbose function
|
verbose
|
Optional
The verbose function is enabled by
default.
|
I. Network requirements
A switch and a remote PC operate as an FTP
client and an FTP server.
l
Create a user account on the FTP server, with
the user name being switch, password being hello, and the permission to access
the directory named Switch assigned to the user account.
l
The IP address of a VLAN interface on the switch
is 1.1.1.1. The IP address of the PC is 2.2.2.2. And the route between the two
is reachable.
Download the application named switch.bin from
the PC to the switch and upload the configuration file named config.cfg to the directory
named Switch on the PC to backup the configuration file.
II. Network diagram

Figure 1-3
Network diagram for FTP configurations
III. Configuration procedure
1)
Perform FTP server-related configurations on the
PC, that is, create a user account on the FTP server, with the user name being switch,
password being hello, and the permission to access the directory named Switch
assigned to the user account. (These operations are omitted here.)
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 Chapter 2 “Log
into an Ethernet Switch” for detailed information.)
<H3C>
Caution:
If the free space
of the Flash of the switch is insufficient to hold the file to be downloaded,
you need to delete useless files in the flash 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]
# Enter the authorized directory on the FTP
server.
[ftp] cd switch
# Upload the configuration file named config.cfg
to the FTP server.
[ftp] put config.cfg
# Download the file named switch.bin.
[ftp] get switch.bin
# Terminate the FTP connection and quit to
user view.
[ftp] quit
<H3C>
# Specify the downloaded file (the file
named 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
1.2 TFTP Configuration
Compared with FTP, TFTP (trivial file transfer
protocol) features simple interactive access interface and authentication
control. It simplifies the interaction between servers and clients remarkably.
TFTP is usually implemented based on UDP.
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.
When you download a file that is larger
than the free space of the switch’s flash memory:
l
If the TFTP server supports file size
negotiation, file size negotiation will be initiated between the switch and the
server and the file download operation will be aborted if the free space of the
switch’s flash memory is found to be insufficient.
l
If the TFTP server does not support file size
negotiation, the switch will receive data from the server until the flash
memory is full. If there is more data to be downloaded, the switch will prompt
that the space is insufficient and delete the data partially downloaded. File
download fails.
TFTP-based file transmission can be
performed in the following modes:
l
Binary mode, where executable files are
transmitted.
l
ASCII mode, where text files are transmitted.
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 an 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. (The IP address of a VLAN interface on the switch
needs to be in the same network segment as that which the IP address of the
TFTP server belongs to.)
|
—
|
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.
|
—
|
—
|
|
PC
|
The TFTP
server is started and the TFTP work directory is configured.
|
—
|
—
|
I. Prerequisites
A switch operates as a TFTP client. A PC operates
as the TFTP server. The network operates properly, as shown in Figure 1-4.
II. Configuration procedure
Table 1-7 Configure TFTP
|
Operation
|
Command
|
Description
|
|
Set the TFTP file transmission mode
|
tftp { ascii
| binary }
|
Optional
By default, the binary file
transmission mode is adopted.
|
|
Download a file
|
tftp tftp-server get source-file [ dest-file ]
|
Optional
|
|
Upload a file
|
tftp 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
|
I. Network requirements
A switch and a PC operate as a TFTP client
and 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.
Download the application named switch.bin from
the PC to the switch and upload the configuration file named config.cfg to the directory
named Switch 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 Chapter 2 “Log
into an Ethernet Switch” for detailed information.)
<H3C>
Caution:
If the free space
of the Flash of the switch is insufficient to hold the file to be downloaded,
you need to delete useless files in the flash to make room for the file.
# Enter system view
<H3C> system-view
System View: return to User View with
Ctrl+Z.
[H3C]
# Configure the IP address of a VLAN
interface on the switch to be 1.1.1.1, and ensure that the port through which
the switch connects with the PC belongs to this VLAN. (This example assumes
that the port belongs to VLAN 1.)
[H3C] interface Vlan-interface 1
[H3C-Vlan-interface1] ip address
1.1.1.1 255.255.255.0
[H3C-Vlan-interface1] quit
[H3C] quit
# Download the application named switch.bin
from the TFTP server to the switch.
<H3C> tftp 1.1.1.2 get switch.bin
switch.bin
# Upload the configuration file named config.cfg
to the TFTP server.
<H3C> tftp 1.1.1.2 put config.cfg
config.cfg
# Specify the downloaded file (the file
named 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