CentOS as DHCP server

1.1. check the public iface settings

vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp0s3"
UUID="ad0182e7-0fcb-4f91-90d6-ebaf2a41049f"
DEVICE="enp0s3"
ONBOOT="yes"
DNS1="5.9.49.12"
DNS2="5.135.183.146"
PEERDNS="no"
PEERROUTES="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_PRIVACY="no"

1.2. check the internal iface settings:

vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=44362b74-28a1-4792-8643-648ff38245d0
DEVICE=enp0s8
ONBOOT=yes
IPADDR=10.10.10.1
PREFIX=24
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no

2. up the internal interface

ifup enp0s8

3. install dhcp server

yum install dhcp

4.1. configure the server

vi /etc/dhcp/dhcpd.conf
option domain-name "local.domain";
option domain-name-servers ns1.local.domain, ns2.local.domain;

default-lease-time 600;
max-lease-time 7200;

ddns-update-style interim;

authoritative;

log-facility local7;

subnet 10.10.10.0 netmask 255.255.255.0 {
    range         10.10.10.10     10.10.10.219;
    option subnet-mask            255.255.255.0;
    option routers                10.10.10.1;

    option domain-search          "local.domain";

    option broadcast-address      10.10.10.255;
    option time-offset            -18000; 
}

4.2. optionally – static dhcp declaration:

host ipa.local.test { 
    hardware ethernet 00:99:33:55:AA:00;
    fixed-address 10.10.10.220;
}

5. start and enable service

systemctl start dhcpd
systemctl enable dhcpd

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *