01-Fundamentals Configuration Guide

HomeSupportConfigure & DeployConfiguration GuidesH3C S6826 & S9826 Switch Series Configuration Guides-Release 6715-6W10001-Fundamentals Configuration Guide
09-Automatic configuration
Title Size Download
09-Automatic configuration 301.84 KB

Using automatic configuration

About automatic configuration

When the device starts up without a valid next-startup configuration file, the device searches the root directory of its default file system for the autocfg.py, autocfg.tcl, and autocfg.cfg files. Only one of files might exist in the root directory. If any one of the files exists, the device loads the file. If none of the files exists, the device uses the automatic configuration feature to obtain a set of configuration settings.

With the automatic configuration feature, the device can automatically obtain a set of configuration settings at startup. This feature simplifies network configuration and maintenance.

Automatic configuration can be implemented by using the implementation methods in Table 1.

Table 1 Automatic configuration implementation methods

Implementation method

Configuration file location

Application scenarios

Server-based automatic configuration

File server

A number of geographically distributed devices need to be configured.

Using server-based automatic configuration

About server-based automatic configuration

With server-based automatic configuration, a device without a configuration file can run the DHCP client to obtain a configuration file from a file server at startup.

You can deploy server-based automatic configuration on both IPv4 and IPv6 networks by using the same method. This chapter describes the tasks for deploying server-based automatic configuration on an IPv4 network.

Typical server-based automatic configuration network

As shown in Figure 1, a typical server-based automatic configuration network consists of the following servers:

·     DHCP server—Allocates an IP address to the device that performs server-based automatic configuration and notifies the device of the method to obtain the configuration file or script file for automatic configuration.

·     File server—TFTP, HTTP, SFTP, or FTP server. The file server stores the configuration file or script file for automatic configuration.

·     (Optional.) DNS server—Obtains the configuration file name or the IP address of the file server for the device.

Figure 1 Server-based automatic configuration network diagram

Host name file

A host name file stores mappings between host IP addresses and host names. To configure a host name file:

1.     Create a host name file. The file name must be network.cfg.

2.     Add each mapping entry in the ip host host-name ip-address format on a separate line. For example:

ip host host1 101.101.101.101

ip host host2 101.101.101.102

ip host client1 101.101.101.103

ip host client2 101.101.101.104

 

IMPORTANT

IMPORTANT:

The host name for a device must be the same as the name of the configuration file configured for the device. For example, the name of the configuration file for the device at 101.101.101.101 is host1.cfg.

Selecting the interface used for automatic configuration

The device uses the following steps to select the interface for automatic configuration:

1.     Identifies the status of the management Ethernet interface at Layer 2. If the management Ethernet interface is up, the device uses that interface.

2.     Identifies the status of Layer 2 Ethernet interfaces. If one or more Layer 2 Ethernet interfaces are in up state, the device uses the VLAN interface of the default VLAN.

For fast automatic device configuration, connect only the management Ethernet interface on each device to the network.

Operating mechanism

The process for server-based automatic configuration for a device is as follows:

1.     The device selects the interface used to obtain the configuration file or script file for automatic configuration and sends an IP request message to the DHCP server. For more information about the interface selection order, see "Selecting the interface used for automatic configuration."

2.     After the DHCP server receives the IP request message, it sends a reply message to the device. If the device does not receive any reply message within the timeout period of the request message, it selects the next interface according to the interface selection order and sends the IP request message again.

3.     The device parses the reply message.

¡     Obtains the IP address included in the reply message and uses it as the IP address for the selected interface to connect to the DHCP server. If the interface already has an IP address assigned, the device replaces the original IP address with the one included in the reply message. Once the automatic configuration process is complete, the device restores the original IP address to the interface.

¡     Obtains the protocol information (HTTP, TFTP, SFTP, or FTP), configuration file name information, and file server address included in the reply message.

4.     If no configuration file name is obtained or the obtained configuration file name does not meet the requirements, the device uses file network.cfg on the file server. If file network.cfg does not exist, the device uses file device.cfg on the file server. If file device.cfg does not exist, the device fails to obtain the configuration file or script file. In this case, the process returns to step 1.

5.     The device resolves the domain name of the file server. If the file server address included in the reply message is a domain name rather than an IP address, the device uses the DNS server to resolve the domain name to an IP address.

6.     The device downloads the configuration file or script file used for automatic configuration from the file server based on the obtained protocol, file server address, and configuration file name.

7.     The device deploys the configuration in the configuration file or executes the script file.

8.     The device automatically deletes the configuration file or script file.

Server-based automatic configuration tasks at a glance

To configure server-based automatic configuration, perform the following tasks:

1.     Prepare the files for automatic configuration:

¡     Preparing configuration files

¡     Preparing script files

2.     Configuring the file server

3.     Configuring the DHCP server

4.     (Optional.) Configuring the DNS server

5.     (Optional.) Configuring the gateway

6.     Starting and completing automatic configuration

7.     (Optional.) Stopping automatic configuration

Preparing configuration files

Configuration file types

The device supports the configuration file types listed in Table 2.

Table 2 Configuration file types

Configuration file type

Application objects

File name requirements

Supported file server types

Dedicated configuration file

Devices that require different settings

File name.cfg

For simple file name identification, use configuration file names that do not contain spaces.

·     HTTP server

·     TFTP server

·     SFTP server

·     FTP server

Common configuration file

Devices that share all or some settings

File name.cfg

For simple file name identification, use configuration file names that do not contain spaces.

·     HTTP server

·     TFTP server

·     SFTP server

·     FTP server

Default configuration file

All devices.

The file contains only common configurations that devices use to start up.

device.cfg

TFTP server

Identifying requirements for and preparing configuration files

1.     Identify the requirements of the devices for configuration files.

2.     For devices that require different configurations, prepare a configuration file for each of them and save the files to the file server.

3.     For devices that share all or some configurations, save the common configurations to a .cfg file on the file server.

4.     If a TFTP file server is used, you can save the common configurations that devices use to start up to the device.cfg file on the server. The file is assigned to a device only when the device does not have any other configuration file to use.

Preparing a host name file on the file server

If the DHCP server does not assign configuration file names, you can configure a host name file on the file server. The host name file contains the host name-IP address mappings of the devices to be automatically configured. As the host name for a device is the same as the name of the configuration file configured for the device, the device can obtain the configuration file configured for it.

Preparing script files

About this task

Script files can be used for automatic software upgrade and automatic configuration.

The devices support Python scripts (.py files) and Tcl scripts (.tcl files). For more information about Python and Tcl scripts, see "Using Python" and "Using Tcl."

The devices support dedicated script files and common dedicated script files. They do not support using a default script file. For information about dedicated script files and common dedicated script files, see Table 2.

When script files are used, you cannot use a host name file to provide the host name-IP address mappings for devices.

Restrictions and guidelines

To use a Tcl script, make sure all commands in the script are supported and correctly configured. Any error in a command causes the automatic configuration process to quit.

When you use a Python script to automatically configure a device, make sure the script file does not contain command line errors (such as spelling mistakes, incorrect views, and unsupported commands for the device). If the script file contains command line errors, the current round of automatic configuration will fail and the device will proceed to the next round of automatic configuration.

When you use a Python script to automatically configure a device, the device is in the startup phase and the device is unstable. Therefore, do not use the Stable value in the display system stable state command output as the judgment condition in the Python script.

Procedure

·     For devices that share all or some configurations, create a script file that contains the common configurations.

·     For the other devices, create a separate script file for each of them.

Configuring the file server

For devices to obtain configuration information from an HTTP, TFTP, SFTP, or FTP server, start HTTP, TFTP, SFTP, or FTP service on the file server, respectively.

Configuring the DHCP server

About this task

The DHCP server assigns the following items to devices that need to be automatically configured:

·     IP addresses.

·     Paths of the configuration or script files.

Restrictions and guidelines

When you configure the DHCP server, follow these guidelines:

·     For devices for which you have prepared different configuration files, perform the following tasks for each of the devices on the DHCP server:

¡     Create a DHCP address pool.

¡     Configure a static address binding.

¡     Specify a configuration file or script file.

Because an address pool can use only one configuration file, you can specify only one static address binding for an address pool.

·     For devices for which you have prepared the same configuration file, use either of the following methods:

¡     Method 1:

-     Create a DHCP address pool for the devices.

-     Configure a static address binding for each of the devices in the address pool.

-     Specify the configuration file for the devices.

¡     Method 2:

-     Create a DHCP address pool for the devices.

-     Specify the subnet for dynamic allocation.

-     Specify the TFTP server.

-     Specify the configuration file for the devices.

·     If all devices on a subnet share the same configuration file or script file, perform the following tasks on the DHCP server:

¡     Configure dynamic address allocation.

¡     Specify the configuration file or script file for the devices.

The configuration file can contain only the common settings for the devices. You can provide a method for the device administrators to change the configurations after their devices start up.

When you specify a startup configuration file on a remote server for a DHCP client, follow these restrictions and guidelines:

·     If a TFTP server is used, you must specify the file name. If the file name contains special characters, you must transcode the special characters according to the RFC specification.

·     If an HTTP server is used, you must specify the URL of the file in the format of http://HTTP-server-IP-address:port-number/path/file-name. If the path or file name in the URL contains special characters, you must transcode the special characters according to the RFC specification. If you do not specify a port number, the default port number applies.

·     If an FTP server is used, you must specify the URL of the file in the format of ftp://username:password@FTP-server-IP-address:port-number/path/file-name. If the username, password, path, or file name in the URL contains special characters, you must transcode the special characters according to the RFC specification. If you do not specify a port number, the default port number applies. If you do not specify a path, the root directory of the server applies.

·     If an SFTP server is used, you must specify the URL of the file in the format of sftp://username:password@SFTP-server-IP-address:port-number/path/file-name. If the username, password, path, or file name in the URL contains special characters, you must transcode the special characters according to the RFC specification. If you do not specify a port number, the default port number applies. If you do not specify a path, the root directory of the server applies.

Configuring the DHCP server when an HTTP file server is used

1.     Enter system view.

system-view

2.     Enable DHCP.

dhcp enable

By default, DHCP is disabled.

3.     Create a DHCP address pool and enter its view.

dhcp server ip-pool pool-name

4.     Configure the address pool.

Choose the options to configure as needed:

¡     Specify the primary subnet for the address pool.

network network-address [ mask-length | mask mask ]

By default, no primary subnet is specified.

¡     Configure a static binding.

static-bind ip-address ip-address [ mask-length | mask mask ] { client-identifier client-identifier | hardware-address hardware-address [ ethernet | token-ring ] }

By default, no static binding is configured.

You can configure multiple static bindings. However, one IP address can be bound to only one client. To change the binding for a DHCP client, you must remove the binding and reconfigure a binding.

5.     Specify the URL of the configuration or script file in HTTP format.

bootfile-name url

By default, no configuration or script file URL is specified in HTTP format.

Configuring the DHCP server when a TFTP file server is used

1.     Enter system view.

system-view

2.     Enable DHCP.

dhcp enable

By default, DHCP is disabled.

3.     Create a DHCP address pool and enter its view.

dhcp server ip-pool pool-name

4.     Configure the address pool.

Choose the options to configure as needed:

¡     Specify the primary subnet for the address pool.

network network-address [ mask-length | mask mask ]

By default, no primary subnet is specified.

¡     Configure a static binding.

static-bind ip-address ip-address [ mask-length | mask mask ] { client-identifier client-identifier | hardware-address hardware-address [ ethernet | token-ring ] }

By default, no static binding is configured.

You can configure multiple static bindings. However, one IP address can be bound to only one client. To change the binding for a DHCP client, you must remove the binding and reconfigure a binding.

5.     Specify a TFTP server.

Choose one option as needed:

¡     Specify the IP address of the TFTP server.

tftp-server ip-address ip-address

By default, no TFTP server IP address is specified.

¡     Specify the name of the TFTP server.

tftp-server domain-name domain-name

By default, no TFTP server name is specified.

