将DHCP特定供应商选项发送到Windows服务器

Modified on: Sat, 06 Jul 2019 12:00:02 +0800

我的目标是将一些信息(网址和一次性令牌)发送到Windows机器。它适用于GNU / Linux服务器,因为我从/var/lib/dh​​cp/dhcp.lease或类似的地方获取信息。这是我的设置:

dhcp服务器(GNU / Linux服务器):

host windows {
            dynamic;
            hardware ethernet XX:XX:XX:XX:XX:XX;
            fixed-address 10.70.10.107;
            supersede vendor-encapsulated-options  "http://URL/TOKEN";
    }

我发现在Windows服务器上获取此信息的唯一方法是在注册表中。我在这里添加了,在HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ services \ Tcpip \ Parameters \ Interfaces {ID}下,您可以找到名为DhcpInterfaceOptions的密钥。

问题是此密钥的信息“已损坏”。我会试着解释一下。

使用Wireshark,我可以从我的DHCP服务器看到一个格式正确的DHCP应答,并设置了43个选项。此选项包含我正在寻找的内容。当我尝试在注册表中读取它时包含大量垃圾并且某些部分网址丢失。

DHCP选项RFC 2132定义了以下协议:

Code   Len   Vendor-specific information
+-----+-----+-----+-----+---
|  43 |  n  |  i1 |  i2 | ...
+-----+-----+-----+-----+---

我发现Windows在获得选项后做了类似的事情。我的意思是,如果URL为“http:// URL / TOKEN”,则Windows将“h”设置为ID ,'t'作为长度,并在第二个't'之后开始读取。我的网址比上一个ASCII可打印字符(〜)长,我无法解决这个问题。

更新1

WireShark捕获:

Option: (t=43,l=16) Vendor-Specific Information
  Option: (43) Vendor-Specific Information
  Length: 16
  Value: 687474703a2f2f55524c2f544f4b454e (http://URL/TOKEN)

Windows注册表:

"DhcpInterfaceOptions"=hex:06,00,00,00,00,00,00,00,08,00,00,00,00,00,00,00,52,\ 45,b7,4f,0a,46,0a,01,08,08,08,08,03,00,00,00,00,00,00,00,04,00,00,00,00,00,\ 00,00,52,45,b7,4f,0a,46,0a,01,0f,00,00,00,00,00,00,00,0f,00,00,00,00,00,00,\ 00,52,45,b7,4f,74,50,1f,2b,6f,61,6f,75,75,6a,3f,64,6e,77,2e,00,01,00,00,00,\ 00,00,00,00,04,00,00,00,00,00,00,00,52,45,b7,4f,ff,ff,ff,00,36,00,00,00,00,\ 00,00,00,04,00,00,00,00,00,00,00,52,45,b7,4f,0a,46,0a,01,35,00,00,00,00,00,\ 00,00,01,00,00,00,00,00,00,00,52,45,b7,4f,05,00,00,00,fc,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,2a,bd,b6,4f,33,00,00,00,00,00,00,00,04,00,00,00,\ 00,00,00,00,52,45,b7,4f,00,00,8c,a0

更新2

如果网址短于 Windows协议上定义的大小,则网址上不会显示网址。在我的情况下,'h'将是标识符,'t'是大小(116)。如果网址是:

http://AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

注册表包含我之前粘贴的内容。网址正好是117个字符,但我们使用2表示内容和大小。这意味着数据是115.还不够。

如果我在网址中添加一个'A':

http://AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

然后注册表包含:

"DhcpInterfaceOptions"=hex:68,00,00,00,00,00,00,00,74,00,00,00,01,00,00,00,62,\ 0e,bb,4f,74,70,3a,2f,2f,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,\ 41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,\ 41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,\ 41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,\ 41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,06,00,00,00,00,00,\ 00,00,08,00,00,00,00,00,00,00,62,0e,bb,4f,0a,46,0a,01,08,08,08,08,03,00,00,\ 00,00,00,00,00,04,00,00,00,00,00,00,00,62,0e,bb,4f,0a,46,0a,01,0f,00,00,00,\ 00,00,00,00,0f,00,00,00,00,00,00,00,62,0e,bb,4f,75,61,4a,1f,31,4c,ca,11,55,\ 6f,2e,63,1f,6d,fe,00,01,00,00,00,00,00,00,00,04,00,00,00,00,00,00,00,62,0e,\ bb,4f,ff,ff,ff,00,33,00,00,00,00,00,00,00,04,00,00,00,00,00,00,00,62,0e,bb,\ 4f,00,00,8c,a0,36,00,00,00,00,00,00,00,04,00,00,00,00,00,00,00,62,0e,bb,4f,\ 0a,46,0a,01,35,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,62,0e,bb,4f,05,\ 00,00,00

41是'A'的十六进制表示。

作者:Community,Seoman

最佳答案

实施的解决方案是:

的dhcpd.conf:

option space yourCompany;
    option yourCompany.url code 128 = text;

class "vendor-classes" {
    match option vendor-class-identifier;
}

subclass "vendor-classes" "MSFT 5.0" {
    vendor-option-space yourCompany;
}

在租约中,添加以下行:

supersede yourCompany.url = "http://URL"

您可以根据需要更改.url。只需确保在公司空间中更改选项名称。

使用此方法,我可以在注册表中看到完整的URL。

作者:Seoman

相关问答

添加新评论