< Home

Enabling the DHCP Server Function

This section provides a sample of enabling the DHCP server function using the rpc method.

Table 1 Enabling the DHCP server function

Operation

XPATH

rpc

/huawei-dhcp:dhcp-config/dhcpv4-config/dhcp-server-configuration/dhcp-servers/dhcp-server

Data Requirements

Item

Data

Description

DHCP function

true

Enable the DHCP server function on VLANIF404.

DHCP server function

true

Name and IP address of an interface

  • Interface name: VLANIF404

  • Interface IP address: 10.10.10.44/24

Request Example

<rpc message-id="123" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
 <interface xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:operation="merge">
  <name>Vlanif404</name>
  <type xmlns:x="urn:ietf:params:xml:ns:yang:iana-if-type">x:propVirtual</type>
  <ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
   <address ns0:operation="merge">
    <ip>10.10.10.44</ip>
    <netmask>255.255.255.0</netmask>
   </address>
  </ipv4>
 </interface>
</interfaces>
<dhcp-config xmlns="urn:huawei:params:xml:ns:yang:huawei-dhcp">
 <dhcpv4-config>
  <enable>true</enable>
  <dhcp-server-configuration>
   <dhcp-servers>
    <dhcp-server xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:operation="merge">
     <interface-name>Vlanif404</interface-name>
      <enable>true</enable>
     <hw-dhcp:interface-pool>
     </hw-dhcp:interface-pool>
    </dhcp-server>
   </dhcp-servers>
  </dhcp-server-configuration>
 </dhcpv4-config>
</dhcp-config>
    </config>
  </edit-config>
</rpc>

Response Example

Sample of successful response

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="123">
  <ok/>
</rpc-reply>

Sample of failed response

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="123">
  <rpc-error>
    <error-app-tag>-1</error-app-tag>
    <error-message> Please enable DHCP in the global view first.</error-message>
    <error-info>Error on node /huawei-dhcp:dhcp-config/dhcpv4-config/dhcp-server-configuration/dhcp-servers/dhcp-server[interface-name="Vlanif404"]/enable</error-info>
  </rpc-error>
</rpc-reply>
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >