Log host identifier

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Log host identifier

Narcis Garcia
isc-dhcp-server is currently logging in my system:
DHCPDISCOVER from 11:22:33:44:55:66 via eth0
DHCPOFFER on 172.16.20.201 to 11:22:33:44:55:66 via eth0
DHCPREQUEST for 172.16.20.201 from 11:22:33:44:55:66 via eth0
DHCPACK on 172.16.20.201 to 11:22:33:44:55:66 via eth0

How can I make the service logs some name about that known client? (such
as "printer_1")

Thanks.
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Log host identifier

Bill Shirley-2
Add logging to your dhcpd.conf.  Here is what I use:
on commit {
    if static {
        set is-static = " --> STATIC";

        option dhcp-renewal-time    = encode-int(43200 / 2, 32);    # 43200 = 12 hours
        option dhcp-rebinding-time    = encode-int(43200 * 7 / 8, 32);
        ddns-ttl            = encode-int((43200 / 2) + 1, 32);
    } else {
        set is-static = "";

        option dhcp-renewal-time    = encode-int(lease-time / 2, 32);
        option dhcp-rebinding-time    = encode-int(lease-time * 7 / 8, 32);
        ddns-ttl            = encode-int((lease-time / 2) + 1, 32);
    }

    log (   info,
        concat (
            "Host:", pick-first-value(option fqdn.hostname, option host-name, "(none)"), "=>", pick-first-value(config-option server.ddns-hostname, "(none)")

            ,"  VendorId:", pick-first-value(option vendor-class-identifier, "(none)")

            ,"  Lease:", pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)), "(none)")
            ,"  Renewal:", pick-first-value(binary-to-ascii(10, 32, "", config-option dhcp-renewal-time), "(none)")
            ,"  Rebind:", pick-first-value(binary-to-ascii(10, 32, "", config-option dhcp-rebinding-time), "(none)")

            ,"  TTL:", pick-first-value(binary-to-ascii(10, 32, "", config-option server.ddns-ttl), "(none)")

            ,"  GIaddr:", pick-first-value(binary-to-ascii(10, 8, ".", packet(24,4)), "(none)")
            , is-static
        )
    );
}

Bill


On 10/19/2017 3:00 AM, Narcis Garcia wrote:
isc-dhcp-server is currently logging in my system:
DHCPDISCOVER from 11:22:33:44:55:66 via eth0
DHCPOFFER on 172.16.20.201 to 11:22:33:44:55:66 via eth0
DHCPREQUEST for 172.16.20.201 from 11:22:33:44:55:66 via eth0
DHCPACK on 172.16.20.201 to 11:22:33:44:55:66 via eth0

How can I make the service logs some name about that known client? (such
as "printer_1")

Thanks.
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Log host identifier

Narcis Garcia
Thank you;

Is there some way to get the label of the host definition instead of
having to add a hostname/fqdn/identifier to each host?

(such as "printer_1" here)

host printer_1 {
        hardware ethernet 00:11:22:33:44:55;
        fixed-address 172.16.20.201;
}


El 19/10/17 a les 09:12, Bill Shirley ha escrit:

> Add logging to your dhcpd.conf.  Here is what I use:
> on commit {
>     if static {
>         set is-static = " --> STATIC";
>
>         option dhcp-renewal-time    = encode-int(43200 / 2, 32);    #
> 43200 = 12 hours
>         option dhcp-rebinding-time    = encode-int(43200 * 7 / 8, 32);
>         ddns-ttl            = encode-int((43200 / 2) + 1, 32);
>     } else {
>         set is-static = "";
>
>         option dhcp-renewal-time    = encode-int(lease-time / 2, 32);
>         option dhcp-rebinding-time    = encode-int(lease-time * 7 / 8, 32);
>         ddns-ttl            = encode-int((lease-time / 2) + 1, 32);
>     }
>
>     log (   info,
>         concat (
>             "Host:", pick-first-value(option fqdn.hostname, option
> host-name, "(none)"), "=>", pick-first-value(config-option
> server.ddns-hostname, "(none)")
>
>             ,"  VendorId:", pick-first-value(option
> vendor-class-identifier, "(none)")
>
>             ,"  Lease:",
> pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)),
> "(none)")
>             ,"  Renewal:", pick-first-value(binary-to-ascii(10, 32, "",
> config-option dhcp-renewal-time), "(none)")
>             ,"  Rebind:", pick-first-value(binary-to-ascii(10, 32, "",
> config-option dhcp-rebinding-time), "(none)")
>
>             ,"  TTL:", pick-first-value(binary-to-ascii(10, 32, "",
> config-option server.ddns-ttl), "(none)")
>
>             ,"  GIaddr:", pick-first-value(binary-to-ascii(10, 8, ".",
> packet(24,4)), "(none)")
>             , is-static
>         )
>     );
> }
>
> Bill
>
>
> On 10/19/2017 3:00 AM, Narcis Garcia wrote:
>> isc-dhcp-server is currently logging in my system:
>> DHCPDISCOVER from 11:22:33:44:55:66 via eth0
>> DHCPOFFER on 172.16.20.201 to 11:22:33:44:55:66 via eth0
>> DHCPREQUEST for 172.16.20.201 from 11:22:33:44:55:66 via eth0
>> DHCPACK on 172.16.20.201 to 11:22:33:44:55:66 via eth0
>>
>> How can I make the service logs some name about that known client? (such
>> as "printer_1")
>>
>> Thanks.
>> _______________________________________________
>> dhcp-users mailing list
>> [hidden email]
>> https://lists.isc.org/mailman/listinfo/dhcp-users
>
>
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users
>
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Log host identifier

Narcis Garcia

Okay, I've solved with your example, dhcp-eval manpage, and Glenn Satchell's AA-01039 answer in ISC:

on commit {
        if static {
                set KnownHost = pick-first-value(host-decl-name, "(none)");
        } else {
                set KnownHost = "(dynamic)";
        }
        set MacString = concat(
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
        );

        log(info, concat(
                "KnownHost:", KnownHost
                ," ClientHostname:", pick-first-value(option fqdn.hostname, option host-name, config-option server.ddns-hostname, "(none)")
                ," MAC:", MacString
                ," leased-address:", pick-first-value( binary-to-ascii(10, 8, ".", leased-address), "(none)")
                ," lease-time:", pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)), "(none)")
        ));
}


El 19/10/17 a les 09:27, Narcis Garcia ha escrit:
Thank you;

Is there some way to get the label of the host definition instead of
having to add a hostname/fqdn/identifier to each host?

(such as "printer_1" here)

host printer_1 {
	hardware ethernet 00:11:22:33:44:55;
	fixed-address 172.16.20.201;
}


El 19/10/17 a les 09:12, Bill Shirley ha escrit:
Add logging to your dhcpd.conf.  Here is what I use:
on commit {
    if static {
        set is-static = " --> STATIC";

        option dhcp-renewal-time    = encode-int(43200 / 2, 32);    #
43200 = 12 hours
        option dhcp-rebinding-time    = encode-int(43200 * 7 / 8, 32);
        ddns-ttl            = encode-int((43200 / 2) + 1, 32);
    } else {
        set is-static = "";

        option dhcp-renewal-time    = encode-int(lease-time / 2, 32);
        option dhcp-rebinding-time    = encode-int(lease-time * 7 / 8, 32);
        ddns-ttl            = encode-int((lease-time / 2) + 1, 32);
    }

    log (   info,
        concat (
            "Host:", pick-first-value(option fqdn.hostname, option
host-name, "(none)"), "=>", pick-first-value(config-option
server.ddns-hostname, "(none)")

            ,"  VendorId:", pick-first-value(option
vendor-class-identifier, "(none)")

            ,"  Lease:",
pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)),
"(none)")
            ,"  Renewal:", pick-first-value(binary-to-ascii(10, 32, "",
config-option dhcp-renewal-time), "(none)")
            ,"  Rebind:", pick-first-value(binary-to-ascii(10, 32, "",
config-option dhcp-rebinding-time), "(none)")

            ,"  TTL:", pick-first-value(binary-to-ascii(10, 32, "",
config-option server.ddns-ttl), "(none)")

            ,"  GIaddr:", pick-first-value(binary-to-ascii(10, 8, ".",
packet(24,4)), "(none)")
            , is-static
        )
    );
}

