1# dhclient 2 3 4## Command Function<a name="section366714216619"></a> 5 6This command is used to set and query **dhclient** parameters. 7 8## Syntax<a name="section8833164614615"></a> 9 10- dhclient <_netif name_\> 11- dhclient -x <_netif name_\> 12 13## Parameters<a name="section12809111019453"></a> 14 15**Table 1** Parameter description 16 17<a name="table438mcpsimp"></a> 18<table><thead align="left"><tr id="row444mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p446mcpsimp"><a name="p446mcpsimp"></a><a name="p446mcpsimp"></a><strong id="b20999054421160"><a name="b20999054421160"></a><a name="b20999054421160"></a>Parameter</strong></p> 19</th> 20<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p448mcpsimp"><a name="p448mcpsimp"></a><a name="p448mcpsimp"></a><strong id="b16991513175018"><a name="b16991513175018"></a><a name="b16991513175018"></a>Description</strong></p> 21</th> 22<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p450mcpsimp"><a name="p450mcpsimp"></a><a name="p450mcpsimp"></a><strong id="b9837196561160"><a name="b9837196561160"></a><a name="b9837196561160"></a>Value Range</strong></p> 23</th> 24</tr> 25</thead> 26<tbody><tr id="row15810322374"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p108030222712"><a name="p108030222712"></a><a name="p108030222712"></a>-h | --help</p> 27</td> 28<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p14803132214716"><a name="p14803132214716"></a><a name="p14803132214716"></a>Displays parameters supported by the <strong id="b71961312874"><a name="b71961312874"></a><a name="b71961312874"></a>dhclient</strong> command and their usage.</p> 29</td> 30<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p28038222716"><a name="p28038222716"></a><a name="p28038222716"></a>N/A</p> 31</td> 32</tr> 33<tr id="row880917225712"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p6803162212717"><a name="p6803162212717"></a><a name="p6803162212717"></a><netif name></p> 34</td> 35<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p980352211712"><a name="p980352211712"></a><a name="p980352211712"></a>Enables Dynamic Host Configuration Protocol (DHCP) for a network interface card (NIC).</p> 36</td> 37<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p48031822276"><a name="p48031822276"></a><a name="p48031822276"></a>NIC name, <strong id="b178511243205513"><a name="b178511243205513"></a><a name="b178511243205513"></a>eth0</strong></p> 38</td> 39</tr> 40<tr id="row78092222716"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p108032221379"><a name="p108032221379"></a><a name="p108032221379"></a>-x <netif name></p> 41</td> 42<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1180318222710"><a name="p1180318222710"></a><a name="p1180318222710"></a>Disables DHCP for a NIC.</p> 43</td> 44<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p78034222072"><a name="p78034222072"></a><a name="p78034222072"></a>NIC name, <strong id="b41988451673"><a name="b41988451673"></a><a name="b41988451673"></a>eth0</strong></p> 45</td> 46</tr> 47</tbody> 48</table> 49 50## Usage<a name="section15935131220717"></a> 51 52Run the following commands: 53 54- dhclient eth0 55- dhclient -x eth0 56 57## Example<a name="section79281818476"></a> 58 59Example 1: enabling DHCP for eth0 60 61``` 62OHOS:/$ dhclient eth0 63OHOS:/$ ifconfig 64lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1 65 ip6: ::1/64 66 HWaddr 00 MTU:0 Running Link UP 67eth0 ip:192.168.1.10 netmask:255.255.255.0 gateway:192.168.1.1 68 HWaddr 42:da:81:bc:58:94 MTU:1500 Running Default Link UP 69OHOS:/$ 70``` 71 72Example 2: disabling DHCP for eth0 73 74``` 75OHOS:/$ dhclient -x eth0 76NetifStatusCallback(eth0): nsc event: 0xf0 77OHOS:/$ ifconfig 78lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1 79 ip6: ::1/64 80 HWaddr 00 MTU:0 Running Link UP 81eth0 ip:0.0.0.0 netmask:0.0.0.0 gateway:0.0.0.0 82 HWaddr 42:da:81:bc:58:94 MTU:1500 Running Default Link UP 83``` 84 85