Thursday, November 21, 2019

Cisco 2960L: simple DHCP port-based ip address allocation, can't do it, help!

tldr; need basic advice on how to setup port-based address allocation on a switch with no router, no dns-server.

Background

I've been using 2960L switches for almost a year now. I use them in a manufacturing scenario where we make "widgets" that have a network interface. During manufacturing, I use the 2960L as a dhcp server and controllable PoE provider. That's it. Just a 2960L, widgets get plugged into the switch, and then a computer (also plugged into switch) runs scripts to power-on the widgets, load software, configure, and test the widgets using the switch as an isolated LAN. Then they're unplugged put in a box and shipped. No router. Nothing talks beyond the switch, except the computer but it uses a second NIC card for that.

It has been working great. And last year folks on r/networking helped me get past the initial Cisco WTF-moments in configuring these switches. I am not a network person, but I just need to do this stuff sometimes as part of my job. Thanks!

Problem

I now need to adapt to a slightly different scenario where, for technical reasons, I would like to use what Cisco calls "DHCP Server Port-based IP Address Allocation". Instead of giving out DHCP addresses tied to device MAC addresses with a lease, I would like to make it so that when I plug a widget into port 1, it gets ip address 192.168.1.1, when I then plug that device (or any device) into port 2, it gets ip address 192.168.1.2. Devices plugged into port 3 gets 192.168.1.3, and so on... up to port 28.

That seems fairly simple, but geezus, it's so hard to understand the Configuration "Guide" (using 15.2(6)E). Getting frustrated and confused.

Here's what I've Tried

I've written a script that flattens the switch down to a factory default and then starts to configure it by assigning it an IP address, hostname, user/password, and enabling ssh. That works. I can even enable DHCP like before. The issue is that I don't understand how I am supposed to set-up the port-based address allocation.

The chapter on this in the guide, tells me to do this...

enable configure terminal ip dhcp use subscriber-id client-id ip dhcp subscriber-id interface-name interface gigabitethernet 0/1 ip dhcp server use subscriber-id client-id 

OK, the next to last line above specifies a particular port. Presumably, I need to do the last two lines for each interface? That seems tedious for 28 ports, but continuing...

interface gigabitethernet 0/2 ip dhcp server use subscriber-id client-id [...] interface gigabitethernet 0/28 ip dhcp server use subscriber-id client-id end 

Still, nothing in there said anything about assigning specific ip addresses to specific ports. Then the guide says...

What to do next

After enabling DHCP port-based address allocation on the switch, use the ip dhcp pool global configuration command to preassign IP addresses and to associate them to clients.

So now it wants me to setup dhcp pools... presumably, that's where I get to assign ip addresses to ports? The instructions say...

For procedures to configure the switch as a DHCP server, see the “Configuring DHCP” section of the “IP addressing and Services” section of the Cisco IOS IP Configuration Guide, Release 12.4.

OK, putting down the configuration guide, and going to another huge manual, the instructions are...

service dhcp ip dhcp pool uutpool network 192.168.1.0 /27 

Here, I am trying to specify a dhcp pool that is just large enough to cover all ports (28). This one will give me 30 ip addresses ranging from 192.168.1.1 to 192.168.1.30. Can I safely assume that it will magically assign each of these to the ports in order so that Gi0/1 gets 192.168.1.1 , Gi0/2 gets 192.168.1.2, and so on? Continuing...

domain-name mycompany.com dns-server 192.168.1.202 end 

Since no traffic that is on this switch is ever going to go outside of the switch, I don't need a gateway, nor do I need a dns-server. I don't know what I am supposed to put for these things. I assigned an ip address for the switch of 192.168.1.200 , and for the gateway, 192.168.1.201 and for the dns-server 192.168.1.202. There's no router and no dns server, of course, but it seems that these things aren't optional so I just set them to something outside of the dhcp pool.

When I try to connect my laptop after configuring the laptop interface to get a DHCP address, it just gets the default 169.254.... address-- so it's not getting an ip address from the switch DHCP server, let alone a port-allocated address. When I give the laptop a static IP, I can ssh to the switch and see the webpage.

I don't see what I am doing wrong here. It should be simple, right? What am I missing? I will gladly paste in my config file if that helps. I am stuck!



No comments:

Post a Comment