25
DHCP ITL

DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

Embed Size (px)

Citation preview

Page 1: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

DHCP

ITL

Page 2: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 2

Dynamic Host Configuration

• RFC 2131 – DHCP

• RFC 2132 – DHCP Options

• RFC 951 - BOOTP

Page 3: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 3

Overview

• How to Configure Hosts that– Should not store this information (for

manageability)– Cannot store configuration info locally

• RARP – limited usefulness• BOOTP – designed for diskless

workstations• DHCP – update of BOOTP (more options)

Page 4: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 4

DHCP Process Flow

• Client– broadcast dhcpdiscover

– send dhcprequest

– send dhcprelease

• Server(s)

– send dhcpoffer

– send dhcpack

Page 5: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 5

DHCP Process Flow, cont.

• Client renews– broadcast dhcprequest

– send dhcprelease

• Server(s)

– send dhcpack

Page 6: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 6

DHCP Process Flow, cont.

• Client moved– send dhcprequest

– broadcast dhcpdiscover

– send dhcprequest

– send dhcprelease

• Server(s)

– send dhcpnack

– send dhcpoffer

– send dhcpack

Page 7: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 7

DHCP Message Structure

0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | op (1) | htype (1) | hlen (1) | hops (1) | +---------------+---------------+---------------+---------------+ | xid (4) | +-------------------------------+-------------------------------+ | secs (2) | flags (2) | +-------------------------------+-------------------------------+ | ciaddr (4) | +---------------------------------------------------------------+ | yiaddr (4) | +---------------------------------------------------------------+ | siaddr (4) | +---------------------------------------------------------------+ | giaddr (4) | +---------------------------------------------------------------+ | | | chaddr (16) | | | | | +---------------------------------------------------------------+ | | | sname (64) | +---------------------------------------------------------------+ | | | file (128) | +---------------------------------------------------------------+ | | | options (variable) | +---------------------------------------------------------------+

in UDP:

Page 8: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 8

Protocol Fields from RFC2131

• op: Message op code / message type1 = BOOTREQUEST, 2 = BOOTREPLY

• htype: Hardware address type'1' = 10mb ethernet.

• hlen: Hardware address length‘6’ for 10mb ethernet

• hops: Client sets to zero, optionally used by relay agents when booting via a relay agent.

• xid Transaction ID, a random number chosen by the client

Page 9: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 9

Fields cont.

• secs: Filled in by client, seconds elapsed since client began address acquisition or renewal process.

• flags: Used to request broadcast reply• ciaddr: Client IP address; only filled in if client is in

BOUND, RENEW or REBINDING state and can respond to ARP requests.

• yiaddr: 'your' (client) IP address.• siaddr: IP address of next server to use in bootstrap;

returned by server.

Page 10: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 10

Fields cont.

• giaddr: Relay agent IP address

• chaddr: Client hardware address.

• sname: Optional server host name

• file: Boot file name

• Options: Optional parameters field

Page 11: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 11

DHCP Options

• Message Format comes from BOOTP– Boot-request and Boot-reply op codes

• DHCP commands sent as options

• Many other pieces of information can be sent in optional fields

Page 12: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 12

Option Field Structure

• Tag (1 octet)– 0 – pad, 255 – end of options

• Option Length (1 octet), except for 0 & 255

• Option Data

• Tags 128-254 are reserved for “site specific” options, all others are registered

Page 13: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 13

Option Examples

• Tag 1 (Length 4)– Subnet Mask

• Tag 3 (Length 4n)– n Router Addresses

• Tag 53 (Length 1)– DHCP Message Type

Page 14: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 14

Windows 2000/XP/2003Windows 2000 IP Configuration Host Name . . . . . . . . . . . . : hans-laptop1 Primary DNS Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Intel(R) PRO/100+ MiniPCI Physical Address. . . . . . . . . : 00-10-A4-8C-18-7F DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 132.235.74.219 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 132.235.74.254 DHCP Server . . . . . . . . . . . : 132.235.250.15 DNS Servers . . . . . . . . . . . : 132.235.64.1 132.235.64.2 Primary WINS Server . . . . . . . : 132.235.234.235 Secondary WINS Server . . . . . . : 123.235.197.38 Lease Obtained. . . . . . . . . . : Friday, April 20, 2001 08:50:49 Lease Expires . . . . . . . . . . : Friday, April 20, 2001 20:50:49

