This section provides a sample of enabling DHCP relay using the rpc method.
Operation |
XPATH |
|---|---|
rpc |
/huawei-dhcp:dhcp-config/dhcpv4-config/dhcp-relay-configuration/dhcp-relays |
Item |
Data |
Description |
|---|---|---|
Whether DHCP is enabled |
true |
Enable DHCP relay on VLANIF 3 and configure it to serve DHCP server with the IP address 10.1.1.2. |
Whether DHCP relay is enabled |
true |
|
Interface name |
VLANIF3 |
|
IP address of the DHCP server served by the DHCP relay agent |
10.1.1.2 |
<rpc message-id="123" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<edit-config>
<target>
<running/>
</target>
<config>
<huawei-vlan:vlans xmlns:huawei-vlan="urn:huawei:params:xml:ns:yang:huawei-vlan">
<huawei-vlan:vlan>
<huawei-vlan:id>3</huawei-vlan:id>
</huawei-vlan:vlan>
</huawei-vlan:vlans>
<if:interfaces xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<if:interface>
<if:name>Vlanif3</if:name>
<if:type xmlns:iana-if-type="urn:ietf:params:xml:ns:yang:iana-if-type">iana-if-type:propVirtual</if:type>
<ip:ipv4 xmlns:ip="urn:ietf:params:xml:ns:yang:ietf-ip">
<ip:address>
<ip:ip>192.168.10.1</ip:ip>
<ip:prefix-length>24</ip:prefix-length>
</ip:address>
</ip:ipv4>
</if:interface>
</if:interfaces>
<if:interfaces xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<if:interface>
<if:name>GigabitEthernet0/0/1</if:name>
<if:type xmlns:iana-if-type="urn:ietf:params:xml:ns:yang:iana-if-type">iana-if-type:ethernetCsmacd</if:type>
<huawei-vlan:vlan xmlns:huawei-vlan="urn:huawei:params:xml:ns:yang:huawei-vlan">
<huawei-vlan:port-link-type>trunk</huawei-vlan:port-link-type>
<huawei-vlan:trunk>
<huawei-vlan:trunk-vlan>3</huawei-vlan:trunk-vlan>
</huawei-vlan:trunk>
</huawei-vlan:vlan>
</if:interface>
</if:interfaces>
<hw-dhcp:dhcp-config xmlns:hw-dhcp="urn:huawei:params:xml:ns:yang:huawei-dhcp">
<hw-dhcp:dhcpv4-config>
<hw-dhcp:enable>true</hw-dhcp:enable>
<hw-dhcp:dhcp-relay-configuration>
<hw-dhcp:dhcp-relays>
<hw-dhcp:dhcp-relay>
<hw-dhcp:interface-name>Vlanif3</hw-dhcp:interface-name>
<hw-dhcp:enable>true</hw-dhcp:enable>
<hw-dhcp:server-ip>10.1.1.2</hw-dhcp:server-ip>
</hw-dhcp:dhcp-relay>
</hw-dhcp:dhcp-relays>
</hw-dhcp:dhcp-relay-configuration>
</hw-dhcp:dhcpv4-config>
</hw-dhcp:dhcp-config>
</config>
</edit-config>
</rpc>
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-relay-configuration/dhcp-relays/dhcp-relay[interface-name="Vlanif3"]/enable</error-info>
</rpc-error>
</rpc-reply>