If you specify a TFTP server by its name, a DNS server is required on the network.

6.     Specify the name of the configuration or script file.

bootfile-name bootfile-name

By default, no configuration or script file name is specified.

Configuring the DHCP server when an SFTP file server is used

1.     Enter system view.

system-view

2.     Enable DHCP.

dhcp enable

By default, DHCP is disabled.

3.     Create a DHCP address pool and enter its view.

dhcp server ip-pool pool-name

4.     Configure the address pool.

Choose the options to configure as needed:

¡     Specify the primary subnet for the address pool.

network network-address [ mask-length | mask mask ]

By default, no primary subnet is specified.

¡     Configure a static binding.

static-bind ip-address ip-address [ mask-length | mask mask ] { client-identifier client-identifier | hardware-address hardware-address [ ethernet | token-ring ] }

By default, no static binding is configured.

You can configure multiple static bindings. However, one IP address can be bound to only one client. To change the binding for a DHCP client, you must remove the binding and reconfigure a binding.

5.     Specify the URL of the configuration or script file in SFTP format.

bootfile-name url

By default, no configuration or script file URL in SFTP format is specified.

Configuring the DHCP server when an FTP file server is used

1.     Enter system view.

system-view

2.     Enable DHCP.

dhcp enable

By default, DHCP is disabled.

3.     Create a DHCP address pool and enter its view.

dhcp server ip-pool pool-name

4.     Configure the address pool.

Choose the options to configure as needed:

¡     Specify the primary subnet for the address pool.

network network-address [ mask-length | mask mask ]

By default, no primary subnet is specified.

¡     Configure a static binding.

static-bind ip-address ip-address [ mask-length | mask mask ] { client-identifier client-identifier | hardware-address hardware-address [ ethernet | token-ring ] }

By default, no static binding is configured.

You can configure multiple static bindings. However, one IP address can be bound to only one client. To change the binding for a DHCP client, you must remove the binding and reconfigure a binding.

5.     Specify the URL of the configuration or script file in FTP format.

bootfile-name url

By default, no configuration or script file URL in FTP format is specified.

Configuring the DNS server

A DNS server is required in the following situations:

·     Obtaining the names of configuration files for automatic configuration when the TFTP server does not have a host name file—In this situation, the devices that perform server-based automatic configuration use the DNS server to resolve their IP addresses to their host names. Then, each device can use its host name to obtain the configuration file that has the same name as its host name from the TFTP server.

·     Obtaining the IP address of a file server—If the devices obtain the domain name of the file server from DHCP reply messages, they can use the domain name to obtain the IP address of the file server through the DNS server.

For more information about DNS servers, see DNS configuration in Layer 3—IP Services Configuration Guide.

Configuring the gateway

If the devices to be automatically configured and the servers for automatic configuration reside in different network segments, you must perform the following tasks:

·     Deploy a gateway and make sure the devices can communicate with the servers.

·     Configure the DHCP relay agent feature on the gateway.

·     Configure the UDP helper feature on the gateway.

This task is required if devices send requests to a TFTP server by using broadcast packets. A device uses broadcast packets to send requests to a TFTP server in the following situations:

¡     The DHCP reply does not contain the IP address or domain name of the TFTP server.

¡     The IP address or domain name of the TFTP server is invalid.

The UDP helper transforms a broadcast packet into a unicast packet and forwards the unicast packet to the file server. For more information about UDP helper, see Layer 3—IP Services Configuration Guide.

Starting and completing automatic configuration

1.     Power on the devices to be automatically configured.

2.     The devices enter the automatic configuration process. After a device obtains a configuration file and executes the file successfully, the automatic configuration process ends.

3.     Save the running configuration.

save

As a best practice, save the running configuration on each device after the configuration file is executed successfully on the device.

For more information about the save command, see configuration file management commands in Fundamentals Command Reference.

Stopping automatic configuration

