<meta http-equiv="Content-Type" content="text/html; charset=GB18030"><div><font __editorwarp__="1" style="display: inline; font-size: 14px; font-family: Verdana; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0); font-weight: 400; font-style: normal;">I have already asked a question on serverfault(https://serverfault.com/questions/1149090/linux-server-management-debian-10-and-centos-dhcp-service-host-name-based-client), but I didn't receive any useful response. So, I'm reaching out to you for help. Sorry for bothering you.</font></div><div>I want to allocate a client's IP address based on the host-name provided by the client, but the results are often unpredictable.  </div><div>I have tried to imitate the Client Classing in dhcpd.conf(5) by assigning   </div><div>clients with host-name "Debian-xx" to the 192.168.100.0/24 subnet   </div><div>clients with host-name "Centos-xx" to the 192.168.1.0/24 subnet.  </div><div>I am using DHCP version 4.4.1. When I check the logs using "dhcpd -d", I noticed that the classing is not taking effect or there are errors. For example, the "Centos-xxx" clients might be assigned to the 192.168.100.0 or 192.168.255.0 subnet, and the assignments seem to be inconsistent.  </div><div><br></div><div>This is the content of my dhcpd.conf file.</div><div><br></div><div>```</div><div>default-lease-time 10;</div><div>use-host-decl-names on;</div><div>max-lease-time 20;</div><div>authoritarive ;</div><div>log-facility local2;</div><div><br></div><div>class "centos-server"{</div><div><span style="white-space: normal;"><span style="white-space:pre">       </span>match if (substring(option host-name ,0,6)="Centos") ;</span></div><div>}</div><div><br></div><div>class "debian-server"{</div><div><span style="white-space: normal;"><span style="white-space:pre">      </span>match if (substring (option host-name  ,0,6)="Debian") ;</span></div><div><br></div><div>}</div><div><br></div><div>subnet 192.168.0.0 netmask 255.255.0.0 {</div><div><br></div><div><span style="white-space: normal;"><span style="white-space:pre">     </span>option routers 192.168.0.2;</span></div><div><br></div><div><span style="white-space: normal;"><span style="white-space:pre">  </span>option subnet-mask 255.255.255.0;</span></div><div><span style="white-space: normal;"><span style="white-space:pre">     </span>pool{</span></div><div><span style="white-space: normal;"><span style="white-space:pre"> </span>allow members of "centos-server";</span></div><div><span style="white-space: normal;"><span style="white-space:pre">   </span>range 192.168.100.1 192.168.100.254;</span></div><div><span style="white-space: normal;"><span style="white-space:pre">  </span>}</span></div><div><span style="white-space: normal;"><span style="white-space:pre">     </span>pool{</span></div><div><span style="white-space: normal;"><span style="white-space:pre"> </span>allow members of "dbian-server";</span></div><div><span style="white-space: normal;"><span style="white-space:pre">    </span>range 192.168.1.1 192.168.1.254;</span></div><div><span style="white-space: normal;"><span style="white-space:pre">      </span>}</span></div><div><span style="white-space: normal;"><span style="white-space:pre">     </span>pool{</span></div><div><span style="white-space: normal;"><span style="white-space:pre"> </span>range 192.168.255.1 192.168.255.254;</span></div><div><span style="white-space: normal;"><span style="white-space:pre">  </span>}</span></div><div><br></div><div>}</div><div>on commit {</div><div>log(debug, concat("test for   ",  substring(option host-name,0,6 ) ));</div><div> if ( ( substring( option host-name , 0, 6 ) ="Debian") ) {</div><div>log(debug,"Debian!");</div><div>}</div><div>else if ( ( substring( option host-name , 0, 6 ) ="Centos") ) {</div><div>log(debug,"Centos!");</div><div>}</div><div>else {</div><div>log(debug,"i dont konw");</div><div>}</div><div><br></div><div>}</div><div><br></div><div>```</div><div>This is the content of my dhclient.conf</div><div><br></div><div>```</div><div>send host-name = gethostname();</div><div>request subnet-mask, broadcast-address, time-offset, routers,</div><div><span style="white-space: normal;"><span style="white-space:pre"> </span>domain-name, domain-name-servers, domain-search, host-name,</span></div><div><span style="white-space: normal;"><span style="white-space:pre">   </span>dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,</span></div><div><span style="white-space: normal;"><span style="white-space:pre">      </span>netbios-name-servers, netbios-scope, interface-mtu,</span></div><div><span style="white-space: normal;"><span style="white-space:pre">   </span>rfc3442-classless-static-routes, ntp-servers;</span></div><div><br></div><div><br></div><div>```</div><div><br></div><div><br></div><div><br></div><div>I experimented with modifying the expression after "match if," such as using "or (1=1)," but the client may still not be assigned to that class.  </div><div>I tried to see if it was an issue with "host-name" and "option host-name," but it doesn't seem to be the key issue.  </div><div>I suspect there is an error in the conditional expression within the class, but the commit logs, I found that the log results alternated between "Centos!" and "I don't know".  </div><div>I searched for related issues, such as this link [dhcpd class match on hostname or mac address](https://serverfault.com/questions/778719/dhcpd-class-match-on-hostname-or-mac-address), but it seems that the answers did not provide a good solution to the problem.  </div><div>I want to know where my mistake lies, how to modify it, or if there are websites that provide solutions.  </div><div><br></div><div>If you can provide assistance, I would be extremely grateful.<br></div>