Manual:IP/DHCP Client: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 29: Line 29:




<table class="styled_table">
{{Mr-arg-table-h
<tr>
|prop=Property
  <th width="40%">Property</th>
|desc=Description
  <th >Description</th>
}}
</tr>
 
<tr>
{{Mr-arg-table
    <td><var><b>add-default-route</b></var> (<em>yes | no</em>; Default: <b>yes</b>)</td>
|arg=add-default-route
    <td>Whether to install default route in routing table received from dhcp server.</td>
|type=yes {{!}} no
</tr>
|default=yes
<tr>
|desc=Whether to install default route in routing table received from dhcp server.
    <td><var><b>client-id</b></var> (<em>string</em>; Default: <b></b>)</td>
}}
    <td>Corresponds to the settings suggested by the network administrator or ISP. If not specified, client's MAC address will be sent.</td>
 
</tr>
{{Mr-arg-table
<tr>
|arg=client-id
    <td><var><b>default-route-distance</b></var> (<em>integer:0..255</em>; Default: <b></b>)</td>
|type=string
    <td>Distance of default route. Applicable if <code>add-default-route</code> is set to <code>yes</code>.</td>
|default=
</tr>
|desc=Corresponds to the settings suggested by the network administrator or ISP. If not specified, client's MAC address will be sent
<tr>
}}
    <td><var><b>host-name</b></var> (<em>string</em>; Default: <b></b>)</td>
 
    <td>Tthe host name of the client sent to a DHCP server. If not specified, client's system identity will be used.</td>
{{Mr-arg-table
</tr>
|arg=default-route-distance
<tr>
|type=integer:0..255
    <td><var><b>interface</b></var> (<em>name</em>; Default: <b></b>)</td>
|default=
    <td>Interface on which DHCP client will be running.</td>
|desc=Distance of default route. Applicable if <code>add-default-route</code> is set to <code>yes</code>.
</tr>
}}
<tr>
 
    <td><var><b>use-peer-dns</b></var> (<em>yes | no</em>; Default: <b>yes</b>)</td>
{{Mr-arg-table
    <td>Whether to accept the [[DNS]] settings advertised by [[DHCP Server]]. (Will override the settings put in the <code>/ip dns</code> submenu</td>
|arg=host-name
</tr>
|type=string
<tr>
|default=
    <td><var><b>use-peer-ntp</b></var> (<em>yes | no</em>; Default: <b>yes</b>)</td>
|desc=Host name of the client sent to a DHCP server. If not specified, client's system identity will be used.
    <td>Whether to accept the [[Time#NTP_client_and_server| NTP]] settings advertised by [[DHCP Server]]. (Will override the settings put in the <code>/system ntp client</code> submenu)</td>
}}
</tr>
 
</table>
{{Mr-arg-table
<br />
|arg=interface
|type=string
|default=
|desc=Interface on which DHCP client will be running.
}}
 
{{Mr-arg-table
|arg=use-peer-dns
|type=yes {{!}} no
|default=yes
|desc=Whether to accept the [[M:IP/DNS | DNS]] settings advertised by [[M:IP/DHCP Server | DHCP Server]]. (Will override the settings put in the <code>/ip dns</code> submenu.
}}
 
{{Mr-arg-table-end
|arg=use-peer-ntp
|type=yes {{!}} no
|default=yes
|desc=Whether to accept the [[M:System/Time#NTP_client_and_server| NTP]] settings advertised by [[M:IP/DHCP Server | DHCP Server]]. (Will override the settings put in the <code>/system ntp client</code> submenu)
}}
 


==Status==
==Status==
Line 70: Line 89:




<table class="styled_table">
{{Mr-arg-table-h
<tr>
|prop=Property
  <th width="40%">Property</th>
|desc=Description
  <th >Description</th>
}}
</tr>
 
<tr>
{{Mr-arg-ro-table
    <td><var><b>address</b></var> (<em>IP/mask</em>)</td>
|arg=address
    <td>IP address and netmask, which is assigned to DHCP Client from the Server</td>
|type=IP/Netmask
</tr>
|desc=IP address and netmask, which is assigned to DHCP Client from the Server
<tr>
}}
    <td><var><b>dhcp-server</b></var> (<em>IP</em>)</td>
 
    <td>IP address of the DHCP server</td>
{{Mr-arg-ro-table
</tr>
|arg=dhcp-server
<tr>
|type=IP
    <td><var><b>expires-after</b></var> (<em>time</em>)</td>
|desc=IP address of the DHCP server.
    <td>Time, when the lease expires (specified by the DHCP server)</td>
}}
</tr>
 
<tr>
{{Mr-arg-ro-table
    <td><var><b>gateway</b></var> (<em>IP</em>)</td>
|arg=expires-after
    <td>IP address of the gateway which is assigned by DHCP server</td>
|type=time
</tr>
|desc=Time when the lease expires (specified by the DHCP server).
<tr>
}}
    <td><var><b>invalid</b></var> (<em>yes | no</em>)</td>
 
    <td>Shows whether configuration is invalid.</td>
{{Mr-arg-ro-table
</tr>
|arg=gateway
<tr>
|type=IP
    <td><var><b>netmask</b></var> (<em>IP</em>)</td>
|desc=IP address of the gateway which is assigned by DHCP server
    <td></td>
}}
</tr>
 
<tr>
{{Mr-arg-ro-table
    <td><var><b>primary-dns</b></var> (<em>IP</em>)</td>
|arg=invalid
    <td>IP address of the primary DNS server, assigned by the DHCP server</td>
|type=yes {{!}} no
</tr>
|desc=Shows whether configuration is invalid.
<tr>
}}
    <td><var><b>primary-ntp</b></var> (<em>IP</em>)</td>
 
    <td>IP address of the primary NTP server, assigned by the DHCP server</td>
{{Mr-arg-ro-table
</tr>
|arg=netmask
<tr>
|type=IP
    <td><var><b>secondary-dns</b></var> (<em>IP</em>)</td>
|desc=
    <td>IP address of the secondary DNS server, assigned by the DHCP server</td>
}}
</tr>
 
<tr>
{{Mr-arg-ro-table
    <td><var><b>secondary-ntp</b></var> (<em>IP</em>)</td>
|arg=primary-dns
    <td>IP address of the secondary NTP server, assigned by the DHCP server</td>
|type=IP
</tr>
|desc=IP address of the primary DNS server, assigned by the DHCP server
<tr>
}}
    <td><var><b>status</b></var> (<em>bound | error | rebinding... | requesting... | searching... | stopped</em>)</td>
 
    <td>Shows the status of DHCP Client</td>
{{Mr-arg-ro-table
</tr>
|arg=primary-ntp
|type=IP
|desc=IP address of the primary NTP server, assigned by the DHCP server
}}


</table>
{{Mr-arg-ro-table
|arg=secondary-dns
|type=IP
|desc=IP address of the secondary DNS server, assigned by the DHCP server
}}
 
{{Mr-arg-ro-table
|arg=secondary-ntp
|type=IP
|desc=IP address of the secondary NTP server, assigned by the DHCP server
}}
 
{{Mr-arg-ro-table-end
|arg=status
|type=bound {{!}} error {{!}} rebinding... {{!}} requesting... {{!}} searching... {{!}} stopped
|desc=Shows the status of DHCP Client
}}




Line 126: Line 164:
==Menu specific commands==
==Menu specific commands==


<table class="styled_table">
{{Mr-arg-table-h
<tr>
|prop=Property
  <th width="40%">Property</th>
|desc=Description
  <th >Description</th>
}}
</tr>
 
<tr>
{{Mr-arg-ro-table
    <td><var><b>release</b></var> (<em>id</em>)</td>
|arg=release
    <td>Release current binding and restart DHCP client</td>
|type=numbers
</tr>
|desc=Release current binding and restart DHCP client
<tr>
}}
    <td><var><b>renew</b></var> (<em>id</em>)</td>
 
    <td>Renew current leases. If the renew operation was not successful, client tries to reinitialize lease (i.e. it starts lease request procedure (rebind) as if it had not received an IP address yet)</td>
{{Mr-arg-ro-table-end
</tr>
|arg=renew
</table>
|type=numbers
|desc=Renew current leases. If the renew operation was not successful, client tries to reinitialize lease (i.e. it starts lease request procedure (rebind) as if it had not received an IP address yet)
}}





Revision as of 13:18, 10 January 2011

Applies to RouterOS: v3, v4 +

Summary

The MikroTik RouterOS DHCP client may be enabled on any Ethernet-like interface at a time. The client will accept an address, netmask, default gateway, and two dns server addresses. The received IP address will be added to the interface with the respective netmask. The default gateway will be added to the routing table as a dynamic entry. Should the DHCP client be disabled or not renew an address, the dynamic default route will be removed. If there is already a default route installed prior the DHCP client obtains one, the route obtained by the DHCP client would be shown as invalid.

Quick setup example

Add a DHCP client on ether1 interface:

/ip dhcp-client add interface=ether1 disabled=no

After interface is added, you can use rint" or "print detail" command to see what parameters DHCP client acquired:

[admin@MikroTik] ip dhcp-client> print detail
Flags: X - disabled, I - invalid 
 0   interface=ether1 add-default-route=yes use-peer-dns=yes use-peer-ntp=yes
     status=bound address=192.168.0.65/24 gateway=192.168.0.1
     dhcp-server=192.168.0.1 primary-dns=192.168.0.1 primary-ntp=192.168.0.1
     expires-after=9m44s 
[admin@MikroTik] ip dhcp-client>


Properties

Sub-menu: /ip dhcp-client


Property Description
add-default-route (yes | no; Default: yes) Whether to install default route in routing table received from dhcp server.
client-id (string; Default: ) Corresponds to the settings suggested by the network administrator or ISP. If not specified, client's MAC address will be sent
default-route-distance (integer:0..255; Default: ) Distance of default route. Applicable if add-default-route is set to yes.
host-name (string; Default: ) Host name of the client sent to a DHCP server. If not specified, client's system identity will be used.
interface (string; Default: ) Interface on which DHCP client will be running.
use-peer-dns (yes | no; Default: yes) Whether to accept the DNS settings advertised by DHCP Server. (Will override the settings put in the /ip dns submenu.
use-peer-ntp (yes | no; Default: yes) Whether to accept the NTP settings advertised by DHCP Server. (Will override the settings put in the /system ntp client submenu)


Status

Command /ip dhcp-client print detail will show current status of dhcp client and read-only properties listed in table below:


Property Description
address (IP/Netmask) IP address and netmask, which is assigned to DHCP Client from the Server
dhcp-server (IP) IP address of the DHCP server.
expires-after (time) Time when the lease expires (specified by the DHCP server).
gateway (IP) IP address of the gateway which is assigned by DHCP server
invalid (yes | no) Shows whether configuration is invalid.
netmask (IP)
primary-dns (IP) IP address of the primary DNS server, assigned by the DHCP server
primary-ntp (IP) IP address of the primary NTP server, assigned by the DHCP server
secondary-dns (IP) IP address of the secondary DNS server, assigned by the DHCP server
secondary-ntp (IP) IP address of the secondary NTP server, assigned by the DHCP server
status (bound | error | rebinding... | requesting... | searching... | stopped) Shows the status of DHCP Client


Menu specific commands

Property Description
release (numbers) Release current binding and restart DHCP client
renew (numbers) Renew current leases. If the renew operation was not successful, client tries to reinitialize lease (i.e. it starts lease request procedure (rebind) as if it had not received an IP address yet)


[ Top | Back to Content ]