DHCP Client, Relay and Server · Topic 2 of 5

DHCP Client

Learn how to configure the RouterOS DHCP client: default route, peer DNS and NTP, client identification by host name and client id, status and renew.

  • 5 min
In a nutshell
  • The client is configured in /ip dhcp-client, one entry per interface.
  • It adds a dynamic address, a default route and dynamic DNS servers.
  • add-default-route and default-route-distance control the route that is added.

What it is

The DHCP client lets the router take its address and settings from a DHCP server, usually the internet provider.

It is the common way to set up a WAN port. The router sends a Discover, and the provider answers with an address, a gateway and DNS servers. RouterOS then applies those settings automatically.

RouterDHCP client on ether1Provider serversends a leaseRouteradds address, route and DNS

The settings are in /ip dhcp-client.

How it works

You create a client on an interface, and the router handles the rest.

Basic configuration

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

Once the lease is accepted, the router shows the result in the print output and in other menus. The address appears in /ip address as a dynamic entry. A default route appears in /ip route and DNS servers appear as dynamic servers in /ip dns.

What the client applies

Several parameters decide which parts of the lease the router uses.

ParameterEffect
add-default-routeAdd a default route using the gateway from the server
default-route-distanceThe distance given to that default route
use-peer-dnsUse the DNS servers from the server
use-peer-ntpUse the NTP servers from the server
/ip dhcp-client add interface=ether1 add-default-route=yes use-peer-dns=no use-peer-ntp=no

With use-peer-dns=no, the router ignores the provider DNS. This is useful when you use your own servers, as set in the DNS chapter.

A larger default-route-distance makes the route less preferred. This allows a second WAN to act as a backup. In that setup, the main link has a lower distance, so it is used while it is up.

Client identification

A server may identify a client by its hardware address, by a client identifier, or by its host name. The client can send these in the Discover and Request messages.

ItemWhat it is
Client identifierAn option that identifies the client to the server, often built from its MAC address
Host nameThe router name, sent so that the server can record it

The parameter dhcp-options decides which of these the client sends. The common values are hostname and clientid.

/ip dhcp-client set 0 dhcp-options=hostname,clientid

The provider often ties a lease to the client identity. If you replace a router, the new device has a different MAC address, so it may not get the same address.

Some providers need the old identity. You may then change the identity the client sends, or ask the provider to update its record.

Exam tip

If a replaced router does not get an address from the provider, check whether the provider binds leases to the client identity. This is a common cause of silence after a hardware change.

Status

The print output shows a status for each client.

StatusMeaning
searchingThe client sends Discover and waits for an Offer
requestingThe client has an offer and sent a Request
boundThe lease is active
renewingThe client is renewing the lease with the server
rebindingRenewal failed, so the client asks any server
stopped, errorThe client is disabled or has a problem

A client stuck in searching means no server answered. Check the cable, the interface and any filter on the path.

Renew and release

You can ask for a new lease at any time.

/ip dhcp-client renew 0
/ip dhcp-client release 0

renew asks the server again, and release gives the lease back. These are useful when you change something at the provider and want the router to pick up the change.

Firewall and masquerade

A router with a DHCP client on the WAN still needs NAT and filter rules. The client only supplies the address. A masquerade rule on the WAN interface suits this case well, because the address can change.

LAN hostprivate addressRoutermasquerade on WANProvidersees the lease address

What to remember for the exam

Seven facts cover most questions on this topic.

  • The client is configured in /ip dhcp-client, one entry per interface.
  • It adds a dynamic address, a default route and dynamic DNS servers.
  • add-default-route and default-route-distance control the route that is added.
  • use-peer-dns and use-peer-ntp decide whether to use the server settings.
  • dhcp-options selects whether the host name and client identifier are sent.
  • The status values include searching, requesting, bound, renewing and rebinding.
  • renew and release control the lease by hand.
Watch out

The address and route from a DHCP client are dynamic. They disappear when the lease ends or the client is disabled.

Common mistakes

These four mistakes appear often.

Forgetting masquerade. The client gives an address, but LAN hosts still need NAT to reach the internet.

Keeping peer DNS when you use your own servers. Set use-peer-dns=no so the provider servers do not mix in.

Replacing a router without checking identity. The provider may tie the lease to the old client identity.

Reading searching as a fault in the client. It usually means no server answered, so check the link first.

Check yourself

Work through these three questions.

  • Which setting stops the router using the provider DNS servers?

    use-peer-dns=no on the DHCP client.

  • What does a status of bound mean?

    The lease is active and the router is using the address it received.

  • Why might a replaced router fail to get an address from a provider?

    The provider may tie the lease to the client identity, which changes with the hardware address.

Topic 2 of 5 in DHCP Client, Relay and Server

Test yourself on DHCP Client, Relay and Server

The full MikroTik MTCTCE question bank has 479 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by MikroTik. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.