Difference between revisions of "DHCP Cisco IOS"

From Teknologisk videncenter
Jump to: navigation, search
(ip helper-address command)
(ip helper-address command)
Line 77: Line 77:
  
 
== DHCP Relay ==
 
== DHCP Relay ==
=== ip helper-address command ===
+
=== ip helper-address command ===<span id="IP HELPER"></span>
<span id="IP HELPER"></span>
 
 
When using a Cisco Router as a DHCP Relay you need to set the '''ip helper-address''' on the interface which receives the broadcast from the DHCP-client and specify the IP-address of the DHCP Server. See example below. R2 Receives the broadcasts on fastethernet 0/0 and need to transmit the request as a unicast to the DHCP-server R1. Se config examples below.
 
When using a Cisco Router as a DHCP Relay you need to set the '''ip helper-address''' on the interface which receives the broadcast from the DHCP-client and specify the IP-address of the DHCP Server. See example below. R2 Receives the broadcasts on fastethernet 0/0 and need to transmit the request as a unicast to the DHCP-server R1. Se config examples below.
  

Revision as of 18:01, 7 February 2009

Comment The information in this article is targeted to Cisco CCNA and CCNP curriculum, and not meant as in-depth information on all IOS

DHCP

See the page DHCP for an explanation of DHCP.

DHCP Server

IOS DHCP Servers service is installed Cisco Router IOS and most Cisco Switch IOS.


DHCP Server example with fixed options

! 
ip dhcp excluded-address 192.168.22.2 192.168.22.99
ip dhcp excluded-address 192.168.22.200 192.168.22.255
!
ip dhcp pool STUDENTS
  network 192.168.22.0 255.255.255.0
  domain-name tekkom.dk
  default-router 192.168.22.1
  dns-server 192.168.22.223 
! 

DHCP Server often used SHOW commands

Show leased addresses

Mercantec#show ip dhcp binding
IP address       Client-ID/Hardware address	 	Lease expiration            Type
192.168.22.100   0063.5972.636f.9da6.                   Jan 25 2009 12:30 AM        Automatic
192.168.22.101   0063.6c72.636f.6e38.                   Jan 25 2009 12:53 AM        Automatic
192.168.22.108   0063.7e7a.636f.247f.                   Jan 25 2009 14:32 AM        Automatic

Show Server statistics

Mercantec#show ip dhcp server statistics
Memory usage         13906
Address pools        1
Database agents      1
Automatic bindings   1
Manual bindings      0
Expired bindings     0
Malformed messages   0

Message              Received
BOOTREQUEST          0
DHCPDISCOVER         1
DHCPREQUEST          1
DHCPDECLINE          0
DHCPRELEASE          0
DHCPINFORM           0

Message              Sent
BOOTREPLY            0
DHCPOFFER            1
DHCPACK              1
DHCPNAK              0


Show imported parameters from DHCP Client

This show command is used to see which DHCP server options that are imported from the Client. For example when connecting to an ISP the DHCP Client receives DNS server IP Addresses, that the inside clients need to use. This information is imported into the DHCP server.

Mercantec#show ip dhcp import
Address Pool Name: Client
Domain Name Server(s): 10.0.0.2
NetBIOS Name Server(s): 10.0.0.2
Domain Name Option: tekkom.dk

DHCP Server Debug commands

Decode DHCP server receptions and transmissions

Mercantec#debug ip dhcp server

DHCP Relay

=== ip helper-address command === When using a Cisco Router as a DHCP Relay you need to set the ip helper-address on the interface which receives the broadcast from the DHCP-client and specify the IP-address of the DHCP Server. See example below. R2 Receives the broadcasts on fastethernet 0/0 and need to transmit the request as a unicast to the DHCP-server R1. Se config examples below.

DHCP Relay example

thumb|none|500px|Example network DHCP Relay

Configuration of R1

hostname R1
! 
ip dhcp excluded-address 192.168.22.1 192.168.22.99
ip dhcp excluded-address 192.168.22.200 192.168.22.255
!
ip dhcp pool STUDENTS
  network 192.168.22.0 255.255.255.0
  domain-name tekkom.dk
  default-router 192.168.22.1
  dns-server 192.168.22.223 
! 
interface fastethernet 0/0
  ip address 172.16.10.1 255.255.255.0


Configuration of R2

hostname R2
!
interface fastethernet 0/0
  ip address 192.168.22.1 255.255.255.0
  ip helper-address 172.16.10.1     
!
interface fastethernet 0/1
  ip address 172.16.10.2 255.255.255.0


DHCP Client

DHCP Client simple example

!
interface FastEthernet0/1
 description Outside: Internet connection to ISP
 ip address dhcp

Examples with Server and Client

DHCP Client and Server with NAT/PAT example

ip dhcp excluded-address 192.168.22.1 192.168.22.99
ip dhcp excluded-address 192.168.22.200 192.168.22.255
!
ip dhcp pool HETH
   network 192.168.22.0 255.255.255.0
   domain-name tekkom.dk
   default-router 192.168.22.1
   dns-server 192.168.22.223
!
interface FastEthernet0/0
 description Inside. Internal LAN
 ip address 192.168.22.1 255.255.255.0
 ip nat inside
!
interface FastEthernet0/1
  description Outside: Internet connection to ISP
 ip address dhcp
 ip nat outside
!
ip nat inside source list 1 interface FastEthernet0/1 overload
!
access-list 1 permit 10.0.0.0 0.255.255.255
access-list 1 permit 172.16.0.0 0.15.255.255
access-list 1 permit 192.168.0.0 0.0.255.255

DHCP Client and Server with NAT/PAT example and import

This example show a typical configuration of a small Internet gateway, which imports the IP-addresses of for example the DNS servers from the ISP.

ip dhcp excluded-address 192.168.22.1 192.168.22.99
ip dhcp excluded-address 192.168.22.200 192.168.22.255
!
ip dhcp pool HETH
   network 192.168.22.0 255.255.255.0
   import all
!
interface FastEthernet0/0
 description Inside. Internal LAN
 ip address 192.168.22.1 255.255.255.0
 ip nat inside
!
interface FastEthernet0/1
  description Outside: Internet connection to ISP
 ip address dhcp
 ip nat outside
!
ip nat inside source list 1 interface FastEthernet0/1 overload
!
access-list 1 permit 10.0.0.0 0.255.255.255
access-list 1 permit 172.16.0.0 0.15.255.255
access-list 1 permit 192.168.0.0 0.0.255.255