SLAC CPE Software Engineering Group
Stanford Linear Accelerator Center
System Admin

MCC DHCP Configuration

SLAC Detailed
SLAC Computing
Software Home
Software Detailed
 

 

 

Programmers' Guides, Users' Guides

Modified: 15-Sep-2022


DHCP Configuration

DHCP, Dynamic Host Configuration Protocal, implemented via dhcpd, automatically assigns IP and other network configuration information (subnet mask, broadcast address) to computers on a network. IP addresses are either dynamically assigned from a range, or statically assigned by MAC address. A DHCP client will send out a broadcast request to the DHCP server requesting an address. The DHCP server will then issue a "lease" and assign it to that client. DHCP, a superset of BOOTP, provides service to both DHCP cleint and BOOTP cleints. DHCP reduces the ammount of time required to configure clients and allows one to move a computer to various networks and be configured with the appropriate IP address, gateway and subnet mask

 

How to update DHCP service

  • On mccsrv01, update /etc/dhcp/dhcpd.conf
    • cd /etc/dhcp
    • cp dhcpd.conf dhcpd.conf.old  -Or other name with date...
    • edit dhcpd.conf
  • Set up monitoring
    • login mccsyslog
    • tail –f /var/log/messages | grep mccsrv
  • Verify dhcpd config file
    • On mccsrv01:
      • service dhcpd configtest  -No longer available for RHEL7
      • ~/scripts/chk-dhcp-dups  (check duplicate MACs and IPs)
  • On mccsrv01: 
    • systemctl restart dhcpd
    • systemctl status dhcpd
  • Copy dhcpd.conf to mccsrv02 and restart dhcp on mccsrv02
    • scp /etc/dhcp/dhcpd.conf mccsrv02:/etc/dhcp
    • ssh mccsrv02 systemctl restart dhcpd
      • Check syslog for errors

 


RHEL7

#yum install dhcp

# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.

#Copy over dhcpd.conf file from RHEL6 DHCP server

# systemctl start dhcpd


# systemctl status dhcpd -l
● dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-04-21 12:53:02 PDT; 5min ago
Docs: man:dhcpd(8)
man:dhcpd.conf(5)
Main PID: 4595 (dhcpd)
Status: "Dispatching packets..."
CGroup: /system.slice/dhcpd.service
└─4595 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid

Apr 21 12:53:02 mccsrv03 dhcpd[4595]: For info, please visit https://www.isc.org/software/dhcp/
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Wrote 0 class decls to leases file.
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Wrote 0 deleted host decls to leases file.
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Wrote 0 new dynamic host decls to leases file.
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Wrote 0 leases to leases file.
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Listening on LPF/em1/44:a8:42:33:45:74/DMZ_VLAN
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Sending on LPF/em1/44:a8:42:33:45:74/DMZ_VLAN
Apr 21 12:53:02 mccsrv03 systemd[1]: Started DHCPv4 Server Daemon.
Apr 21 12:53:02 mccsrv03 dhcpd[4595]: Sending on Socket/fallback/fallback-net


 

DHCP Installation


yum install dhcp

[root@lcls-srv20 ~]# rpm -qa | grep dhcp
dhcp-3.0.1-65.el4_8.1

DHCP daemon Setup

/sbin/chkconfig --list dhcpd
dhcpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

/sbin/chkconfig dhcpd on

DHCP restart

service dhcpd restart

 

DHCP Server Configuration

dhcpd, DHCP daemon, is configured in /etc/dhcpd.conf.  A leases file is kept in /var/lib/dhcp/dhcpd.leases. 

[root@mccsrv01 ~]# cat /etc/dhcpd.conf

#Required for dhcp 3.0+ / RHEL4 +. Otherwise, dhcpd wont start.

ddns-update-style interim;    
#
shared-network "MCC-CTRLS_VLAN"
{
subnet 172.19.52.0 netmask 255.255.252.0
{

# default DNS to be used by DHCP clients

option domain-name-servers mcc-pep.slac.stanford.edu, mccdev-pep.slac.stanford.edu;                                                             
option domain-name "slac.stanford.edu";

# default gateway to be used by DHCP clients

option routers 172.19.55.1;

# default subnet mask to be used by DHCP clients
option subnet-mask 255.255.252.0;

# default broadcast address to be used by DHCP clients
option broadcast-address 172.19.55.255;
}

}

... more exmaples with comments...

The configuration file is visible to the public via

http://www.slac.stanford.edu/grp/cd/soft/unix/DHCP.html

DHCP Client Configuration

.... make entry here...

DHCP Test

First, test configuration file for syntax errors with the following command:

service dhcpd configtest   -while monitoring /var/log/messages ( tail –f /var/log/messages ) for any error messages. It is important to test the configuration file if there is any change made, before restart dhcpd.

When dhcpd is running it will generate entries in the file: /var/lib/dhcp/dhcpd.leases

Reboot cpu-sys0-ck00

DHCP monitoring

login mccsyslog

tail –f /var/log/messages | grep mccsrv

 


 

Backup of dhcpd.conf

 

 

 

 

 

A cronjob runs every morning at 1:30AM and copies the dhcpd.conf file to dhcpd.conf-date

(ex: dhcpd.conf-Jun-17-14)

 

RHEL5: /etc/

RHEL6: /etc/dhcp/

Also copies a file to our NFS server: (for tape backup)

 

 

 

 

 

mccfs8:/u1/lcls/sys/dhcp/dhcpd.conf-$HOSTNAME-$TDATE

(ex: dhcpd.conf-mccsrv03-Jun-17-14)

/root/scripts/copy-dhcp

Crontab:

 

[root@mccsrv03 opt]# crontab -l
30 1 * * * /root/scripts/copy-dhcp 1> /tmp/copy-dhcp.log 2>&1

*Remember mccsrv01 and mccsrv02 each have a copy of dhcpd.conf

 

 

Ken's Original Note

Test config on mccsrv01

Test config on mccsrv01

  • Install DHCP RPM:
    • yum install dhcp
  • Turn on DHCP
    • chkconfig dhcpd on
  •  Create /etc/dhcpd.conf file
    • Put:  “ddns-update-style interim; “   at top of file –required
  • Started DHCP server
    • service dhcp start
    • monitor /var/log/messages ( tail –F /var/log/messages )

DHCP Management:

  1. Always make changes on mccsrv01 
  2. Always make a copy of DHCP file.  (Remember mccsrv02 also has a copy)
  3. Edit dhcpd.conf file
    1. service dhcpd configtest
    2. Bring up mccsyslog ( tail -F /var/log/messages )
    3. Restart dhcpd services ( service dhcpd restart )
      1. Monitor on syslog
  4. If dhcpd.conf file is correct then copy to mccsrv02 ( scp /etc/dhcpd.conf root@mccsrv02:/etc/  )
  5. Restart dhcp on mccsrv02  (  ssh root@mccsrv02 service dhcpd restart  )
    1. Monitor on syslog
 



 

Programmers' Guides, Users' Guides, Requirements, Design, Papers, Administration, How-To, Hardware, IOC, Database

 

[SLAC CPE Software Engineering Group][ SLAC Home Page]

 


Created by: Ken Brobeck  14-May-2010