Presentation Used in Class

Download Report

Transcript Presentation Used in Class

Dynamic Host
Configuration Protocol
DHCP Overview
• Used to automatically deliver IP addresses and
Network settings
• The purpose of DHCP is to assign network settings centrally
from a server rather than configuring them locally on each and
every workstation.
• DHCP Server service must be installed and configured on
machine that will function as DHCP server
• Reduces the amount of time you spend
configuring computers on your network
• Used by client by default unless you specify
• When configuring a newly detected card it auto sets itself as a
dhcp client
Leasing an IP Address
• An IP address is leased during the boot process
• The overall process is composed of four broadcast
Leasing an IP Address
Leasing an IP Address
• A DHCP transaction begins when a client sends out a DHCP
DISCOVER packet which is a broadcast packet. The packet
contains only the client’s hardware address.
• The DHCP server receives the DHCP DISCOVER packet from
the client. If an IP address on the client subnet is available it
makes an offer by sending a DHCP OFFER packet to the client.
The offer packet contains the following information:
• Proposed IP address for the client
• Server information: i.e, name / IP
• Other configuration information
Leasing an IP Address
• The client receives the DHCP OFFER packet. The client may
receive more than one offer if more than one DHCP server
exists on the network. If the client is interested in the offer, it
sends a DHCPREQUEST packet to the server. This indicates a
formal request to lease the IP address offered by the server.
• The DHCP server receives the DHCPREQUEST packet and
leases an IP address to the client. The server sends a
DHCPACK packet to the client. This is an official notification
that the address has been granted and the client can start using
the IP address and options in the lease.
Renewing an IP Address
• The IP address can either be permanent or timed
• A permanent address is never reused for another
• Timed leases expire after a certain amount of time
• Clients attempt to renew their lease based on the
configured lease time
• A DHCP server may either honor or reject a renew
Renewing an IP Address
DHCP Server and Client
• DHCP Server daemon (dhcpd) does not automatically
get installed during a typical installation.
• It can be installed during the OS installation or,
• It can be installed via Yast or
• It can be installed from the command line
• DHCP client
• 2 DHCP Clients are available
• dhcp client daemon (dhcpcd)
• Internet Systems Consortium (ISC) dhcp-client
• OpenSuse uses dhcpcd by default. It does not need a configuration file
• ISC dhcp-client can be used for more complex situations and does
require a configuration file (/etc/dhclient.conf)
DHCP Server Configuration
/etc/dhcpd.conf file
• The /etc/dhcpd.conf file contains configuration information for the
DHCP Server.
• It can be modified with Yast
or with a text editor
• If a text editor is used, check
syntax and restart service
• rcdhcpd check-syntax
• rcdhcpd restart
Server Commands
• chkconfig
• chkconfig dhcpd -- to view the boot status of dhcpd
• chkconfig dhcpd on – to configure dhcpcd to start at boot
• chkconfig dhcpd off – to configure dhcpcd to not start at boot
• rcdhcpd
rcdhcpd check-syntax – to check the syntax of /etc/dhcpd.conf
rcdhcpd status – displays the status of the dhcp server service
rcdhcpd start –starts the dhcp server
rcdhcpd stop – stops the dhcp server
Client Commands
Note: in each command, replace the pound sign (#) with the
ethernet card number
• ifconfig ethname -- to view the current IP address and IP
settings of the ethname card
• dhcpcd ethname -k -- forces dhcpcd to release the dhcp lease
• dhcpcd ethname -n -- forces dhcpcd to try to renew the dhcp
• ifdown ethname - to bring down the specified Ethernet card
• ifup ethname - to bring up the specified Ethernet card
(Do not use ifup and ifdown to ‘renew’ dhcp settings.)
• /etc/dhcpd.conf – server configuration file
• /var/lib/dhcp/db/dhcpd.leases – stores client leases assigned by
• /etc/sysconfig/network/ifcfg- ethname - stores network card
settings for ethname
• /var/log/rc.dhcpd.log - log file for dhcpd
• /var/lib/dhcpcd/dhcpcd- – contains dhcp settings
assigned to client from server
• /etc/resolv.conf – shows dns settings of machine. At client,
this will show what settings have been received by dhcp server
• /etc/sysconfig/network/ifcfg- ethname - stores network card
settings for ethname
Creating DHCP Fixed Addresses
• Fixed Addresses (aka reservations) are used to hand out a
specific IP address to a particular client
• Useful when delivering IP addresses to devices that would
normally use static addresses
• Configure in Yast’s DHCP Server configuration / Host
Management or by manually editing the dhcpd.conf file
• Fixed Addresses are created based on MAC addresses
• Commands that will display the MAC address of a card include:
• ifconfig ethname
• ifstatus ethname
• ip link show ethname
• Sample entry in dhcpd.conf file for fixed/static IP Address
host apex {
hardware ethernet 00:A0:78:8E:9E:AA;
Creating DHCP “Exclusions”
• No Exclusion entries exist for the dhcpd.conf file
• To Exclude an IP address or range of IP addresses, specify the
ranges around it.
• For example on the network, to exclude through from being distributed by the DHCP server, use the ranges
( to and ( to
• Configure multiple ranges in Expert Settings within Yast’s
DHCP Server configuration. The dhcpd.conf entry would
look something like this:
subnet netmask {
Configuring a DHCP Relay
• DHCP packets cannot travel across a router
• A relay agent is necessary in order to have a single DHCP
server handle all leases on both network segments
• The Linux DHCP Relay Agent (dhcrelay) allows you to relay
DHCP and requests from a subnet with no DHCP server on it
to one or more DHCP servers on other subnets.
Configuring a DHCP Relay
• Relay agents receive broadcast DHCP packets and forward
them to a DHCP server.
• When a DHCP client requests information, the DHCP Relay
Agent forwards the request to the list of DHCP servers
specified when the DHCP Relay Agent is started.
• dhcp-relay must be installed (Yast or zypper install)
• To start the DHCP Relay Agent use the command dhcrelay
Single Subnet
dhcpd.conf entry:
subnet netmask {
• One physical network
• One logical subnet
• One DHCP Server
• Single range is used to
service all DHCP
clients on Subnet A
multiple subnets on
same physical network
(aka superscope)
• One physical network
• Multiple logical subnets
dhcpd.conf entry:
shared-network shared {
subnet netmask {
subnet netmask {
subnet netmask {
• Three separate subnets
must be shared
• One DHCP Server services
all clients on Subnet A with
an IP address from the
shared network settings
• Router configured with
multiple addresses to allow
packets to move from one
logical network to another