DHCP configuration script

Suppose you need to add many subnets to the DHCP server configuration file, for example from to, in this case this script will help.

Download can be HERE.

The script must be made executable and run from linux:

chmod 755 script_dhcp_conf.php

The result is copied to the clipboard and pasted into the DHCP configuration file (in putty, the copying is done with the Ctrl+Ins key combination).

Sample script:

for($i=1; $i<=100; $i++)
subnet 172.16.$i.0 netmask {
       option routers 172.16.$i.1;
       option domain-name-servers,;
       option subnet-mask;
       default-lease-time 86400;
       max-lease-time 86400;
       next-server 172.16.$i.1;

See also my articles:
VLAN Generation Script for Netplan
Installing and configuring isc-dhcp-server in Ubuntu
Configuring the Network in Linux

Leave a comment

Leave a Reply