Bill


On 10/19/2017 3:00 AM, Narcis Garcia wrote:
isc-dhcp-server is currently logging in my system:
DHCPDISCOVER from 11:22:33:44:55:66 via eth0
DHCPOFFER on 172.16.20.201 to 11:22:33:44:55:66 via eth0
DHCPREQUEST for 172.16.20.201 from 11:22:33:44:55:66 via eth0
DHCPACK on 172.16.20.201 to 11:22:33:44:55:66 via eth0

How can I make the service logs some name about that known client? (such
as "printer_1")

Thanks.
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Log host identifier

Bill Shirley-2
I think you're confused. A  "known host" is any host that is defined.  It
can be static or dynamic.  Consider:
host printer_1 {
    hardware ethernet 00:11:22:33:44:55;
    fixed-address 172.16.20.201;
}
host printer_2 {
    hardware ethernet 11:22:33:44:55:66;
}
printer_1 will get a static address; printer_2 will get dynamic; both are
known hosts because they are defined. MAC address 22:33:44:55:66:77
is not defined in the dhcpd.conf and therefore is an "unknown-client".

HTH,
Bill


On 10/19/2017 5:26 AM, Narcis Garcia wrote:

Okay, I've solved with your example, dhcp-eval manpage, and Glenn Satchell's AA-01039 answer in ISC:

on commit {
        if static {
                set KnownHost = pick-first-value(host-decl-name, "(none)");
        } else {
                set KnownHost = "(dynamic)";
        }
        set MacString = concat(

                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",

                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
                suffix(concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
        );

        log(info, concat(
                "KnownHost:", KnownHost
                ," ClientHostname:", pick-first-value(option fqdn.hostname, option host-name, config-option server.ddns-hostname, "(none)")
                ," MAC:", MacString
                ," leased-address:", pick-first-value( binary-to-ascii(10, 8, ".", leased-address), "(none)")
                ," lease-time:", pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)), "(none)")
        ));
}



El 19/10/17 a les 09:27, Narcis Garcia ha escrit:
Thank you;

Is there some way to get the label of the host definition instead of
having to add a hostname/fqdn/identifier to each host?

(such as "printer_1" here)

host printer_1 {
	hardware ethernet 00:11:22:33:44:55;
	fixed-address 172.16.20.201;
}


El 19/10/17 a les 09:12, Bill Shirley ha escrit:
Add logging to your dhcpd.conf.  Here is what I use:
on commit {
    if static {
        set is-static = " --> STATIC";

        option dhcp-renewal-time    = encode-int(43200 / 2, 32);    #
43200 = 12 hours
        option dhcp-rebinding-time    = encode-int(43200 * 7 / 8, 32);
        ddns-ttl            = encode-int((43200 / 2) + 1, 32);
    } else {
        set is-static = "";

        option dhcp-renewal-time    = encode-int(lease-time / 2, 32);
        option dhcp-rebinding-time    = encode-int(lease-time * 7 / 8, 32);
        ddns-ttl            = encode-int((lease-time / 2) + 1, 32);
    }

    log (   info,
        concat (
            "Host:", pick-first-value(option fqdn.hostname, option
host-name, "(none)"), "=>", pick-first-value(config-option
server.ddns-hostname, "(none)")

            ,"  VendorId:", pick-first-value(option
vendor-class-identifier, "(none)")

            ,"  Lease:",
pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)),
"(none)")
            ,"  Renewal:", pick-first-value(binary-to-ascii(10, 32, "",
config-option dhcp-renewal-time), "(none)")
            ,"  Rebind:", pick-first-value(binary-to-ascii(10, 32, "",
config-option dhcp-rebinding-time), "(none)")

            ,"  TTL:", pick-first-value(binary-to-ascii(10, 32, "",
config-option server.ddns-ttl), "(none)")

            ,"  GIaddr:", pick-first-value(binary-to-ascii(10, 8, ".",
packet(24,4)), "(none)")
            , is-static
        )
    );
}

