In Figure 1, the IP phone and PCs described represent typical in an office. To uniformly manage these devices and reduce manual configuration costs, the administrator needs to configure hosts to dynamically obtain IP addresses using DHCP.
PCs are fixed terminals in the duty room and need to be always online and use domain names to access network devices. PCs also require the unlimited IP address lease time and need to obtain information about the DNS server.
The IP phone (MAC address dcd2-fc96-e4c0) needs a fixed IP address 10.1.1.4/24 and needs to dynamically obtain its startup configuration file configuration.ini from the FTP server. There are reachable routes between the FTP server and IP phone. The gateway address of the PCs and IP phone is 10.1.1.1/24.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan 10 [SwitchA-vlan10] quit [SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] port link-type hybrid [SwitchA-GigabitEthernet0/0/1] port hybrid pvid vlan 10 [SwitchA-GigabitEthernet0/0/1] port hybrid untagged vlan 10 [SwitchA-GigabitEthernet0/0/1] quit [SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 10.1.1.1 255.255.255.0 [SwitchA-Vlanif10] quit
[SwitchA] dhcp enable
In the DHCP Option template view, configure the startup configuration file for the static client IP phone and specify the IP address of the file server for the IP phone to obtain the startup configuration file.
[SwitchA] dhcp option template template1 [SwitchA-dhcp-option-template-template1] gateway-list 10.1.1.1 [SwitchA-dhcp-option-template-template1] bootfile configuration.ini [SwitchA-dhcp-option-template-template1] next-server 10.1.1.3 [SwitchA-dhcp-option-template-template1] quit
In the IP address pool view, configure the gateway address, IP address lease, and DNS server IP address for the PCs. Allocate a fixed IP address to the IP phone and configure the startup configuration file.
[SwitchA] ip pool pool1 [SwitchA-ip-pool-pool1] network 10.1.1.0 mask 255.255.255.0 [SwitchA-ip-pool-pool1] dns-list 10.1.1.2 [SwitchA-ip-pool-pool1] gateway-list 10.1.1.1 [SwitchA-ip-pool-pool1] excluded-ip-address 10.1.1.2 10.1.1.3 [SwitchA-ip-pool-pool1] lease unlimited [SwitchA-ip-pool-pool1] static-bind ip-address 10.1.1.4 mac-address dcd2-fc96-e4c0 option-template template1 [SwitchA-ip-pool-pool1] quit
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] dhcp select global [SwitchA-Vlanif10] quit
[SwitchA] dhcp server database enable
# Run the display ip pool name pool1 command on SwitchA to view the address pool configuration.
[SwitchA] display ip pool name pool1 Pool-name : pool1 Pool-No : 0 Lease : unlimited Domain-name : - DNS-server0 : 10.1.1.2 NBNS-server0 : - Netbios-type : - Position : Local Status : Unlocked Gateway-0 : 10.1.1.1 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :4 Idle :247 Expired :0 Conflict :0 Disabled :2 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.1.1.1 10.1.1.254 253 4 247(0) 0 2 -------------------------------------------------------------------------------
# Run the display dhcp option template name template1 command on SwitchA to view the DHCP Option template configuration.
[SwitchA] display dhcp option template name template1
-------------------------------------------------------------------------------
Template-Name : template1
Template-No : 0
Next-server : 10.1.1.3
Domain-name : -
DNS-server0 : -
NBNS-server0 : -
Netbios-type : -
Gateway-0 : 10.1.1.1
Bootfile : configuration.ini
SwitchA configuration file
# sysname SwitchA # vlan batch 10 # dhcp enable # dhcp server database enable # dhcp option template template1 gateway-list 10.1.1.1 next-server 10.1.1.3 bootfile configuration.ini # ip pool pool1 gateway-list 10.1.1.1 network 10.1.1.0 mask 255.255.255.0 excluded-ip-address 10.1.1.2 10.1.1.3 static-bind ip-address 10.1.1.4 mac-address dcd2-fc96-e4c0 option-template template1 lease unlimited dns-list 10.1.1.2 # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 dhcp select global # interface GigabitEthernet0/0/1 port link-type hybrid port hybrid pvid vlan 10 port hybrid untagged vlan 10 # return