Centos 7 DHCP

I’ve been using hyper-v and Microsoft of my servers at home for a while now and to be honest, I’ve no problems with any of it, it just works.  But as the license expiration date gets closer and closer, yes I know about the rearm, it’s time to move to an OS that I won’t have to pay for.  CentOS it is.

Once of the functions of one of my servers is to provide DHCP services, I decided to disable the function on the router itself, as it’s a bit flakey as it is.  To install it on CentOS is quite easy

yum -y install dhcp

Once it’s installed you’ll need to edit the dhcpf.conf, which is blank. For a basic setup I used the content below, it should get you working.

vi /etc/dhcp/dhcpd.conf

# specify domain name
option domain-name “paulmellors.local”
# specify name server’s hostname or IP address
option domain-name-servers 8.8.8.8, 8.8.4.4;
# default lease time
default-lease-time 600;
# max lease time
max-lease-time 7200;
# this DHCP server to be declared valid
authoritative;
# specify network address and subnet mask
subnet 10.0.0.0 netmask 255.255.255.0 {
# specify the range of lease IP address
range dynamic-bootp 10.0.0.200 10.0.0.254;
# specify broadcast address

option broadcast-address 10.0.0.255;
# specify default gateway
option routers 10.0.0.1;
}

Once edited, save the file and start dhcpd
systemctl start dhcpd
systemctl enable dhcpd

Once you enable it, you should see this, no need to type this in.

ln -s ‘/usr/lib/systemd/system/dhcpd.service’ ‘/etc/systemd/system/multi-user.target.wants/dhcpd.service’

But how do I know it’s worked?

Just keep your eye on your leases file

tail /var/lib/dhcpd/dhcpd.leases

It should tell you, but as I’ve just installed it, it doesn’t have any yet, once my devices reconnect, it’ll populate the file.

Questions?

** UPDATE **

Another way of checking all is ok, is to run the status check

[root@rmcdhcp01 paulmellors]# service dhcpd status -l
Redirecting to /bin/systemctl status  -l dhcpd.service
dhcpd.service – DHCPv4 Server Daemon
Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; enabled)
Active: active (running) since Thu 2015-01-08 13:35:30 GMT; 13min ago
Docs: man:dhcpd(8)
man:dhcpd.conf(5)
Main PID: 1885 (dhcpd)
Status: “Dispatching packets…”
CGroup: /system.slice/dhcpd.service
└─1885 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd –no-pid

Jan 08 13:35:30 rmcdhcp01.TUX-NET dhcpd[1885]: All rights reserved.
Jan 08 13:35:30 rmcdhcp01.TUX-NET dhcpd[1885]: For info, please visit https://www.isc.org/software/dhcp/
Jan 08 13:35:30 rmcdhcp01.TUX-NET dhcpd[1885]: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Jan 08 13:35:30 rmcdhcp01.TUX-NET dhcpd[1885]: Wrote 0 leases to leases file.
Jan 08 13:35:30 rmcdhcp01.TUX-NET dhcpd[1885]: Listening on LPF/eth0/00:xx:5d:xx:dc:xx/10.0.0.0/24
Jan 08 13:35:30 rmcdhcp01.TUX-NET dhcpd[1885]: Sending on   LPF/eth0/00:xx:5d:00:xx:06/10.0.0.0/24
Jan 08 13:35:30 rmcdhcp01.TUX-NET dhcpd[1885]: Sending on   Socket/fallback/fallback-net
Jan 08 13:35:30 rmcdhcp01.TUX-NET systemd[1]: Started DHCPv4 Server Daemon.
Jan 08 13:48:34 rmcdhcp01.TUX-NET dhcpd[1885]: DHCPREQUEST for 10.0.0.xx from xx:e1:b6:xx:4b:d7 via eth0
Jan 08 13:48:34 rmcdhcp01.TUX-NET dhcpd[1885]: DHCPACK on 10.0.0.xx to 74:xx:xx:09:xx:d7 (xxxxxxxx) via eth0

Advertisements

2 thoughts on “Centos 7 DHCP

  1. Hi Paul,

    Do you do dynamic DNS internally? I am asking because my setup is dnsmasq based (will post a blog in the next few days) which does both DNS and DHCP, and previously I used to setup BIND and DHCP, which is a bit complicated for a network of 4/5 computers.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s