mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-05-31 15:52:37 +00:00
Merge branch 'dhcp-to-dns' into next
This commit is contained in:
commit
c4db75112c
3 changed files with 35 additions and 7 deletions
|
|
@ -23,6 +23,7 @@ for details!
|
|||
* [Ignacio Serrano](mailto:ignic@ignic.com) (@ignic)
|
||||
* [Ilya Kulakov](mailto:kulakov.ilya@gmail.com) (@Kentzo)
|
||||
* [Leonardo David Monteiro](mailto:leo@cub3.xyz) (@leosfsm)
|
||||
* [Łukasz Witkowski](mailto:witul@skyhost.pl) (@witul)
|
||||
* [Michael Gisbers](mailto:michael@gisbers.de) (@mgisbers)
|
||||
* [Miquel Bonastre](mailto:mbonastre@yahoo.com) (@mbonastre)
|
||||
* @netravnen
|
||||
|
|
|
|||
|
|
@ -66,25 +66,33 @@
|
|||
$LogPrint debug $ScriptName ("A lease just vanished, ignoring.");
|
||||
:continue;
|
||||
}
|
||||
:local LeaseInfo [ $ParseKeyValueStore ($LeaseVal->"comment") ];
|
||||
|
||||
:if ([ :len ($LeaseVal->"active-address") ] = 0) do={
|
||||
$LogPrint debug $ScriptName ("No address available... Ignoring.");
|
||||
:continue;
|
||||
}
|
||||
|
||||
:local Comment ($CommentPrefix . ", macaddress=" . $LeaseVal->"active-mac-address" . ", server=" . $LeaseVal->"server");
|
||||
:local MacDash [ $CleanName ($LeaseVal->"active-mac-address") ];
|
||||
:local HostName [ $CleanName [ $EitherOr ([ $ParseKeyValueStore ($LeaseVal->"comment") ]->"hostname") ($LeaseVal->"host-name") ] ];
|
||||
:local Network [ /ip/dhcp-server/network/find where ($LeaseVal->"active-address") in address ];
|
||||
:local NetworkVal;
|
||||
:if ([ :len $Network ] > 0) do={
|
||||
:set NetworkVal [ /ip/dhcp-server/network/get ($Network->0) ];
|
||||
}
|
||||
:local NetworkInfo [ $ParseKeyValueStore ($NetworkVal->"comment") ];
|
||||
|
||||
:if ($LeaseInfo->"dns-ignore" = true || $NetworkInfo->"dns-ignore" = true) do={
|
||||
$LogPrint debug $ScriptName ("Lease for " . $LeaseVal->"active-mac-address" . " is ignored... Skipping.");
|
||||
:continue;
|
||||
}
|
||||
|
||||
:local Comment ($CommentPrefix . ", macaddress=" . $LeaseVal->"active-mac-address" . ", server=" . $LeaseVal->"server");
|
||||
:local MacDash [ $CleanName ($LeaseVal->"active-mac-address") ];
|
||||
:local HostName [ $CleanName [ $EitherOr ($LeaseInfo->"hostname") ($LeaseVal->"host-name") ] ];
|
||||
:local NetDomain ([ $IfThenElse ([ :len ($NetworkInfo->"name-extra") ] > 0) ($NetworkInfo->"name-extra" . ".") ] . \
|
||||
[ $EitherOr [ $EitherOr ($NetworkInfo->"domain") ($NetworkVal->"domain") ] $Domain ]);
|
||||
:local FullA ($MacDash . "." . $NetDomain);
|
||||
:local FullCN ($HostName . "." . $NetDomain);
|
||||
:local FullA [ :convert transform=lc ($MacDash . "." . $NetDomain) ];
|
||||
:local CNameDomain [ $EitherOr ($LeaseInfo->"cname-domain") ($NetworkInfo->"cname-domain") ];
|
||||
:local FullCN [ :convert transform=lc ($HostName . "." . [ $EitherOr $CNameDomain $NetDomain ]) ];
|
||||
:local MacInServer ($LeaseVal->"active-mac-address" . " in " . $LeaseVal->"server");
|
||||
|
||||
:local DnsRecord [ /ip/dns/static/find where comment=$Comment type=A ];
|
||||
|
|
|
|||
|
|
@ -50,8 +50,14 @@ A bound lease for mac address `00:11:22:33:44:55` with ip address
|
|||
`10.0.0.50` would result in an A record `00-11-22-33-44-55.example.com`
|
||||
pointing to the given ip address.
|
||||
|
||||
Additional options can be given from comment, to add an extra level in
|
||||
dns name or define a different domain.
|
||||
Additional options can be given from comment, first of all you can opt-out
|
||||
for specific networks:
|
||||
|
||||
/ip/dhcp-server/network/add address=10.0.0.0/24 domain=example.com comment="dns-ignore=true";
|
||||
|
||||
The same can be done for a specific lease with its comment.
|
||||
|
||||
Use this to add an extra level in dns name or define a different domain.
|
||||
|
||||
/ip/dhcp-server/network/add address=10.0.0.0/24 domain=example.com comment="domain=another-domain.com, name-extra=dhcp";
|
||||
|
||||
|
|
@ -80,6 +86,19 @@ Note this information can be configured in wireless access list with
|
|||
then due to script execution order. Decrease the scheduler interval to
|
||||
reduce the effect.
|
||||
|
||||
### Override domain for CNAME records
|
||||
|
||||
By default both the A record (based on mac address) and the CNAME record
|
||||
(based on host name) use the same domain. You can set a different domain
|
||||
for CNAME records with `cname-domain=` in network comment:
|
||||
|
||||
/ip/dhcp-server/network/add address=10.0.0.0/24 domain=dhcp.example.com comment="cname-domain=example.com";
|
||||
|
||||
Adding `cname-domain=` in lease comment has even higher priority:
|
||||
|
||||
/ip/dhcp-server/lease/add address=10.0.0.50 comment="cname-domain=example.com" mac-address=00:11:22:33:44:55 server=dhcp;
|
||||
|
||||
|
||||
Frequently asked questions
|
||||
--------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue