PasteZap
🌐 简体中文
免费 · 无需注册

免费 · 网络与 IT 基础设施

DHCP 配置生成器.

为 Kea、ISC dhcpd、dnsmasq、Windows Server 和 MikroTik 生成 DHCPv4 服务器配置,包括地址池、选项和保留地址。

开始之前

部分技术控件使用英语。支持 Unicode 文本;文件格式和输出语言取决于具体工具。

下面以英语列出技术限制。处理大型文件或使用结果之前,请先查看这些限制。

CALCULATED IN YOUR BROWSER · NOTHING IS UPLOADED
Reservations
Addresses in the pool100192.168.10.100 – 192.168.10.199
Subnet
192.168.10.0/24 (255.255.255.0)
Gateway
192.168.10.1
Usable addresses outside the pool
154
Lease time
1d

Kea DHCPv4 (kea-dhcp4.conf)

{
  "Dhcp4": {
    "interfaces-config": {
      "interfaces": [
        "eth0"
      ]
    },
    "lease-database": {
      "type": "memfile",
      "persist": true,
      "name": "/var/lib/kea/kea-leases4.csv"
    },
    "valid-lifetime": 86400,
    "max-valid-lifetime": 172800,
    "subnet4": [
      {
        "id": 1,
        "subnet": "192.168.10.0/24",
        "pools": [
          {
            "pool": "192.168.10.100 - 192.168.10.199"
          }
        ],
        "option-data": [
          {
            "name": "routers",
            "data": "192.168.10.1"
          },
          {
            "name": "domain-name-servers",
            "data": "192.168.10.1"
          },
          {
            "name": "domain-name",
            "data": "office.lan"
          }
        ],
        "reservations": [
          {
            "hw-address": "00:1b:63:84:45:e6",
            "ip-address": "192.168.10.20",
            "hostname": "printer"
          },
          {
            "hw-address": "3c:52:82:0a:11:7f",
            "ip-address": "192.168.10.21",
            "hostname": "nas"
          }
        ]
      }
    ]
  }
}

ISC DHCP (dhcpd.conf)

# ISC DHCP (dhcpd.conf). ISC DHCP reached end of life in 2022; Kea is its successor.
option domain-name "office.lan";
option domain-name-servers 192.168.10.1;
default-lease-time 86400;
max-lease-time 172800;
authoritative;

subnet 192.168.10.0 netmask 255.255.255.0 {
  range 192.168.10.100 192.168.10.199;
  option routers 192.168.10.1;
  option broadcast-address 192.168.10.255;
}

host printer {
  hardware ethernet 00:1b:63:84:45:e6;
  fixed-address 192.168.10.20;
}

host nas {
  hardware ethernet 3c:52:82:0a:11:7f;
  fixed-address 192.168.10.21;
}

dnsmasq

interface=eth0
dhcp-range=192.168.10.100,192.168.10.199,255.255.255.0,86400
dhcp-option=option:router,192.168.10.1
dhcp-option=option:dns-server,192.168.10.1
domain=office.lan
dhcp-host=00:1b:63:84:45:e6,printer,192.168.10.20
dhcp-host=3c:52:82:0a:11:7f,nas,192.168.10.21

Windows Server (PowerShell)

Add-DhcpServerv4Scope -Name "192.168.10.0/24" -StartRange 192.168.10.100 -EndRange 192.168.10.199 -SubnetMask 255.255.255.0 -LeaseDuration (New-TimeSpan -Seconds 86400) -State Active
Set-DhcpServerv4OptionValue -ScopeId 192.168.10.0 -Router 192.168.10.1 -DnsServer 192.168.10.1 -DnsDomain "office.lan"
Add-DhcpServerv4Reservation -ScopeId 192.168.10.0 -IPAddress 192.168.10.20 -ClientId "00-1b-63-84-45-e6" -Name "printer"
Add-DhcpServerv4Reservation -ScopeId 192.168.10.0 -IPAddress 192.168.10.21 -ClientId "3c-52-82-0a-11-7f" -Name "nas"

MikroTik RouterOS

/ip pool
add name=pool-eth0 ranges=192.168.10.100-192.168.10.199
/ip dhcp-server
add name=dhcp-eth0 interface=eth0 address-pool=pool-eth0 lease-time=1d
/ip dhcp-server network
add address=192.168.10.0/24 gateway=192.168.10.1 dns-server=192.168.10.1 domain=office.lan
/ip dhcp-server lease
add address=192.168.10.20 mac-address=00:1B:63:84:45:E6 server=dhcp-eth0 comment=printer
add address=192.168.10.21 mac-address=3C:52:82:0A:11:7F server=dhcp-eth0 comment=nas
  • Run only one DHCP server per network segment unless you configure failover.
  • Validate before restarting: kea-dhcp4 -t, dhcpd -t, dnsmasq --test.

使用方法: DHCP 配置生成器

输入数据或选择文件,调整设置并生成结果。复制或下载之前,请检查结果。

限制与支持格式

输入内容在您的设备上处理。

英语技术说明

DHCPv4 only; no failover, relay or DHCPv6 settings. Reservation rules differ: Windows needs them inside the scope, others prefer them outside the pool. Everything is calculated in your browser; nothing is sent or probed on the network.

Addresses, MACs and options are validated once, then written in each server’s syntax. MAC addresses are normalised to the separator each product expects.

192.168.10.0/24 with pool .100–.199, gateway .1 and two reservations produces matching kea-dhcp4.conf, dhcpd.conf, dnsmasq, PowerShell and RouterOS files.