If a device cannot obtain a configuration file for automatic configuration, the current automatic configuration attempt fails, and the device continues attempting automatic configuration. You can wait until the device automatically ends the automatic configuration process after it has made the maximum number of attempts. Alternatively, you can manually stop the automatic configuration process by using shortcut keys Ctrl+C or Ctrl+D based on the prompt information. After the automatic configuration process fails and ends, the device starts up with initial settings.

Server-based automatic configuration examples

Example: Using a TFTP server for automatic configuration

Network configuration

As shown in Figure 2, two departments of a company are connected to the network through gateways (Switch B and Switch C). Access devices Switch D, Switch E, Switch F, and Switch G do not have a configuration file.

Configure the servers and gateways so the access devices can obtain a configuration file to complete the following configuration tasks:

·     Enable administrators of access devices to Telnet to and manage their respective access devices.

·     Require administrators to enter their respective usernames and passwords at login.

Figure 2 Network diagram

Procedure

1.     Configure the DHCP server:

# Create a VLAN interface and assign an IP address to the interface.

<SwitchA> system-view

[SwitchA] vlan 2

[SwitchA-vlan2] port twenty-fivegige 1/0/1

[SwitchA-vlan2] quit

[SwitchA] interface vlan-interface 2

[SwitchA-Vlan-interface2] ip address 192.168.1.42 24

[SwitchA-Vlan-interface2] quit

# Enable DHCP.

[SwitchA] dhcp enable

# Enable the DHCP server on VLAN-interface 2.

[SwitchA] interface vlan-interface 2

[SwitchA-Vlan-interface2] dhcp select server

[SwitchA-Vlan-interface2] quit

# Configure address pool market to assign IP addresses on the 192.168.2.0/24 subnet to clients in the Marketing department. Specify the TFTP server, gateway, and configuration file name for the clients.

[SwitchA] dhcp server ip-pool market

[SwitchA-dhcp-pool-market] network 192.168.2.0 24

[SwitchA-dhcp-pool-market] tftp-server ip-address 192.168.1.40

[SwitchA-dhcp-pool-market] gateway-list 192.168.2.1

[SwitchA-dhcp-pool-market] bootfile-name market.cfg

[SwitchA-dhcp-pool-market] quit

# Configure address pool rd to assign IP addresses on the 192.168.3.0/24 subnet to clients in the R&D department. Specify the TFTP server, gateway, and configuration file name for the clients.

[SwitchA] dhcp server ip-pool rd

[SwitchA-dhcp-pool-rd] network 192.168.3.0 24

[SwitchA-dhcp-pool-rd] tftp-server ip-address 192.168.1.40

[SwitchA-dhcp-pool-rd] gateway-list 192.168.3.1

[SwitchA-dhcp-pool-rd] bootfile-name rd.cfg

[SwitchA-dhcp-pool-rd] quit

# Configure static routes to the DHCP relay agents.

[SwitchA] ip route-static 192.168.2.0 24 192.168.1.41

[SwitchA] ip route-static 192.168.3.0 24 192.168.1.43

[SwitchA] quit

2.     Configure the gateway Switch B:

# Create VLAN interfaces and assign IP addresses to the interfaces.

<SwitchB> system-view

[SwitchB] vlan 2

[SwitchB-vlan2] port twenty-fivegige 1/0/3

[SwitchB-vlan2] quit

[SwitchB] interface vlan-interface 2

[SwitchB-Vlan-interface2] ip address 192.168.1.41 24

[SwitchB-Vlan-interface2] quit

[SwitchB] vlan 3

[SwitchB-vlan3] port twenty-fivegige 1/0/1

[SwitchB-vlan3] port twenty-fivegige 1/0/2

[SwitchB-vlan3] quit

[SwitchB] interface vlan-interface 3

[SwitchB-Vlan-interface3] ip address 192.168.2.1 24

[SwitchB-Vlan-interface3] quit

# Enable DHCP.

[SwitchB] dhcp enable

# Enable the DHCP relay agent on VLAN-interface 3.

[SwitchB] interface vlan-interface 3

[SwitchB-Vlan-interface3] dhcp select relay

# Specify the DHCP server address.

[SwitchB-Vlan-interface3] dhcp relay server-address 192.168.1.42

3.     Configure the gateway Switch C:

