DHCPd IP 分配

DHCPd IP 分配

在我的测试中,以下操作是使用 2 台虚拟机进行的。服务器在 CentOS7 下,客户端在 Windows 10 下(MAC:08:00:27:bd:3d:ab)。

每次在服务器端进行修改后,我都会在客户端执行发布/更新,以检查它是否获得了我想要的IP。

配置如下:

authoritative;
ddns-update-style none;
default-lease-time 28800;
max-lease-time 36000;
allow bootp;

next-server 192.168.0.254;
filename "pxelinux.0";

shared-network {
    subnet 192.168.0.0 netmask 255.255.255.128 {
        option broadcast-address 192.168.0.127;
        option routers 192.168.0.1;
        option ntp-servers 192.168.0.1;
        option domain-name-servers 192.168.0.1;

        class "matchHW" {
            match hardware;
        }

        group {
            deny unknown-clients;
            subclass "matchHW" 1:08:00:27:bd:3d:ab;
        }

        group {
            deny unknown-clients;
            host win10 {
                hardware ethernet f8:00:27:bd:3d:ab;
                fixed-address 192.168.0.13;
            }
        }

        pool {
            allow members of "matchHW";
            option routers 192.168.0.3;
            option domain-name-servers 192.168.0.3;
            range 192.168.0.40 192.168.0.49;
        }

        pool {
            allow unknown-clients;
            option routers 192.168.0.2;
            option domain-name-servers 192.168.0.2;
            range 192.168.0.30 192.168.0.39;
        }
    }
}

在这个特定的配置中,我不明白为什么 Windows 客户端会获取其 IP 192.168.0.30,其网关为 .1。我预计它会获取 192.168.0.40,其网关为 .3。

如果我切换 2 个 MAC(08:00:27:bd:3d:ab、f8:00:27:bd:3d:ab)以获取静态 IP,则可行(获取 192.168.0.13)。如果我编辑这些 MAC,使其与具有未知 MAC 的客户端一起使用,则也可行(获取 192.168.0.30)。

我的配置的最终目标是为 3 个“组”提供 IP:

  • 已知 MAC 的静态 IP
  • 已知 MAC 的动态 IP
  • 未知 MAC 的动态 IP

每个组都有特定的路由器和 DNS 配置。

有人有想法吗?

答案1

感谢这两个链接,我找到了解决方案:

这是我的工作配置:

shared-network {

    subnet 192.168.0.0 netmask 255.255.255.128 {
        option broadcast-address 192.168.0.127;
        option routers 192.168.0.1;
        option ntp-servers 192.168.0.1;
        option domain-name-servers 192.168.0.1;

        # known clients - dynamic IP
        pool {
            allow known-clients;
            range 192.168.0.40 192.168.0.49;
        }

        # unknown clients - dynamic IP
        pool {
            allow unknown-clients;
            deny known-clients;
            option routers 192.168.0.2;
            option domain-name-servers 192.168.0.2;
            range 192.168.0.30 192.168.0.39;
        }
    }

}

# known clients - dynamic IP
group {
    deny unknown-clients;
    option routers 192.168.0.3;
    option ntp-servers 192.168.0.3;
    option domain-name-servers 192.168.0.3;

    host dyn-A {
        hardware ethernet f8:00:27:bd:3d:ab;
    }
}

# known clients - static IP
group {
    deny unknown-clients;
    option routers 192.168.0.1;
    option ntp-servers 192.168.0.1;
    option domain-name-servers 192.168.0.1;

    host win10 {
        hardware ethernet e8:00:27:bd:3d:ab;
        fixed-address 192.168.0.13;
    }
}

相关内容