Cisco and DHCP: static IP-to-host bindings and multiple IPs for a single host

Practice



So, we have a Cisco box and a DHCP server is running on it. I'll assume the server itself is already configured and working, and our task now is to bind a specific IP, which will always stay the same, to a particular computer or host with a specific MAC address.

As a bonus, I'll explain what to do if the host in question moves between several subnets and needs (i.e. the same MAC address needs) to be given a different IP depending on which site it's currently at.


Binding an IP to a MAC

Cisco has pools. Pools hand out IP addresses for a particular subnet. And the notion of a "pool" is normally associated right away with a set of addresses from which the DHCP server will dynamically assign a free one.

However, the notion of "binding" MAC=IP on Cisco is also implemented via pools. And these pools are created in exactly the same way as regular ones, except for one detail: for regular pools we define the "network" directive to specify the subnet to hand out addresses from, whereas for static-binding pools we do NOT use the "network" directive, but instead use "host", adding "client-identifier" to it.

Here's an example of declaring a static MAC-to-IP binding:

CISCO# config t
CISCO(config)# ip dhcp pool MyHost
CISCO(dhcp-config)# host 10.0.99.15 255.255.255.0
CISCO(dhcp-config)# client-identifier 0194.39e5.c0c2.a9
CISCO(dhcp-config)# default-router 10.0.99.1
CISCO(dhcp-config)# dns-server 10.0.0.1 10.0.1.1
CISCO(dhcp-config)# end

Here:
  • host: defines the IP address for this host
  • client-identifier: sets the MAC address to bind by
  • default-router: the default gateway
  • dns-server: the DNS servers

Attention! Look very closely at the client-identifier line. Notice that the MAC address is, for some reason, one "word" longer than it should be? The reason is that we prepended "01" at the front (the actual MAC is 94:39:E5:C0:C2:A9). The thing is, during the request the MAC arrives at Cisco in exactly this form, i.e. with "01" at the front. That's how it arrives from Windows; from Unix-based systems, "00" is prepended instead of "01". Possibly on other hardware the request arrives in yet another form of its own. It's best to first not bind the host, and instead check via
CISCO# sh ip dhcp bind
what form the MAC arrived in.

So, for Windows and BSD/Unix/MacOS the MAC will arrive in the following form:
  • Unix: 0094.39e5.c0c2.a9
  • Windows: 0194.39e5.c0c2.a9


Assigning different IPs to the same host depending on its location

Let's imagine a setup: we have an enterprise with a distributed network. Say that in Office A people use addressing 10.0.10.0/24, and in Office B - 10.0.11.0/24. Office A sits on VLAN10, and Office B - on VLAN11 (this is just an example). Some kind of roaming subnet, for instance, doesn't exist, and employees in Office A can only use addressing from the 10.0.10.0/24 network. Same for Office B.

Now let's imagine an employee with a laptop who works sometimes in Office A, sometimes in Office B. Obviously, this employee needs to be given a different IP depending on where they're currently connected - in Office A or in Office B. For example, in Office A their IP should be 10.0.10.44, and in Office B - IP=10.0.11.44.

How do we configure this on Cisco DHCP?


So, we use two pools - for Office A and for Office B respectively. Naturally, we'll name the pools differently. Below is an example of such a configuration:

CISCO# config t
CISCO(config)# ip dhcp pool MyRoumingHost_OfficeA
CISCO(dhcp-config)# host 10.0.10.44 255.255.255.0
CISCO(dhcp-config)# client-identifier 0194.39e5.c0c2.a9
CISCO(dhcp-config)# default-router 10.0.10.1
CISCO(dhcp-config)# dns-server 10.0.0.1 10.0.1.1
CISCO(dhcp-config)# end
CISCO# config t
CISCO(config)# ip dhcp pool MyRoumingHost_OfficeB
CISCO(dhcp-config)# host 10.0.11.44 255.255.255.0
CISCO(dhcp-config)# client-identifier 0194.39e5.c0c2.a9
CISCO(dhcp-config)# default-router 10.0.11.1
CISCO(dhcp-config)# dns-server 10.0.0.1 10.0.1.1
CISCO(dhcp-config)# end

Simple, isn't it? That is, we created two pools with different names, with the same MAC, but with different network parameters.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Computer networks"

Terms: Computer networks