I am trying to configure DHCP Server on a Cisco 2960-X switch to achieve port-based address allocation. I would like the IP address assigned to any device connected to that port to be the same every time.

I have used the following guide to achieve this: Configuring DHCP Features and IP Source Guard

The commands used are explained in detail here: Cisco IOS IP Addressing Services Command Reference

I have also tried various iterations of the following command to find something that works: address ip-address client-id string [ascii]

What I am not sure about is the string after client-id. Does it have to match your interface name? If not how does the DHCP server know which interface to relate the assigned IP address.

Here's my running-config:

otg#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi1/0/1, Gi1/0/3, Gi1/0/4
                                                Gi1/0/5, Gi1/0/6, Gi1/0/7
                                                Gi1/0/8, Gi1/0/9, Gi1/0/10
                                                Gi1/0/11, Gi1/0/12, Gi1/0/13
                                                Gi1/0/14, Gi1/0/15, Gi1/0/16
                                                Gi1/0/17, Gi1/0/18, Gi1/0/19
                                                Gi1/0/20, Gi1/0/21, Gi1/0/22
                                                Gi1/0/23, Gi1/0/24, Gi1/0/25
                                                Gi1/0/26, Gi1/0/27, Gi1/0/28
2    VLAN0002                         active    Gi1/0/2
140  VLAN0140                         active
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
2    enet  100002     1500  -      -      -        -    -        0      0

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
140  enet  100140     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0
1003 tr    101003     1500  -      -      -        -    -        0      0
1004 fdnet 101004     1500  -      -      -        ieee -        0      0
1005 trnet 101005     1500  -      -      -        ibm  -        0      0


Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------


otg#show ip dhcp pool

Pool otgpool :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0
 Total addresses                : 254
 Leased addresses               : 0
 Excluded addresses             : 1
 Pending event                  : none
 1 subnet is currently in the pool :
 Current index        IP address range                    Leased/Excluded/Total    -   0     / 1     / 254
 1 reserved address is currently in the pool :
 Address          Client  Gi1/0/2


otg#sh run
Building configuration...

Current configuration : 4058 bytes
! Last configuration change at 06:04:30 UTC Tue Jan 5 2016
! NVRAM config last updated at 23:29:56 UTC Mon Jan 4 2016
version 15.0
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
hostname otg
enable secret 5 $1$43Kk$SyzqQc5biarBjD2TD9Hw0/
enable password otgswitch
no aaa new-model
clock timezone UTC -5 0
clock summer-time UTC recurring
switch 1 provision ws-c2960x-24ts-l
ip dhcp use subscriber-id client-id
ip dhcp subscriber-id interface-name
ip dhcp pool otgpool
   address client-id "Gi1/0/2" ascii
crypto pki trustpoint TP-self-signed-1160303744
 enrollment selfsigned
 subject-name cn=IOS-Self-Signed-Certificate-1160303744
 revocation-check none
 rsakeypair TP-self-signed-1160303744
crypto pki certificate chain TP-self-signed-1160303744
 certificate self-signed 01
  3082022B 30820194 A0030201 02020101 300D0609 2A864886 F70D0101 05050030
  31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274
  69666963 6174652D 31313630 33303337 3434301E 170D3136 30313035 30343239
  35365A17 0D323030 31303130 30303030 305A3031 312F302D 06035504 03132649
  4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D31 31363033
  30333734 3430819F 300D0609 2A864886 F70D0101 01050003 818D0030 81890281
  810081CE C80CB939 C1722AA5 E3167E22 23DE4A5F EBB8168C 0DEF4392 F4624590
  11282956 58E0A473 806BBC5E 65E228F4 8FF553ED B1A07A46 CBBC80BA 22C16838
  11EEFA3B 9CD7290D D79CAEDC 4F259F57 8F30CC84 6125CD18 90917913 ECE9B8BA
  DE9F2BDC 21F62BCC 424D5D19 8FEEE8F5 E5A86568 DAF3EE8A 4CD5BE74 63E14AED
  C9BB0203 010001A3 53305130 0F060355 1D130101 FF040530 030101FF 301F0603
  551D2304 18301680 14E50E89 9DFB34B0 F88C367D D1DFE392 1849468B BC301D06
  03551D0E 04160414 E50E899D FB34B0F8 8C367DD1 DFE39218 49468BBC 300D0609
  2A864886 F70D0101 05050003 81810077 5FCAF4BC 7ABCDE2E 69FFB95E 1BBE6CE6
  584B0392 998CD1FB 226E9767 F400304B 36C1692F 54B4CF09 F461AE69 097E47F3
  64D8EB80 4CDB1E87 0FD375A7 DF45B8B0 72B6630E 5D29A00A 1679F321 CBED7B18
  370AC2D0 D8DD2DA5 AF7FECFD 44DE20D0 6D991B2F BFDA7E64 791ACC01 22031B34
  7C1FB7EC C2EAD9DC 45CB4261 00795F
