option domain-name "lan.local";
option domain-name-servers <NS1>, <NS2>;

default-lease-time 28800;
max-lease-time 86400;

ddns-update-style none;
ddns-updates off;

one-lease-per-client true;

authoritative;

allow booting;
allow bootp;

log-facility local7;

option log-servers <STAT>;

option ntp-servers <NTP>;

use-host-decl-names off;

ping-check false;

log-facility local5;

on commit {
    set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
    set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    set ClientHostName = pick-first-value(option host-name,"undef");
    log (info, concat("add;", ClientMac, ";", ClientIP, ";;", ClientHostName,";",binary-to-ascii(10,8,"",suffix (option agent.circuit-id, 1)),";",binary-to-ascii(16,8,":",suffix(option agent.remote-id,6)),";;;"));
    }

on release {
    set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
    set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    log (info, concat("del;", ClientMac, ";", ClientIP, ";" , ";undef;;;;;;"));
}

on expiry {
    set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
    set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    log (info, concat("del;", ClientMac, ";", ClientIP, ";" , ";undef;;;;;;"));
}

log (info, concat("DHCPDLOG - ",binary-to-ascii(10, 8, ".", leased-address)," - ",pick-first-value(option host-name,"undef")," - ",binary-to-ascii (16, 8, ":", substring(hardware, 1, 7))," - at switch - ",binary-to-ascii(16,8,":",suffix(option agent.remote-id,6))," - vlan - ",binary-to-ascii(10,16,"",substring(suffix(option agent.circuit-id,4),0,2))," - port - ",binary-to-ascii(10,8,"",suffix (option agent.circuit-id, 1))," - via - ",binary-to-ascii(10,8,".",packet (24,4))));

if exists agent.remote-id and exists agent.circuit-id {
  log(info,concat("DHCPCIRCUIT for lease of ",binary-to-ascii(10,8,".",leased-address),
  " is connected to interface ",binary-to-ascii(10,8,"/",suffix(option agent.circuit-id,2)),
  ", VLAN ",binary-to-ascii(10,16,"",substring(suffix(option agent.circuit-id,4),0,2)),
  " on switch ",binary-to-ascii(16,8,":",suffix(option agent.remote-id,6))
  ));
  log(info,concat("DHCPOPT82 for lease of ",binary-to-ascii(10,8,".",leased-address),
  " raw option-82 info is CID: ",binary-to-ascii(10,8,".",option agent.circuit-id),
  " AID: ",binary-to-ascii(16,8,".",option agent.remote-id)
  ));
  } elsif exists agent.remote-id {
      log(info,concat("DHCPAGENT for lease of ",binary-to-ascii(10,8,".",leased-address),
      " on agent ",binary-to-ascii(16,8,":",substring(option agent.remote-id, 2, 6))
    ));
    } elsif exists agent.circuit-id {
      log(info,concat("DHCPCIRCUITID on ",
      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),
      " to ",binary-to-ascii(10,8,".",leased-address),
      " via ",option agent.circuit-id
    ));
}

option ms-classless-static-routes code 249 = array of unsigned integer 8;
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

# WPAD definition
option wpad code 252 = text;
# Suppress WPAD activity - no cache, no DNS.
option wpad "\n\000";

option space MSFT;
#release ip if shutdown
option MSFT.release-on-shutdown code 2 = unsigned integer 32;

class "MSFT" {
match if substring(option vendor-class-identifier, 0, 4) = "MSFT";
# They put 252 on the DHCPINFORM's, but not on the DHCPREQUEST's
# PRL.  So we over-ride the PRL to include 252 = 0xFC, which will also
# suppress the DHCPINFORMS!
option dhcp-parameter-request-list =
concat(option dhcp-parameter-request-list, fc);
# Make DHCP work on dual boot machines (Linux & Windows2000)
# Microsoft proprietary stuff:
send fqdn.server-update true;
send fqdn.no-client-update true;
vendor-option-space MSFT;
option MSFT.release-on-shutdown 1;
}

class "default" {
    match if (binary-to-ascii (10, 16, "",   substring    ( option agent.circuit-id, 2, 2 ) ) = "99");
}

class "any" {
    match if (not exists agent.circuit-id);
}

class "direct" {
    match if (binary-to-ascii(10,8,".",packet (24,4)) = "0.0.0.0");
}

include "/etc/dhcp/eye.d/eye.conf";