# Create VLAN interfaces and assign IP addresses to the interfaces.

<SwitchC> system-view

[SwitchC] vlan 2

[SwitchC-vlan2] port twenty-fivegige 1/0/3

[SwitchC-vlan2] quit

[SwitchC] interface vlan-interface 2

[SwitchC-Vlan-interface2] ip address 192.168.1.43 24

[SwitchC-Vlan-interface2] quit

[SwitchC] vlan 3

[SwitchC-vlan3] port twenty-fivegige 1/0/1

[SwitchC-vlan3] port twenty-fivegige 1/0/2

[SwitchC-vlan3] quit

[SwitchC] interface vlan-interface 3

[SwitchC-Vlan-interface3] ip address 192.168.3.1 24

[SwitchC-Vlan-interface3] quit

# Enable DHCP.

[SwitchC] dhcp enable

# Enable the DHCP relay agent on VLAN-interface 3.

[SwitchC] interface vlan-interface 3

[SwitchC-Vlan-interface3] dhcp select relay

# Specify the DHCP server address.

[SwitchC-Vlan-interface3] dhcp relay server-address 192.168.1.42

4.     Configure the TFTP server:

# On the TFTP server, create a configuration file named market.cfg.

#

 sysname Market

#

 telnet server enable

#

vlan 3

#

local-user market

 password simple build22345

 service-type telnet

 quit

#

interface Vlan-interface3

 ip address dhcp-alloc

 quit

#

interface twenty-fivegige 1/0/1

 port access vlan 3

 quit

#

user-interface vty 0 63

 authentication-mode scheme

 user-role network-admin

#

return

# On the TFTP server, create a configuration file named rd.cfg.

#

 sysname RD

#

 telnet server enable

#

vlan 3

#

local-user rd

 password simple create22345

 service-type telnet

 quit

#

interface Vlan-interface3

 ip address dhcp-alloc

 quit

#

interface twenty-fivegige 1/0/1

 port access vlan 3

 quit

#

user-interface vty 0 63

 authentication-mode scheme

 user-role network-admin

#

return

# Start TFTP service software, and specify the folder where the two configuration files reside as the working directory. (Details not shown.)

# Verify that the TFTP server and DHCP relay agents can reach each other. (Details not shown.)

Verifying the configuration

1.     Power on Switch D, Switch E, Switch F, and Switch G.

2.     After the access devices start up, display assigned IP addresses on Switch A.

<SwitchA> display dhcp server ip-in-use

IP address       Client-identifier/    Lease expiration      Type

                 Hardware address

192.168.2.2      3030-3066-2e65-3233-  May 6 05:21:25 2013   Auto(C)

                 642e-3561-6633-2d56-

                 6c61-6e2d-696e-7465-

                 7266-6163-6533

192.168.2.3      3030-3066-2e65-3230-  May 6 05:22:50 2013   Auto(C)

                 302e-3232-3033-2d56-

                 6c61-6e2d-696e-7465-

                 7266-6163-6533

192.168.3.2      3030-6530-2e66-6330-  May 6 05:23:15 2013   Auto(C)

                 302e-3335-3131-2d56-

                 6c61-6e2d-696e-7465-

                 7266-6163-6531

192.168.3.3      3030-6530-2e66-6330-  May 6 05:24:10 2013   Auto(C)

                 302e-3335-3135-2d56-

                 6c61-6e2d-696e-7465-

                 7266-6163-6532

3.     Telnet to 192.168.2.2 from Switch A.

<SwitchA> telnet 192.168.2.2

4.     Enter username market and password build22345 as prompted. (Details not shown.)

You are logged in to Switch D or Switch E.

Example: Using an HTTP server and Tcl scripts for automatic configuration

Network configuration

As shown in Figure 3, Switch A does not have a configuration file.

Configure the servers so Switch A can obtain a Tcl script to complete the following configuration tasks:

·     Enable the administrator to Telnet to Switch A to manage Switch A.

·     Require the administrator to enter the correct username and password at login.

Figure 3 Network diagram

Procedure

1.     Configure the DHCP server:

