Search code examples
networkingroutesdhcpdd-wrt

Static dhcp lease per interface


Can I force any device plugged into a particular Ethernet port on a router or managed switch to receive a fixed IP address, without knowing its MAC or anything else? I'm thinking there's a way to do this in dd-wrt, but it doesn't need to be that platform. Would need to be able to run it on a managed switch, or at least something with more than four ports. I'd also need to be able to swap them out quickly, so not wait for lease expiry. Don't need a step-by-step solution, just a bearing would help.


Solution

  • Short answer: no.

    Longer answer: Trying to get a certain (reserved) IP address leased to a device on a specific switch port would need to overcome several problems:

    1. The DHCP server doesn't know the switch port of the DHCP client asking for an offer.
    2. The DHCP server doesn't know when a device has disconnected and its lease is potentially free again.

    The closest I can imagine is a separate VLAN per switch port with a single IP address in the VLAN scope and a very short lease time. The DHCP server would also need to be directly connected with each VLAN, alternatively you could use a DHCP agent or relaying on the switch.