dhcp
dhcp copied to clipboard
Existing check that c.ifaceHWAddr == msg.ClientHWAddr
Hi,
In dhcpv4/nclient4/client.go:receiveLoop() there is a check that if a client MAC address is included in an incoming packet and if that client MAC address does not match the local bound interface then the packet is discarded. There is also an accompanying comment:
// This is a somewhat non-standard check, by the looks
// of RFC 2131. It should work as long as the DHCP
// server is spec-compliant for the HWAddr field.
if c.ifaceHWAddr != nil && !bytes.Equal(c.ifaceHWAddr, msg.ClientHWAddr) {
// Not for us.
continue
}
My question is this 'non-standard' check needed at all? In my own case I'm trying to use the package as a form of DHCP relay, where it issues DHCP messages on behalf of multiple 'virtual' clients, identified by the ClientHWAddr field which has a modifier applied to it, but at the network layer it uses the same physical MAC address. Ie the clientHWAddresses are many any varied and never matches the single c.ifaceHWAddr. The check above prohibits me using the package in this way. If I comment out the check all works, in the way I'm using it anyway.
In other more standard scenarios than mine, can we not rely on the NIC filtering incoming unwanted dest MAC addresses from reaching the DHCP client?
Thanks
I'm trying to use the package as a form of DHCP relay
This is a client after all and not a relay. I think it may be fair to make it configurable and have an option to disable it if you know what you are doing (relay).
can we not rely on the NIC filtering incoming unwanted dest MAC addresses from reaching the DHCP client?
This is filtering at the DHCP packet content level and not MAC layer.
Hi,
That would be great if it was made an option as you suggest. Defaulting to keeping the existing check of course.
Would be much appreciated if that could be done in due course?
Many thanks in advance