Community discussions

MikroTik App
 
divB
Member Candidate
Member Candidate
Topic Author
Posts: 102
Joined: Mon Jul 06, 2015 8:18 pm

How to predefine hostnames for DHCP leases?

Fri Aug 23, 2024 11:50 am

Normally one can define hostnames that are proposed/sent to the client. I thought this is "Client ID" but now my static leases got ignored: This seems to be a MATCHING field, along with the MAC address. So I have to leave that one empty. In my opinion, static leases should only match MAC address, but ok...

But now there is no field left to define a hostname. (DHCP host-name option). How can I define it for a static lease?
 
User avatar
karlisi
Member
Member
Posts: 478
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: How to predefine hostnames for DHCP leases?

Fri Aug 23, 2024 1:19 pm

You can't. Hostname dhcp server gets from client, not sends to it. Add comment to static lease if you need to identify it.
 
divB
Member Candidate
Member Candidate
Topic Author
Posts: 102
Joined: Mon Jul 06, 2015 8:18 pm

Re: How to predefine hostnames for DHCP leases?

Fri Aug 23, 2024 2:38 pm

:shock: :shock: :( :( :(

Crazy.
Every other DHCP server supports this.
Sad that RouterOS has to stand out
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12980
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to predefine hostnames for DHCP leases?

Fri Aug 23, 2024 2:41 pm

Every other DHCP server supports this.
If you say so...
 
User avatar
karlisi
Member
Member
Posts: 478
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: How to predefine hostnames for DHCP leases?

Mon Aug 26, 2024 8:55 am

Perhaps you mean option 012 hostname, it is supported
https://help.mikrotik.com/docs/display/ ... POptions.1
 
divB
Member Candidate
Member Candidate
Topic Author
Posts: 102
Joined: Mon Jul 06, 2015 8:18 pm

Re: How to predefine hostnames for DHCP leases?

Tue Aug 27, 2024 9:45 am

Thank you!

Options are a global setting ... how would I make the connection to the lease and and where would/could the hostname be stored?

The link mentions $(HOSTNAME) but to me it's unclear where the value of this variable actually comes from (and how it connects to a specific lease entry).

Or ... create one entry in options for each lease and then reference it?

Like:
/ip dhcp-server option
add code=12 force=yes name=hostname-iPad1 value="'iPad1'"
add code=12 force=yes name=hostname-iPad2 value="'iPad2'"

/ip dhcp-server lease
add address=192.168.1.101 comment=iPad1 dhcp-option=hostname-iPad1 mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server
add address=192.168.1.102 comment=iPad2 dhcp-option=hostname-iPad2 mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server
Is this what you mean?
 
User avatar
karlisi
Member
Member
Posts: 478
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: How to predefine hostnames for DHCP leases?

Tue Aug 27, 2024 1:33 pm

Never used this server-side, but should work
 
User avatar
infabo
Forum Guru
Forum Guru
Posts: 1656
Joined: Thu Nov 12, 2020 12:07 pm

Re: How to predefine hostnames for DHCP leases?

Tue Aug 27, 2024 3:09 pm

Every other DHCP server supports this.
If you say so...
At least some really widely used one support this indeed:

- ISC DHCP by using a "host" declaration - see https://kb.isc.org/docs/isc-dhcp-41-man ... -dhcpdconf
- dnsmasq by using the "dhcp-host" option. see https://linux.die.net/man/8/dnsmasq
- Microsoft DHCP server supports this as well AFAIK

Well. Maybe not "every other". But really widely used ones.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 13664
Joined: Thu Mar 03, 2016 10:23 pm

Re: How to predefine hostnames for DHCP leases?

Tue Aug 27, 2024 3:31 pm

At least some really widely used one support this indeed:

- ISC DHCP by using a "host" declaration - see https://kb.isc.org/docs/isc-dhcp-41-man ... -dhcpdconf
From the cited document:
It should be noted here that most DHCP clients completely ignore the host-name option sent by the DHCP server, and there is no way to configure them not to do this. So you generally have a choice of either not having any hostname to client IP address mapping that the client will recognize, or doing DNS updates. It is beyond the scope of this document to describe how to make this determination.

So this feature has very questionable benefit.
 
User avatar
infabo
Forum Guru
Forum Guru
Posts: 1656
Joined: Thu Nov 12, 2020 12:07 pm

Re: How to predefine hostnames for DHCP leases?

Tue Aug 27, 2024 4:08 pm

The link mentions $(HOSTNAME) but to me it's unclear where the value of this variable actually comes from (and how it connects to a specific lease entry).
It comes from the DHCP client.
 
ato
just joined
Posts: 1
Joined: Tue Oct 08, 2024 4:41 am

Re: How to predefine hostnames for DHCP leases?

Fri Nov 29, 2024 8:30 pm

So this feature has very questionable benefit.
Not at all. it is *very* usefull to dynamically booting diskless machines. I have been using it for years in my university lab with FreeBSD/Linux and Windows machines,
and dynamically registering these names in DNS.
 
jaclaz
Forum Guru
Forum Guru
Posts: 2623
Joined: Tue Oct 03, 2023 4:21 pm

Re: How to predefine hostnames for DHCP leases?

Fri Nov 29, 2024 11:33 pm

it is *very* usefull to dynamically booting diskless machines.
This.
I usually boot (dynamically) two or three diskless machines every day, just before breakfast.