dhcpd – openSUSE Lizards https://lizards.opensuse.org Blogs and Ramblings of the openSUSE Members Fri, 06 Mar 2020 11:29:40 +0000 en-US hourly 1 How to filter a certain class of hardware in dhcpd.conf https://lizards.opensuse.org/2014/03/19/how-to-filter-a-certain-class-of-hardware-in-dhcpd-conf/ Wed, 19 Mar 2014 12:00:59 +0000 http://lizards.opensuse.org/?p=10675 To prepare the end of the XP world

Atfer 8th April 2014, Windows XP system will be Like children in the lions’ den, if connected to internet

In a network around, all the still running XP are all vmware virtual machine, and none of the end-users are the right to modify the settings of the virtual machine, nor has administrative right under XP

The idea is the simply to just suppress the gateway of the network.

Playing with dhcpd.conf

There’s lot of way to handle this classification, but I discover that you need to find the right syntax, and understand how the binary-to-ascii function of dhcpd work.

First binary-to-ascii remove any leading 0, then we will just readd them 🙂

Extract of the dhcpd.conf

# binary-to-ascii remove leading 0 rebuild the complete MAC
set testmac = 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) );

# Extract the only first 8 chars 
set testclass = substring(testmac, 0, 8);
# You will find a lot of this on internet but doesn't work
# set testmac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));

# All our VMware VM use the same prefix
if ( testclass = "00:0c:29" ){
  # put dummy router
  option routers 127.0.0.1;
  # useful debug log
  log (info, "xp32 lease");
}else{
  # Default gateway for anyone else
  option routers 192.168.1.254;
  log (info, "standard lease");
}

That’s all for today

]]>