- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
03-FTP and TFTP Configuration | 195.66 KB |
Contents
Establishing an FTP connection
Managing directories on the FTP server
Operating the files on the FTP server
Using another username to log in to the FTP server
Maintaining and debugging the FTP connection
FTP client configuration example
Configuring FTP server operating parameters
Configuring authentication and authorization on the FTP server
FTP server configuration example
Displaying and maintaining FTP·
Displaying and maintaining the TFTP client
TFTP client configuration example
This chapter includes these sections:
· Displaying and maintaining FTP
|
NOTE: · The term "switch" or "device" in this chapter refers to the switching engine on a WX3000E wireless switch. · The WX3000E series comprises WX3024E and WX3010E wireless switches. · The port numbers in this chapter are for illustration only. |
FTP overview
Introduction to FTP
The File Transfer Protocol (FTP) is an application layer protocol used to share files between server and client over a TCP/IP network.
FTP uses TCP ports 20 and 21. Port 20 is used to transmit data, and port 21 is used to transmit control commands. For more information about basic FTP operations, see RFC 959.
FTP transfers files in the following modes:
· Binary mode: Transfers files as raw data, like .app, .bin, and .btm files.
· ASCII mode: Transfers files as text, like .txt, .bat, and .cfg files.
Operation of FTP
FTP adopts the client/server model. Your device can function either as the client or the server, as shown in Figure 1.
· When the device serves as the FTP client, a user can Telnet to it from a PC, and execute the ftp command to establish a connection to the remote FTP server on the PC to upload/download files to/from the PC.
· When the device serves as the FTP server, a user can FTP to the device from a PC that runs the FTP client and upload/download files to/from the device.
Figure 1 Network diagram for FTP
When the device serves as the FTP client, you need to perform the following configuration:
Table 1 Configuration when the device serves as the FTP client
Device |
Configuration |
Remarks |
Device (FTP client) |
Use the ftp command to establish the connection to the remote FTP server |
If the remote FTP server supports anonymous FTP, the device can log in to it directly; if not, the device must obtain the FTP username and password first to log in to the remote FTP server. |
PC (FTP server) |
Enable FTP server on the PC, and configure the username, password, user privilege level, and so on. |
— |
When the device serves as the FTP server, you need to perform the following configuration:
Table 2 Configuration when the device serves as the FTP server
Device |
Configuration |
Remarks |
Device (FTP server) |
Enable the FTP server function |
Disabled by default. You can use the display ftp-server command to view the FTP server configuration on the device. |
Configure authentication and authorization |
Configure the username, password, and authorized directory for an FTP user. The device does not support anonymous FTP for security reasons. You must set a valid username and password. By default, authenticated users can access the root directory of the device. |
|
Configure the FTP server operating parameters |
Parameters such as the FTP connection timeout time |
|
PC (FTP client) |
Use the FTP client program to log in to the FTP server. |
You can log in to the FTP server only after you input the correct FTP username and password. |
|
CAUTION: · Make sure that the FTP server and the FTP client can reach each other before establishing the FTP connection. · When you use IE to log in to the device serving as the FTP server, some FTP functions are not available. This is because multiple connections are established during the login process but the device supports only one connection at a time. |
Configuring the FTP client
|
NOTE: Only users with the manage level can use the ftp command to log in to an FTP server, enter FTP client view, and execute directory and file related commands. However, whether the commands can be executed successfully depends on the authorizations of the FTP server. |
Establishing an FTP connection
Before you can access the FTP server, you must establish a connection from the FTP client to the FTP server. You can either use the ftp command to establish the connection directly or use the open command in FTP client view to establish the connection.
When using the ftp or ftp client source command, you can specify the source interface (such as a loopback or dialer interface) or source IP address. The primary IP address of the specified source interface or the specified source IP address is used as the source IP address of sent FTP packets.
The FTP client follows these rules to select the source IP address of packets sent to the FTP server:
· If no source IP address is specified, the IP address of the output interface of the route to the server is used as the source IP address.
· The source IP address specified with the ftp client source or ftp command is used.
· If you first use the ftp client source command to specify a source IP address and then use the ftp command to specify another source IP address, the latter is used.
· The source IP address specified with the ftp client source command applies to all FTP connections while the one specified with the ftp command applies to the current FTP connection only.
Follow these steps to establish an IPv4 FTP connection:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Specify the source IP address of sent FTP packets |
ftp client source { interface interface-type interface-number | ip source-ip-address } |
Optional By default, the source IP address is determined by the route from the FTP client to the FTP server. |
Return to user view |
quit |
— |
Log in to the remote FTP server directly in user view |
ftp [ server-address [ service-port ] [ source { interface interface-type interface-number | ip source-ip-address } ] ] |
Use either approach. The ftp command is available in user view, and the open command is available in FTP client view. |
Log in to the remote FTP server indirectly in FTP client view |
ftp |
|
open server-address [ service-port ] |
|
NOTE: · If no primary IP address is configured on the specified source interface, you cannot establish an FTP connection. · If you use the ftp client source command to configure a source interface and then use it to configure a source IP address, the source IP address overwrites the source interface, and vice versa. |
Follow these steps to establish an IPv6 FTP connection:
To do… |
Use the command… |
Remarks |
Log in to the remote FTP server directly in user view |
ftp ipv6 [ server-address [ service-port ] [ source ipv6 source-ipv6-address ] [ -i interface-type interface-number ] ] |
Use either approach. The ftp ipv6 command is available in user view; and the open ipv6 command is available in FTP client view. |
Log in to the remote FTP server indirectly in FTP client view |
ftp ipv6 |
|
open ipv6 server-address [ service-port ] [ -i interface-type interface-number ] |
Managing directories on the FTP server
After the device serving as the FTP client has established a connection with an FTP server, you can create or delete folders under the authorized directory of the FTP server. For more information about establishing an FTP connection, see “Establishing an FTP connection.”
Follow these steps to manage the directories on an FTP server:
To do… |
Use the command… |
Remarks |
Display detailed information about a directory or file on the remote FTP server |
dir [ remotefile [ localfile ] ] |
Optional |
Query a directory or file on the remote FTP server |
ls [ remotefile [ localfile ] ] |
Optional |
Change the working directory of the remote FTP server |
cd { directory | .. | / } |
Optional |
Return to the upper level directory of the remote FTP server |
cdup |
Optional |
Display the working directory that is being accessed |
pwd |
Optional |
Create a directory on the remote FTP server |
mkdir directory |
Optional |
Remove the specified working directory on the remote FTP server |
rmdir directory |
Optional |
Operating the files on the FTP server
After the device serving as the FTP client has established a connection with an FTP server, you can upload a file to or download a file from the FTP server under the authorized directory of the FTP server by following these steps. For more information about establishing an FTP connection, see “Establishing an FTP connection.”
1. Use the dir or ls command to display the directory and the location of the file on the FTP server.
2. Delete useless files for effective use of the storage space.
3. Set the file transfer mode. FTP transmits files in two modes: ASCII and binary. ASCII mode transfers files as text. Binary mode transfers files as raw data.
4. Use the lcd command to display the local working directory of the FTP client. You can upload the file or save the downloaded file under this directory.
5. Upload or download the file.
Follow these steps to operate the files on an FTP server:
To do… |
Use the command… |
Remarks |
Display detailed information about a directory or file on the remote FTP server |
dir [ remotefile [ localfile ] ] |
Optional The ls command displays the name of a directory or file only, while the dir command displays detailed information such as the file size and creation time. |
Query a directory or file on the remote FTP server |
ls [ remotefile [ localfile ] ] |
Optional The ls command displays the name of a directory or file only, while the dir command displays detailed information such as the file size and creation time. |
Delete the specified file on the remote FTP server permanently |
delete remotefile |
Optional |
Set the file transfer mode to ASCII |
ascii |
Optional ASCII by default. |
Set the file transfer mode to binary |
binary |
Optional ASCII by default. |
Set the data transmission mode to passive |
passive |
Optional Passive by default. |
Display the local working directory of the FTP client |
lcd |
Optional |
Upload a file to the FTP server |
put localfile [ remotefile ] |
Optional |
Download a file from the FTP server |
get remotefile [ localfile ] |
Optional |
Using another username to log in to the FTP server
After the device serving as the FTP client has established a connection with the FTP server, you can use another username to log in to the FTP server. For more information about establishing an FTP connection, see “Establishing an FTP connection.”
This feature allows you to switch to different user levels without affecting the current FTP connection; if you input an incorrect username or password, the current connection will be terminated, and you must log in again to access the FTP server.
Follow the step below to use another username to log in to the FTP server:
To do… |
Use the command… |
Remarks |
Use another username to re-log in after successfully logging in to the FTP server |
user username [ password ] |
Optional |
Maintaining and debugging the FTP connection
After a device serving as the FTP client has established a connection with the FTP server, you can perform the following operations to locate and diagnose FTP connection problems. For more information about establishing an FTP connection, see “Establishing an FTP connection.”
To do… |
Use the command… |
Remarks |
Display the help information of FTP-related commands supported by the remote FTP server |
remotehelp [ protocol-command ] |
Optional |
Enable information display in a detailed manner |
verbose |
Optional Enabled by default |
Enable FTP related debugging when the device acts as the FTP client |
debugging |
Optional Disabled by default |
Terminating an FTP connection
After the device serving as the FTP client has established a connection with the FTP server, you can use any of the following commands to terminate the FTP connection. For more information about establishing an FTP connection, see “Establishing an FTP connection.”
To do… |
Use the command… |
Remarks |
Terminate the connection to the FTP server without exiting FTP client view |
disconnect |
Optional Equal to the close command. |
Terminate the connection to the FTP server without exiting FTP client view |
close |
Optional Equal to the disconnect command. |
Terminate the connection to the FTP server and return to user view |
bye |
Optional Available in FTP client view, equal to the quit command. |
Terminate the connection to the FTP server and return to user view |
quit |
Optional Available in FTP client view, equal to the bye command. |
FTP client configuration example
Network requirements
As shown in Figure 2, the switch operates as an FTP client and a remote PC as an FTP server. The configuration file of the switching engine named config.cfg is stored on the PC. Download it to the switching engine through FTP and use the startup saved-configuration command to specify config.cfg as the main configuration file for next startup, and then reboot the device.
· Create a user account on the FTP server with the user name “switch” and password “hello”, and grant the user “switch” read and write permissions for the directory named “Switch” on the PC.
· Configure the IP address 1.1.1.1 for a VLAN interface on the switch, and 2.2.2.2 for the PC. Ensure a route exists between the switch and the PC.
Figure 2 Network diagram for FTP configurations: the device operating as an FTP client
Configuration procedure
1. Configure the PC (FTP server)
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 (FTP client)
# Log in to the switching engine. (You can log in to the switching engine through OAP or by telnetting the switching engine.)
|
CAUTION: If available space on the flash memory of the device is not enough to hold the file to be uploaded, you need to delete files not in use from the flash memory to make room for the file, and then upload the file again. The files in use cannot be deleted. |
# Connect to the FTP server using the ftp command in user view. You need to provide the IP address of the FTP server, the user name and the password as well to enter FTP view.
<switch> ftp 2.2.2.2
Trying ...
Press CTRL+K to abort
Connected.
220 FTP service ready.
User(none):switch
331 Password required for switch.
Password:
230 User logged in.
[ftp]
# Enter the authorized directory on the FTP server.
[ftp] cd switch
# Execute the put command to upload the configuration file named config.cfg to the FTP server.
[ftp] put config.cfg
# Execute the get command to download the file named config.cfg to the flash memory of the device.
[ftp] get config.cfg
# Execute the quit command to terminate the FTP connection and return to user view.
[ftp] quit
<switch>
# After downloading the file, use the startup saved-configuration command to specify the downloaded configuration file as the main configuration file for next startup, and then restart the switch.
<device>startup saved-configuration config.cfg main
Please wait........................................Done!
|
NOTE: For information about the startup saved-configuration command and how to specify the startup file for the device, see the Fundamentals Command Reference. |
Configuring the FTP server
Configuring FTP server operating parameters
The FTP server uses one of the two modes to update a file when you upload the file (use the put command) to the FTP server:
· In fast mode, the FTP server starts writing data to the storage medium after a file is transferred to the memory. This prevents the existing file on the FTP server from being corrupted in the event that anomaly, power failure for example, occurs during a file transfer.
· In normal mode, the FTP server writes data to the storage medium while receiving data. This means that any anomaly, power failure for example, during file transfer might result in file corruption on the FTP server. This mode, however, consumes less memory space than the fast mode.
Follow these steps to configure the FTP server:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Enable the FTP server |
ftp server enable |
Required Disabled by default. |
Use an ACL to control FTP clients’ access to the device |
ftp server acl acl-number |
Optional By default, no ACL is used to control FTP clients’ access to the device. |
Configure the idle-timeout timer |
ftp timeout minutes |
Optional 30 minutes by default. Within the idle-timeout time, if there is no information interaction between the FTP server and client, the connection between them is terminated. |
Set the file update mode for the FTP server |
ftp update { fast | normal } |
Optional Normal update is used by default. |
Return to user view |
quit |
— |
Manually release the FTP connection established with the specified username |
free ftp user username |
Optional Available in user view |
Configuring authentication and authorization on the FTP server
To allow an FTP user to access certain directories on the FTP server, you need to create an account for the user, authorize the user to access the directories and configure a password for the user.
Make the following configuration to perform authentication and authorization on a local FTP user. To authenticate remote FTP users, you need to configure authentication, authorization and accounting (AAA). For detailed configuration about AAA, see the Security Configuration Guide.
In local authentication, the device checks the input username and password against those configured on the device. In remote authentication, the device sends the input username and password to the remote authentication server for authentication.
Follow these steps to configure authentication and authorization for FTP server:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Create a local user and enter its view |
local-user user-name |
Required No local user exists by default, and the system does not support FTP anonymous user access. |
Assign a password to the user |
password { simple | cipher } password |
Required |
Assign the FTP service to the user |
service-type ftp |
Required By default, the system does not support anonymous FTP access, and does not assign any service. If the FTP service is assigned, the root directory of the device is used by default. |
Configure user properties |
authorization-attribute { acl acl-number | callback-number callback-number | idle-cut minute | level level | user-profile profile-name | user-role security-audit | vlan vlan-id | work-directory directory-name } * |
Optional By default, the FTP/SFTP users can access the root directory of the device, and the user level is 0. You can change the default configuration by using this command. |
|
NOTE: · For more information about the local-user, password, service-type ftp, and authorization-attribute commands, see the Security Command Reference. · When the device serves as the FTP server, to perform the write operations (for example, upload, delete, create, and delete) on the device’s file system, the FTP login users must be level 3 users; to perform other operations, for example, read operation, users of any level from 0 to 3 are allowed. |
FTP server configuration example
Network requirements
As shown in Figure 3, the switching engine operates as an FTP server and a remote PC as an FTP client. The configuration file config.cfg of the switching engine is stored on the PC. Upload the configuration file to the remote switching engine through FTP and use the startup saved-configuration command to specify config.cfg as the main configuration file for next startup and then reboot the device.
· Create a user account on the FTP server with the user name “switch” and password “hello”.
· The IP addresses 1.1.1.1 for a VLAN interface on the switching engine and 2.2.2.2 for the PC have been configured. Ensure that a route exists between the device and the PC.
Figure 3 Network diagram for FTP configurations: the device operating as an FTP server
Configuration procedure
1. Configure the switch (the FTP server)
# Log in to the switching engine and enable the FTP server function on the switching engine. Configure the user name and password used to access FTP services, and specify the service type as FTP (You can log in to the switching engine through OAP or by telnetting the switching engine.)
# Configure the FTP user name as “switch”, the password as “hello”, and the service type as FTP.
<device>
<device> system-view
[device] ftp server enable
[device] local-user switch
[device-luser-switch] password simple hello
[device-luser-switch] service-type ftp
2. Configure the PC (FTP client)
Run an FTP client application on the PC to connect to the FTP server. Upload the configuration file named config.cfg to the root directory of the flash memory of 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 config.cfg is located. In this example it is in the root directory of C:\.
C:\>
# Access the switching engine 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 config.cfg file.
ftp> put config.cfg
200 Port command okay.
150 Opening ASCII mode data connection for config.cfg.
226 Transfer complete.
This example uses the command line window tool provided by Windows. When you log in to the FTP server through another FTP client, refer to the corresponding instructions for operation description.
|
CAUTION: · If available space on the flash memory of the device is not enough to hold the file to be uploaded, you need to delete files not in use from the flash memory to make room for the file, and then upload the file again. The files in use cannot be deleted. · The device is not shipped with FTP client application software. You need to purchase and install it by yourself. |
3. Configure the switch (FTP server)
# After uploading the configuration file, use the startup saved-configuration command to specify the uploaded configuration file as the main configuration file for next startup, and restart the switch.
<device>startup saved-configuration config.cfg main
Please wait........................................Done!
|
NOTE: For information about the startup saved-configuration command and how to specify the main configuration file for the switching engine, see the Fundamentals Configuration Guide. |
Displaying and maintaining FTP
To do… |
Use the command… |
Remarks |
Display the source IP address configuration of the FTP client |
display ftp client configuration [ | { begin | exclude | include } regular-expression ] |
Available in any view |
Display the configuration of the FTP server |
display ftp-server |
Available in any view |
Display detailed information about logged-in FTP users |
display ftp-user |
Available in any view |
This chapter includes these sections:
|
NOTE: · The term "switch" or "device" in this chapter refers to the switching engine on a WX3000E wireless switch. · The WX3000E series comprises WX3024E and WX3010E wireless switches. · The port numbers in this chapter are for illustration only. |
TFTP overview
Introduction to TFTP
The Trivial File Transfer Protocol (TFTP) provides functions similar to those provided by FTP, but it is less complex than FTP in interactive access interface and authentication. It is more suitable in environments where complex interaction is not needed between client and server.
TFTP uses the UDP port 69 for data transmission. For more information about basic TFTP operations, see RFC 1986.
In TFTP, file transfer is initiated by the client.
· In a normal file downloading process, the client sends a read request to the TFTP server, receives data from the server, and then sends the acknowledgement to the server.
· In a normal file uploading process, the client sends a write request to the TFTP server, sends data to the server, and receives the acknowledgement from the server.
TFTP transfers files in two modes:
· Binary mode: Transfers files as raw data, like .app, .bin, and .btm files.
· ASCII mode: Transfers files as text, like .txt, .bat, and .cfg files.
Operation of TFTP
|
NOTE: Only the TFTP client service is available with your device. |
Figure 4 TFTP configuration diagram
Before using TFTP, the administrator needs to configure IP addresses for the TFTP client and server, and make sure that there is a reachable route between the TFTP client and server.
When the device serves as the TFTP client, you need to perform the following configuration:
Table 3 Configuration when the device serves as the TFTP client
Device |
Configuration |
Remarks |
Device (TFTP client) |
· Configure the IP address and routing function, and ensure that the route between the device and the TFTP server is available. · Use the tftp command to establish a connection to the remote TFTP server to upload/download files to/from the TFTP server |
— |
PC (TFTP server) |
Enable TFTP server on the PC, and configure the TFTP working directory. |
— |
Configuring the TFTP client
When a device acts as a TFTP client, you can upload a file on the device to a TFTP server and download a file from the TFTP server to the local device. You can use either of the following methods to download a file:
· Normal download: The device writes the obtained file to the storage medium directly. If you download a remote file using a filename destination-filename that exists in the target directory, the device deletes the original file and saves the new one. If file download fails due to network disconnection or other reasons, the original file will never recover because it has been deleted.
· Secure download: The device saves the obtained file to its memory and does not write it to the storage medium until the whole file is obtained. If you download a remote file using a filename destination-filename that exists in the target directory, the original file is not overwritten. If file download fails due to network disconnection or other reasons, the original file still exists. This mode is more secure but consumes more memory.
H3C recommends that you use the secure mode or, if you use the normal mode, specify a filename that does not exist in the target directory.
When using the tftp client source or tftp command, you can specify the source interface (such as a loopback or dialer interface) or source IP address. The primary IP address of the specified source interface or the specified source IP address is used as the source IP address of sent TFTP packets.
The TFTP client follows these rules to select the source IP address of packets sent to the TFTP server:
· If no source IP address is specified, the IP address of the output interface of the route to the server is used as the source IP address.
· The source IP address specified with the tftp client source or tftp command is used.
· If you first use the tftp client source command to specify a source IP address and then use the tftp command to specify another source IP address, the latter is used.
· The source IP address specified with the tftp client source command applies to all TFTP connections while the one specified with the tftp command applies to the current TFTP connection only.
Follow these steps to configure the TFTP client:
To do… |
Use the command… |
Remarks |
Enter system view |
system-view |
— |
Use an ACL to control the device’s access to TFTP servers |
tftp-server [ ipv6 ] acl acl-number |
Optional By default, no ACL is used to control the device’s access to TFTP servers. |
Specify the source IP address of sent TFTP packets |
tftp client source { interface interface-type interface-number | ip source-ip-address } |
Optional By default, the source IP address is determined by the route from the TFTP client to the TFTP server. |
Return to user view |
quit |
— |
Download or upload a file in an IPv4 network |
tftp server-address { get | put | sget } source-filename [ destination-filename ] [ source { interface interface-type interface-number | ip source-ip-address } ] |
Optional Available in user view |
Download or upload a file in an IPv6 network |
tftp ipv6 tftp-ipv6-server [ -i interface-type interface-number ] { get | put } source-filen[ destination-file ] |
Optional Available in user view |
|
NOTE: · If no primary IP address is configured on the source interface, no TFTP connection can be established. · If you use the tftp client source command to configure a source interface and then use it to configure a source IP address, the source IP address overwrites the source interface, and vice versa. |
Displaying and maintaining the TFTP client
To do… |
Use the command… |
Remarks |
Display the source IP address configuration of the TFTP client |
display tftp client configuration [ | { begin | exclude | include } regular-expression ] |
Available in any view |
TFTP client configuration example
Network requirements
As shown in Figure 5, the switch operates as a TFTP client and a PC as the TFTP server. The configuration file named config.cfg is stored on the PC. Download it to the device through TFTP, and use the startup saved-configuration command to specify config.cfg as the main configuration file for next startup.
· The TFTP working directory is configured on the TFTP server.
· Configure the IP addresses of a VLAN interface on the switch and the PC as 1.1.1.1 and 1.1.1.2 respectively. The port through which the switch connects with the PC belongs to the VLAN.
Figure 5 Network diagram for TFTP configurations
Configuration procedure
1. Configure the TFTP server (PC)
Start the TFTP server and configure the working directory on the PC.
2. Configure the TFTP client (switch).
# Log in to the switching engine. (You can log in to the switching engine through OAP or by telnetting the device.)
|
CAUTION: If available space on the flash memory of the device is not enough to hold the file to be uploaded, you need to delete files not in use from the flash memory to make room for the file, and then upload the file again. The files in use cannot be deleted. |
# Enter system view
<device> system-view
[device]
# Configure the IP address of a VLAN interface on the device to be 1.1.1.1, and ensure that the port through which the device connects with the PC belongs to this VLAN. (This example assumes that the port belongs to VLAN 1.)
[device] interface Vlan-interface 1
[device-Vlan-interface1] ip address 1.1.1.1 255.255.255.0
[device-Vlan-interface1] quit
# Download the device configuration file named config.cfg from the TFTP server to the switch.
<device> tftp 1.1.1.2 get config.cfg config.cfg
# After downloading the file, use the startup saved-configuration command to specify the downloaded configuration file as the main configuration file for next startup, and restart the switch.
<device>startup saved-configuration config.cfg main
Please wait........................................Done!
|
NOTE: For information about the startup saved-configuration command and how to specify the main configuration file for the switching engine, see the Fundamentals Configuration Guide. |