Bill


On 10/19/2017 3:00 AM, Narcis Garcia wrote:
isc-dhcp-server is currently logging in my system:
DHCPDISCOVER from 11:22:33:44:55:66 via eth0
DHCPOFFER on 172.16.20.201 to 11:22:33:44:55:66 via eth0
DHCPREQUEST for 172.16.20.201 from 11:22:33:44:55:66 via eth0
DHCPACK on 172.16.20.201 to 11:22:33:44:55:66 via eth0

How can I make the service logs some name about that known client? (such
as "printer_1")

Thanks.
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users



_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Log host identifier

Narcis Garcia
Better this:

if static {
        set KnownHost = pick-first-value(host-decl-name, "(static)");
} else {
        set KnownHost = pick-first-value(host-decl-name, "(dynamic)");
}

Thanks.


El 19/10/17 a les 18:37, Bill Shirley ha escrit:

> I think you're confused. A  "known host" is any host that is defined.  It
> can be static or dynamic.  Consider:
> host printer_1 {
>     hardware ethernet 00:11:22:33:44:55;
>     fixed-address 172.16.20.201;
> }
> host printer_2 {
>     hardware ethernet 11:22:33:44:55:66;
> }
> printer_1 will get a static address; printer_2 will get dynamic; both are
> known hosts because they are defined. MAC address 22:33:44:55:66:77
> is not defined in the dhcpd.conf and therefore is an "unknown-client".
>
> HTH,
> Bill
>
>
> On 10/19/2017 5:26 AM, Narcis Garcia wrote:
>>
>> Okay, I've solved with your example, dhcp-eval manpage, and Glenn
>> Satchell's AA-01039 answer in ISC*:*
>>
>> on commit {
>>         if static {
>>                 set KnownHost = pick-first-value(host-decl-name,
>> "(none)");
>>         } else {
>>                 set KnownHost = "(dynamic)";
>>         }
>>         set MacString = concat(
>>
>>                 suffix(concat ("0", binary-to-ascii (16, 8, "",
>> substring(hardware,1,1))),2), ":",
>>
>>                 suffix(concat ("0", binary-to-ascii (16, 8, "",
>> substring(hardware,2,1))),2), ":",
>>                 suffix(concat ("0", binary-to-ascii (16, 8, "",
>> substring(hardware,3,1))),2), ":",
>>                 suffix(concat ("0", binary-to-ascii (16, 8, "",
>> substring(hardware,4,1))),2), ":",
>>                 suffix(concat ("0", binary-to-ascii (16, 8, "",
>> substring(hardware,5,1))),2), ":",
>>                 suffix(concat ("0", binary-to-ascii (16, 8, "",
>> substring(hardware,6,1))),2)
>>         );
>>
>>         log(info, concat(
>>                 "KnownHost:", KnownHost
>>                 ," ClientHostname:", pick-first-value(option
>> fqdn.hostname, option host-name, config-option server.ddns-hostname,
>> "(none)")
>>                 ," MAC:", MacString
>>                 ," leased-address:", pick-first-value(
>> binary-to-ascii(10, 8, ".", leased-address), "(none)")
>>                 ," lease-time:",
>> pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)),
>> "(none)")
>>         ));
>> }
>>
>>
>>
>> El 19/10/17 a les 09:27, Narcis Garcia ha escrit:
>>> Thank you;
>>>
>>> Is there some way to get the label of the host definition instead of
>>> having to add a hostname/fqdn/identifier to each host?
>>>
>>> (such as "printer_1" here)
>>>
>>> host printer_1 {
>>> hardware ethernet 00:11:22:33:44:55;
>>> fixed-address 172.16.20.201;
>>> }
>>>
>>>
>>> El 19/10/17 a les 09:12, Bill Shirley ha escrit:
>>>> Add logging to your dhcpd.conf.  Here is what I use:
>>>> on commit {
>>>>     if static {
>>>>         set is-static = " --> STATIC";
>>>>
>>>>         option dhcp-renewal-time    = encode-int(43200 / 2, 32);    #
>>>> 43200 = 12 hours
>>>>         option dhcp-rebinding-time    = encode-int(43200 * 7 / 8, 32);
>>>>         ddns-ttl            = encode-int((43200 / 2) + 1, 32);
>>>>     } else {
>>>>         set is-static = "";
>>>>
>>>>         option dhcp-renewal-time    = encode-int(lease-time / 2, 32);
>>>>         option dhcp-rebinding-time    = encode-int(lease-time * 7 / 8, 32);
>>>>         ddns-ttl            = encode-int((lease-time / 2) + 1, 32);
>>>>     }
>>>>
>>>>     log (   info,
>>>>         concat (
>>>>             "Host:", pick-first-value(option fqdn.hostname, option
>>>> host-name, "(none)"), "=>", pick-first-value(config-option
>>>> server.ddns-hostname, "(none)")
>>>>
>>>>             ,"  VendorId:", pick-first-value(option
>>>> vendor-class-identifier, "(none)")
>>>>
>>>>             ,"  Lease:",
>>>> pick-first-value(binary-to-ascii(10,32,"",encode-int(lease-time,32)),
>>>> "(none)")
>>>>             ,"  Renewal:", pick-first-value(binary-to-ascii(10, 32, "",
>>>> config-option dhcp-renewal-time), "(none)")
>>>>             ,"  Rebind:", pick-first-value(binary-to-ascii(10, 32, "",
>>>> config-option dhcp-rebinding-time), "(none)")
>>>>
>>>>             ,"  TTL:", pick-first-value(binary-to-ascii(10, 32, "",
>>>> config-option server.ddns-ttl), "(none)")
>>>>
>>>>             ,"  GIaddr:", pick-first-value(binary-to-ascii(10, 8, ".",
>>>> packet(24,4)), "(none)")
>>>>             , is-static
>>>>         )
>>>>     );
>>>> }
>>>>
>>>> Bill
>>>>
>>>>
>>>> On 10/19/2017 3:00 AM, Narcis Garcia wrote:
>>>>> isc-dhcp-server is currently logging in my system:
>>>>> DHCPDISCOVER from 11:22:33:44:55:66 via eth0
>>>>> DHCPOFFER on 172.16.20.201 to 11:22:33:44:55:66 via eth0
>>>>> DHCPREQUEST for 172.16.20.201 from 11:22:33:44:55:66 via eth0
>>>>> DHCPACK on 172.16.20.201 to 11:22:33:44:55:66 via eth0
>>>>>
>>>>> How can I make the service logs some name about that known client? (such
>>>>> as "printer_1")
>>>>>
>>>>> Thanks.
>>>>> _______________________________________________
>>>>> dhcp-users mailing list
>>>>> [hidden email]
>>>>> https://lists.isc.org/mailman/listinfo/dhcp-users
>>>>
>>>> _______________________________________________
>>>> dhcp-users mailing list
>>>> [hidden email]
>>>> https://lists.isc.org/mailman/listinfo/dhcp-users
>>>>
>>> _______________________________________________
>>> dhcp-users mailing list
>>> [hidden email]
>>> https://lists.isc.org/mailman/listinfo/dhcp-users
>>
>>
>>
>> _______________________________________________
>> dhcp-users mailing list
>> [hidden email]
>> https://lists.isc.org/mailman/listinfo/dhcp-users
>
>
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users
>
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users