isc-dhcp 自定义option 配置, option 43, option 60

本文为原创, 转载请注明出处

 

 

配置选项对应的指令列表:

isc-dhcp-ipv4/dhcp-4.2.4/common/tables.c

 

私有编号:

1.      定义:

# 配置文件有声明的编号 会在接收的时候 替换成类似new_acip1=value 形式

# 声明一个私有编号名字: acip1, 编号: 234, 值类型: string

# string类型: 一种 “abc”形式, 另一种十六进制形式:

option acip1 code 234 = string;

 

# 向目标请求一个选项acip1, 数据包里面的 option-55(参数请求列表) 就会带上这个编号, # request 请求要写在{}类里面, 并且最后一个request 才生效

request acip1;

 

# 强制发送, 向目标发送一个私有选项 acip1 编号 234, 内容acip138

send acip1 "acip138";

 

# 选择发送, 如果目标有请求 234编号, 就发送

option acip1 “acip138”

 

2.      请求:

# 公共规则

# 声明一个选项 , private1 编号 234(个人私有编号, 随便写的) 值类型 string

option private1 code 234 = string;

# 指定接口规则, 优先级高

interface "eth0" {

    # 请求234选项

    request subnet-mask,vendor-encapsulated-options;

}

 

3.      处理:

# 声明

option acip code 138 = string;

option private1 code 234 = string;

option vendor-encapsulated-options code 43 = string;

 

subnet 192.168.5.0 netmask 255.255.255.0 {

    range  192.168.5.2 192.168.5.254;

 

    # 根据请求发送

    option routers 192.168.5.1;

    option subnet-mask 255.255.255.0;

    option vendor-encapsulated-options "dhcp43";

    #option serverip 03:0C:31:39:32:2E:31:36:38:2E:32:32:2E:31;

 

    # 强制发送

    send acip "acip";

}

dhclient 配置

dhclient –d eth0

debug模式运行

1.    拓普图:

2.    配置信息:

isc-dhcp

dhclient.conf 配置:

 

 

timeout 300;

retry 15;

reboot 10;

select-timeout 5;

initial-interval 5;

 

# 公共规则

send vendor-class-identifier "dhcp60";

send vendor-encapsulated-options "dhcp43";

request routers, host-name;

 

# 指定接口规则, 优先级高

interface "eth0" {

send vendor-class-identifier "acdhcp60";

send vendor-encapsulated-options "acdhcp43";

request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name, netbios-name-servers, netbios-scope;

}

 

 

dhcpd option 43配置

vendor-encapsulated-options 通告另一个设备的IP

dhcpd  -d -cf dhcpd.conf -lf dhcpd.leases

debug模式运行

1.    拓普图:

2.    配置信息:

option vendor43 code 43 = string;

 

class "ac43-req" {

    # 全字符串匹配, 做标记

    match if option vendor43  = "acdhcp43";

}

 

shared-network "dhcp" { # 用来告知是否一些子网络分享相同网络 ?

    subnet 192.168.10.0 netmask 255.255.255.0 {

        option routers 192.168.10.1;

    }

 

    pool {  # 一个IP

        # class acdhcp43

        allow members of "ac43-req";

 

        # 地址范围

        range 192.168.10.10 192.168.10.20;

        # 根据请求发送

        option vendor43 "192.168.100.100";

        # 强制发送

        #send vendor43 "192.168.100.100";

    }

 

    # network interface, 绑定到 192.168.5.0 这个的接口上(至少绑定一个有效接口)

    subnet 192.168.5.0 netmask 255.255.255.0 {

        option routers 192.168.5.1;

    }

    pool {

        # class 不为 acdhcp43

        deny members of "ac43-req";

        range 192.168.5.30 192.168.5.40;

    }

}

 

dhcpd option 60配置

使用option vendor-class-identifier 60 指定的dhcpd

1.   拓普图:

2.   配置信息:

# vendor-class-identifier == acdhcp60, 标记 members acdhcp60, 执行 pool: 192.168.5.10

# 否则: pool: 10.0.29.10

class "acdhcp60" {

    # 部分字符串匹配

    #match if substring (option vendor-class-identifier, 0, 4) = "abcd";

    # 完整字符串匹配, 匹配:  vendor-class-identifier == acdhcp60

    match if option vendor-class-identifier = "acdhcp60";

}

 

shared-network "dhcp" { # 用来告知是否一些子网络分享相同网络 ?

    # network interface, 绑定到 192.168.5.0 这个的接口上(至少绑定一个有效接口)

    subnet 192.168.5.0 netmask 255.255.255.0 {

        option routers 192.168.5.1;

    }

    pool {  # 一个IP

        # class acdhcp60

        allow members of "acdhcp60";

        range 192.168.5.10 192.168.5.25;

    }

 

    subnet 10.0.29.0 netmask 255.255.255.0 {

        option routers rtr-29.example.org;

    }

    pool {

        # class 不为 acdhcp60

        deny members of "acdhcp60";

        range 10.0.29.10 10.0.29.230;

    }

}

原文地址:https://www.cnblogs.com/listenerln/p/9111001.html