Automatic configuration using TFTP server

Network requirements

As shown in Figure 7, 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:

Figure 41: Network diagram

Configuration 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 Ten-GigabitEthernet 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 the address pool market to assign IP addresses on subnet 192.168.2.0/24 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 the address pool rd to assign IP addresses on subnet 192.168.3.0/24 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 Ten-GigabitEthernet 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 Ten-GigabitEthernet 1/0/1
    [SwitchB-vlan3] port Ten-GigabitEthernet 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 Ten-GigabitEthernet 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 Ten-GigabitEthernet 1/0/1
    [SwitchC-vlan3] port Ten-GigabitEthernet 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, edit the configuration file market.cfg.

    #
     sysname Market
    #
     telnet server enable
    #
    vlan 3
    #
    local-user market
     password simple market
     service-type telnet
     quit
    #
    interface Vlan-interface3
     ip address dhcp-alloc
     quit
    #
    interface Ten-GigabitEthernet1/0/1
     port access vlan 3
     quit
    #
    user-interface vty 0 4
     authentication-mode scheme
     user-role network-admin
    #
    return
    

    # On the TFTP server, edit the configuration file rd.cfg.

    #
     sysname RD
    #
     telnet server enable 
    #
    vlan 3
    #
    local-user rd
     password simple rd
     service-type telnet
     quit
    #
    interface Vlan-interface3
     ip address dhcp-alloc
     quit
    #
    interface Ten-GigabitEthernet1/0/1
     port access vlan 3
     quit
    #
    user-interface vty 0 4
     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 the username market and password market as prompted. (Details not shown.)

    You are logged in to Switch D or Switch E.