# Enable DHCP.

<DeviceA> system-view

[DeviceA] dhcp enable

# Configure address pool 1 to assign IP addresses on the 192.168.1.0/24 subnet to clients.

[DeviceA] dhcp server ip-pool 1

[DeviceA-dhcp-pool-1] network 192.168.1.0 24

# Specify the URL of the script file for the clients.

[DeviceA-dhcp-pool-1] bootfile-name http://192.168.1.40/device.tcl

2.     Configure the HTTP server:

# Create a configuration file named device.tcl on the HTTP server.

system-view

telnet server enable

local-user user

password simple hello22345

service-type telnet

quit

user-interface vty 0 63

authentication-mode scheme

user-role network-admin

quit

 

ip address dhcp-alloc

return

# Start HTTP service software and enable HTTP service. (Details not shown.)

Verifying the configuration

1.     Power on Switch A.

2.     After Switch A starts up, display assigned IP addresses on Device A.

<DeviceA> display dhcp server ip-in-use

IP address       Client identifier/    Lease expiration      Type

                 Hardware address

192.168.1.2      0030-3030-632e-3239-  Dec 12 17:41:15 2013  Auto(C)

                 3035-2e36-3736-622d-

                 4574-6830-2f30-2f32

3.     Telnet to 192.168.1.2 from Device A.

<DeviceA> telnet 192.168.1.2

4.     Enter username user and password hello22345 as prompted. (Details not shown.)

You are logged in to Switch A.

Example: Using an HTTP server and Python scripts for automatic configuration

Network configuration

As shown in Figure 4, Switch A does not have a configuration file.

Configure the servers so Switch A can obtain a Python script to complete the following configuration tasks:

·     Enable the administrator to Telnet to Switch A to manage Switch A.

·     Require the administrator to enter the correct username and password at login.

Figure 4 Network diagram

Procedure

1.     Configure the DHCP server:

# Enable DHCP.

<DeviceA> system-view

[DeviceA] dhcp enable

# Configure address pool 1 to assign IP addresses on the 192.168.1.0/24 subnet to clients.

[DeviceA] dhcp server ip-pool 1

[DeviceA-dhcp-pool-1] network 192.168.1.0 24

# Specify the URL of the script file for the clients.

[DeviceA-dhcp-pool-1] bootfile-name http://192.168.1.40/device.py

2.     Configure the HTTP server:

# Create a configuration file named device.py on the HTTP server.

#!usr/bin/python

 

import plathformtools

plathformtools.CLI(‘system-view ;telnet server enable ;local-user user ;password simple hello22345 ;service-type telnet ;quit ;user-interface vty 0 63 ;authentication-mode scheme ;user-role network-admin ;quit ;ip address dhcp-alloc ;return’)

# Start HTTP service software and enable HTTP service. (Details not shown.)

Verifying the configuration

1.     Power on Switch A.

2.     After Switch A starts up, display assigned IP addresses on Device A.

<DeviceA> display dhcp server ip-in-use

IP address       Client identifier/    Lease expiration      Type

                 Hardware address

192.168.1.2      0030-3030-632e-3239-  Dec 12 17:41:15 2013  Auto(C)

                 3035-2e36-3736-622d-

                 4574-6830-2f30-2f32

3.     Telnet to 192.168.1.2 from Device A.

<DeviceA> telnet 192.168.1.2

4.     Enter username user and password hello22345 as prompted. (Details not shown.)

You are logged in to Switch A.

Example: Using an SFTP server for automatic configuration

Network configuration

As shown in Figure 5, Switch A automatically obtains and executes a configuration file from the SFTP server after it starts up in order to meet the following requirements:

·     The network administrator can log in to and control the switch through Telnet.

·     Authentication is required for switch login to enhance security.

Figure 5 Network diagram

Procedure

 

1.     Configure the DHCP server:

# Enable DHCP, create DHCP address pool 1, and specify primary subnet 192.168.1.0/24 for dynamic allocation in the address pool.

<DeviceA> system-view

[DeviceA] dhcp enable

[DeviceA] dhcp server ip-pool 1

