7

I am trying to get my DHCP server (isc-dhcpd-4.1.1-P1) in CentOS to give the same IP and hostname to two different MAC addresses (LAN and WLAN) on the same computer depending on which is connected..

This is my entry in dhcpd.conf

host hostname.my.domain {
        option host-name hostname;
        hardware ethernet xx:xx:xx:xx:xx:xx;
        fixed-address 10.0.1.134;
}

I've tried adding a second hardware line and adding the second MAC to the first hardware line. Neither worked. Does anyone have an idea how I can accomplish this task while using the same hostname and IP in DHCPd?

EDIT: My users bring their laptops into work. I want to make sure, whether they use our Wireless or LAN to connect to the network that their device gets the same IP address. I want to do this because I'm running out of IP addresses on my current internal ClassC.

Albion
  • 465
  • 2
  • 6
  • 16

1 Answers1

12
host hostname-primary.my.domain {
    option host-name hostname;
    hardware ethernet xx:xx:xx:xx:xx:xx;
    fixed-address 10.0.1.134;
}
host hostname-secondary.my.domain {
    option host-name hostname;
    hardware ethernet yy:yy:yy:yy:yy:yy;
    fixed-address 10.0.1.134;
}

Just for the record... You are opening yourself for an IP address conflict, but I am sure you have a very valid reason for doing something like this.

Daniel Widrick
  • 3,418
  • 2
  • 12
  • 26
  • My users bring their laptops into work. I want to make sure, whether they use our Wireless or LAN to connect to the network that their device gets the same IP address. I want to do this because I'm running out of IP addresses on my current internal ClassC. (I also added this to the text of the post) – Albion Feb 27 '14 at 17:15
  • If users enable their wireless and plug in you could have a problem. Ensure DHCP does the ping-before-offer thing. And I would begin formulating a plan to move to a larger subnet soon. Migrating to a larger subnet is a cleaner solution. – Daniel Widrick Feb 27 '14 at 17:19
  • I use this in for a PXE network with clonezilla, so i can restore systems back. Each IP have one special image to restore and i can group on the same ip the workstations and laptops of each department or role. As only 3 people can do this, the ip collision is very rare and with little importance – higuita Oct 21 '14 at 11:38
  • Giving the same IP address to two interfaces *on the same host* works without problems. You only have a problem if two *different* hosts get the same address. – Matthias Urlichs Feb 12 '15 at 18:10
  • Just as a follow up. Giving a duplicate IP out on a wired and on a wireless interface will surely cause some interesting problems in the network eventually. Especially when ARP shows up and the device in question starts responding to other nodes on a hardware address that isn't in the arp table. Your layer 3 - layer 4 translations will be a right mess. – Daniel Widrick Jun 06 '17 at 03:43
  • I found this thread because I have a similar issue, but on a personal network. Our home is "ridiculously computerized," as the landlord says. In addition to having limited addresses on a class-C network, I want to be able to connect to my devices via SSH without having to first figure out whether they're wired or wireless. Since we might end up with redundant connections this way, is it possible to automatically disconnect wireless clients when they plug in their wired connections? I feel like this answer is incomplete without an explanation of how to overcome these difficulties if possible. – StarCrashr Sep 23 '18 at 16:44
  • I found this thread because I too have a similar question. Here is why this is important to me and why this is a valid use case. In my deployment we're using bonding to enslave two interfaces as one. Some of the bonding modes change the mac of the bond to that of the slave during an activation event. In fact some modes actively load balance (balance-alb) using mac hashing tables. For this reason some servers using configurations like these may have multiple mac address for a single bond interface and depending on the the path the dhcp request used. Thank you! – Vex Mage Jan 16 '20 at 19:20
  • There is another reason to need this: when you have a bonded interface of two physical NICs, and the software in the host (aka Windows Server) is not able to acquire the DHCP IP with the first NIC only, you randomly get the request from one MAC or the other, but you still want the server to have a single IP... – David Aparicio May 17 '21 at 20:55