Page 15: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 15

Ipconfig

USAGE: ipconfig [/? | /all | /release [adapter] | /renew [adapter] | /flushdns | /registerdns | /showclassid adapter | /setclassid adapter [classidtoset] ]

adapter Full name or pattern with '*' and '?' to 'match', * matches any character, ? matches one character. Options /? Display this help message. /all Display full configuration information. /release Release the IP address for the specified adapter. /renew Renew the IP address for the specified adapter. /flushdns Purges the DNS Resolver cache. /registerdns Refreshes all DHCP leases and re-registers DNS names /displaydns Display the contents of the DNS Resolver Cache. /showclassid Displays all the dhcp class IDs allowed for adapter. /setclassid Modifies the dhcp class id.

Page 16: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 16

FreeBSD

• /sbin/dhclient (see man dhclient)– dhclient -r

• Release address and exit

– dhclient normally starts at boot and uses dhclient.conf to determine which interfaces to request addresses on.

Page 17: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 17

Mac OS X

• GUI– Turn interface off and back on

• Reinitializes loadable kernel module and renews DHCP

• /usr/sbin/ipconfig (???…)– ipconfig set interface mode

switches interface settings (e.g. from DHCP to MANUAL and back)

Page 18: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 18

Solaris

• Two methods

– Set up to use DHCP at boot-up

– Do it by hand

Page 19: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 19

Make Solaris reboot into DHCP

• Unix likes to use file-based mechanisms

• For Solaris– create a file /etc/dhcp.le0 (or whatever the

interface is called)• usually by touch /etc/dhcp.le0

• note: the file /etc/hostname.le0 must exist

– Reboot– Note: this is not how we do it in the lab

Page 20: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 20

Set up Solaris/DHCP by hand

• Create the interface– ifconfig le0 plumb

• Start the DHCP client (Solaris calls it agent)– /sbin/dhcpagent &

• see next page for debug options

• Put the interface under DHCP control– ifconfig le0 dhcp start

Page 21: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 21

Other Controls

• ifconfig le0 dhcp extend ‘extend the lease

• ifconfig le0 dhcp release ‘release the address and down the interface

• ifconfig le0 dhcp status ‘get information

• /sbin/dhcpagent -d1 -f

• /sbin/dhcpagent -f -v– both run the DHCP agent in the foreground and request

diagnostic information. The latter form is most useful to watch the DHCP process.

Page 22: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 22

DHCP Server on BSD

NAME

dhcpd - Dynamic Host Configuration Protocol Server

SYNOPSIS

dhcpd [ -p port ] [ -f ] [ -d ] [ -q ] [ -cf config-file ]

[ -lf lease-file ] [ if0 [ ...ifN ] ]

See “man dhcpd” and “man dhcpd.conf”

Page 23: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 23

simple dhcpd.conf file

subnet 239.252.197.0 netmask 255.255.255.0 {

range 239.252.197.10 239.252.197.250;

}

See “man dhcpd.conf”

Page 24: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 24

More Complete

subnet 239.252.197.0 netmask 255.255.255.0 {

range 239.252.197.10 239.252.197.250;

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

option subnet-mask 255.255.255.0;

option broadcast-address 239.252.197.255;

option routers 239.252.197.1;

option domain-name-servers 239.252.197.2, 239.252.197.3;

option domain-name "isc.org";

}# Note: there is a typo in the man page

Page 25: DHCP ITL. ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman2 Dynamic Host Configuration RFC 2131 – DHCP RFC 2132 – DHCP Options RFC 951 - BOOTP

ITL: ©2000-2005 Hans Kruse, Shawn Ostermann, Carl Bruggeman 25

The Relay

buell(if-config)#ip helper-address ?

A.B.C.D IP destination address

Router

DHCPServer

Client