[DeviceA-dhcp-pool-1] network 192.168.1.0 24

# Specify the URL of the configuration file. The username and password must be the same as those on the SFTP server.

[DeviceA-dhcp-pool-1] bootfile-name sftp://user%dd:[email protected]:22/device.cfg

2.     Configure the SFTP server to ensure that Switch A can successfully download configuration file device.cfg from the SFTP server:

# Create configuration file device.cfg on the SFTP server. The file contents are as follows:

#

telnet server enable

#

local-user user

password simple hello12345

service-type telnet

quit

#

user-interface vty 0 63

authentication-mode scheme

user-role network-admin

quit

#

interface twenty-fivegige 1/0/1

port link-mode route

ip address dhcp-alloc

return

# Start the SFTP management software and enable the SFTP service. (Details not shown.)

Verifying the configuration

# Start up Switch A without a startup configuration file. After the switch starts up successfully, display binding information about assigned IP addresses on Device A.

<DeviceA> display dhcp server ip-in-use

IP address       Client identifier/    Lease expiration      Type

                 Hardware address

192.168.1.2      0030-3030-632e-3239-  Dec 12 17:41:15 2013  Auto(C)

                 3035-2e36-3736-622d-

                 4574-6830-2f30-2f32

# On Device A, Telnet to Switch A.

<SwitchA> telnet 192.168.1.2

# Enter username user and password hello12345. Verify that you can Telnet to Switch A from Device A.

Example: Using an FTP server for automatic configuration

Network configuration

As shown in Figure 6, Switch A automatically obtains and executes a configuration file from the FTP server after it starts up in order to meet the following requirements:

·     The network administrator can log in to and control the switch through Telnet.

·     Authentication is required for switch login to enhance security.

Figure 6 Network diagram

Procedure

 

1.     Configure the DHCP server:

# Enable DHCP, create DHCP address pool 1, and specify primary subnet 192.168.1.0/24 for dynamic allocation in the address pool.

<DeviceA> system-view

[DeviceA] dhcp enable

[DeviceA] dhcp server ip-pool 1

[DeviceA-dhcp-pool-1] network 192.168.1.0 24

# Specify the URL of the configuration file. The username and password must be the same as those on the FTP server.

[DeviceA-dhcp-pool-1] bootfile-name ftp://user:[email protected]:22/device.cfg

2.     Configure the FTP server to ensure that Switch A can successfully download configuration file device.cfg from the FTP server:

# Create configuration file device.cfg on the FTP server. The file contents are as follows:

#

telnet server enable

#

local-user user

password simple hello12345

service-type telnet

quit

#

user-interface vty 0 63

authentication-mode scheme

user-role network-admin

quit

#

interface twenty-fivegige 1/0/1

port link-mode route

ip address dhcp-alloc

return

# Start the FTP management software and enable the FTP service. (Details not shown.)

Verifying the configuration

# Start up Switch A without a startup configuration file. After the switch starts up successfully, display binding information about assigned IP addresses on Device A.

<DeviceA> display dhcp server ip-in-use

IP address       Client identifier/    Lease expiration      Type

                 Hardware address

192.168.1.2      0030-3030-632e-3239-  Dec 12 17:41:15 2013  Auto(C)

                 3035-2e36-3736-622d-

                 4574-6830-2f30-2f32

# On Device A, Telnet to Switch A.

<SwitchA> telnet 192.168.1.2

# Enter username user and password hello12345. Verify that you can Telnet to Switch A from Device A.

 

  • Cloud & AI
  • InterConnect
  • Intelligent Computing
  • Intelligent Storage
  • Security
  • SMB Products
  • Intelligent Terminal Products
  • Product Support Services
  • Technical Service Solutions
All Services
  • Resource Center
  • Policy
  • Online Help
  • Technical Blogs
All Support
  • Become A Partner
  • Partner Policy & Program
  • Global Learning
  • Partner Sales Resources
  • Partner Business Management
  • Service Business
All Partners
  • Profile
  • News & Events
  • Online Exhibition Center
  • Contact Us
All About Us
新华三官网