Presentation Used in Class

Download Report

Transcript Presentation Used in Class

DHC P
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
otherwise
• When configuring a newly detected card it auto sets itself as a
dhcp client
2
Leasing an IP Address
• An IP address is leased during the boot process
• The overall process is composed of four broadcast
packets:
•
•
•
•
DHCPDISCOVER
DHCPOFFER
DHCPREQUEST
DHCPACK
3
Leasing an IP Address
(continued)
4
Leasing an IP Address
(continued)
• 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
5
Leasing an IP Address
(continued)
• 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.
6
Renewing an IP Address
• The IP address can either be permanent or timed
• A permanent address is never reused for another
client
• 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
request
7
Renewing an IP Address
(continued)
8
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)
9
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
10
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
11
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
lease
• 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.)
12
Files
Server
• /etc/dhcpd.conf – server configuration file
• /var/lib/dhcp/db/dhcpd.leases – stores client leases assigned by
dhcpd
• /etc/sysconfig/network/ifcfg- ethname - stores network card
settings for ethname
• /var/log/rc.dhcpd.log - log file for dhcpd
Client
• /var/lib/dhcpcd/dhcpcd- ethname.info – 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
13
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 {
fixed-address 192.168.1.4;
hardware ethernet 00:A0:78:8E:9E:AA;
}
14
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 192.168.1.0 network, to exclude 192.168.1.101 through
192.168.1.150 from being distributed by the DHCP server, use the ranges
(192.168.1.1 to 192.168.1.100) and (192.168.1.151 to 192.168.1.254)
• Configure multiple ranges in Expert Settings within Yast’s
DHCP Server configuration. The dhcpd.conf entry would
look something like this:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.1 192.168.1.100;
range 192.168.1.150 192.168.1.254;
}
15
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.
16
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
server-ip.
17
Single Subnet
dhcpd.conf entry:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.254;
}
• One physical network
segment
• One logical subnet
(192.168.1.0)
• One DHCP Server
• Single range is used to
service all DHCP
clients on Subnet A
18
Shared-Network
multiple subnets on
same physical network
(aka superscope)
• One physical network
segment
• Multiple logical subnets
dhcpd.conf entry:
shared-network shared {
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.254;
}
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.10 192.168.2.254;
}
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.10 192.168.3.254;
}
}
•
•
•
192.168.1.0
192.168.2.0
192.168.3.0
• 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
19