spanning-tree mode pvst
spanning-tree extend system-id
vlan internal allocation policy ascending
interface FastEthernet0
 no ip address
interface GigabitEthernet1/0/1
interface GigabitEthernet1/0/2
 description cart2
 switchport access vlan 2
 switchport mode access
 switchport port-security maximum 2
 switchport port-security
 ip dhcp server use subscriber-id client-id
 storm-control broadcast level 10.00
 storm-control multicast level 10.00
 spanning-tree portfast
 spanning-tree bpduguard enable
interface GigabitEthernet1/0/3
interface GigabitEthernet1/0/4
interface GigabitEthernet1/0/5
interface GigabitEthernet1/0/6
interface GigabitEthernet1/0/7
interface GigabitEthernet1/0/8
interface GigabitEthernet1/0/9
interface GigabitEthernet1/0/10
interface GigabitEthernet1/0/11
interface GigabitEthernet1/0/12
interface GigabitEthernet1/0/13
interface GigabitEthernet1/0/14
interface GigabitEthernet1/0/15
interface GigabitEthernet1/0/16
interface GigabitEthernet1/0/17
interface GigabitEthernet1/0/18
interface GigabitEthernet1/0/19
interface GigabitEthernet1/0/20
interface GigabitEthernet1/0/21
interface GigabitEthernet1/0/22
interface GigabitEthernet1/0/23
interface GigabitEthernet1/0/24
interface GigabitEthernet1/0/25
interface GigabitEthernet1/0/26
interface GigabitEthernet1/0/27
interface GigabitEthernet1/0/28
interface Vlan1
 ip address
interface Vlan2
 ip address
 no ip route-cache
ip default-gateway
ip http server
ip http secure-server
banner motd ^Cto #
line con 0
line vty 0 4
 password otgswitch
line vty 5 15

I then enabled DHCP debug messages and here is what I receive:

Jan 4 02:55:49.112: DHCPD: Reload workspace interface Vlan1 tableid 0.
Jan 4 02:55:49.112: DHCPD: tableid for on Vlan1 is 0
Jan 4 02:55:49.112: DHCPD: client's VPN is .
Jan 4 02:55:49.112: DHCPD: using subscriber-id as client-id
Jan 4 02:55:49.112: DHCPD: using received relay info.
Jan 4 02:55:49.112: DHCPD: DHCPDISCOVER received from client 0047.6931.2f30.2f on interface Vlan1.
Jan 4 02:55:49.112: DHCPD: using received relay info.

otg#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address          Client-ID/              Lease expiration        Type
                    Hardware address/
                    User name       0047.6931.2f30.2f       Jan 09 2016 04:53 AM    Automatic       0047.6931.2f30.2f32     Infinite                Manual

Above we can see that the client id received by dhcp is off by 32 from what we reserved. address client-id Gi1/0/2 ascii

Please advise on what I might be doing wrong. Would appreciate your help.

  • Typically, you don't enclose a string in quotes on IOS. – Ron Maupin Jan 4 '16 at 20:47
  • I didnt enclose it in quotes when setting up in config but when displayed in running config it shows up with quotes. Also I realized if I didnt use quotes I cant leave a space. So I tried various combinations as follows: – Allay Desai Jan 4 '16 at 20:53
  • If you read the debug messages it says received from client on VLAN 1 interface but shouldnt it be saying from GigabitEthernet1/0/x interface. Basically the port interface? This really confuses me. I am not sure what is wrong in my configuration. But it should work on the switch I have. – Allay Desai Jan 4 '16 at 20:55
  • The example shows, ip dhcp relay information policy removal pad, but you don't have that. – Ron Maupin Jan 4 '16 at 21:08
  • Yes I saw that too but that command is not accepted. It will let me do ip dhcp relay information policy replace but not the one mentioned in the document so i skipped it. – Allay Desai Jan 4 '16 at 21:13

Finally solved the problem!! So I was facing problem due to loss of information in the dhcp binding table. In short the subscriber id automatically generated would not match my reservations. Here are some examples:

port#  interface  received SID(hex)      expected SID(hex) 
2      Gi1/0/2    0047-6931-2f30-2f      0047-6931-2f30-2f32 
13     Gi1/0/13   0047-6931-2f30-2f31    0047-6931-2f30-2f31-33 
24     Gi1/0/24   0047-6931-2f30-2f32    0047-6931-2f30-2f32-34 

I was hitting IOS bug present in some 15.0 releases. I updated my ios to 15.2 and problem solved! Thank you for all your help.

| improve this answer | |

ip dhcp subscriber-id interface-name

Automatically generate a subscriber identifier based on the short name of the interface. A subscriber identifier configured on a specific interface takes precedence over this command.

The keyword here is short name. In the example, "Et1/0". So, "Ge1/0/4", etc. Yes, it's case sensitive.

| improve this answer | |
  • Hi thanks for your response. I know there is something wrong with the subscriber-id I am using. In the command [code]address client-id "Gi1/0/4" ascii[/code]. What should i use as the string after client-id for Eg: GigabitEthernet1/0/4. I have tried various combinations but cant seem to get it right. Any thoughts? – Allay Desai Jan 5 '16 at 14:56

Let my show you my confing, this is working. You need tree thinks to work it corrert:

1: ip dhcp use subscriber-id client-id

2: ip dhcp pool Printers network default-router reserved-only address client-id "Fa0/37" ascii address client-id "Fa0/38" ascii address client-id "Fa0/39" ascii address client-id "Fa0/40" ascii address client-id "Fa0/41" ascii address client-id "Fa0/42" ascii address client-id "Fa0/43" ascii

and the most important is to have a virtal interface with IP address:

interface Vlan140 ip address no ip route-cache

| improve this answer | |
  • Hi I tried the setting you suggested but I still have the same error.. I thing you missed the following line [code]ip dhcp subscriber-id interface-name[/code] also do i have to go to each of the port interfaces and use [code]switchport mode access[/code] then [code]switchport access vlan 140[/code] Finally i think what i am getting wrong is the short name for my interface. I have tried so many combination but cant get it right. GigabitEthernet1/0/4 would be? Gi1/0/4, G1/0/4, Ge1/0/4. Please advise. – Allay Desai Jan 5 '16 at 14:47
  • When you get a chance could you please share your running config with me so i can see if there are any additional seetings which are missing in mine. – Allay Desai Jan 5 '16 at 20:40
  • This is the right, you need to write this: Gi1/0/4. sure i can but first try this if you have more virtual interfaces then add this line qith the default GW address: ip default-gateway 10.xxx.xxx.xxx – István Fonyó Jan 6 '16 at 7:31
  • First of all check this after you implemented the config: - Do you have created the VLAN in your device? - Is the physical port in this VLAN – István Fonyó Jan 6 '16 at 7:39
  • Firstly thank you so much for your help. Truly appreciate it. I added the default-gateway just like you suggested and I made sure the new vlan exists and the port is a part of it. Also I used the interface short name Gi1/0/x as suggested by you. But still doesn't work. I have uploaded my entire running-config please have a look maybe you will see something I have missed. You can see it in the question. – Allay Desai Jan 6 '16 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.