Use syscall.SO_BINDTODEVICE to only bind on specific interface
Added a way to bind the broadcast socket to the specific interface instead of all interfaces.
Fyi i also added a way to send back raw packet to the client https://github.com/inverse-inc/packetfence/blob/eed0be802f79cc4425011de428a89fc97da30ef2/go/dhcp/rawClient.go the code is not ready and need to be cleaned.
Sorry for the delay.
A client would be awesome. But first I'd like to get the bind socket idea working. I tried the building a bound socket that can be passed as a ServeConn for the Serve command. https://github.com/krolaw/dhcp4/blob/bind2/conn/bound_linux.go
Alas, while I receive packets, my responses fail: write udp 0.0.0.0:67->255.255.255.255:68: sendto: permission denied
No change after I entered the source ip: connIn, err := dhcp.NewUDP4BoundListener("br-lan", "172.30.0.1:67")
Thoughts appreciated...
Just fixed the IP binding, but still not working. I suspect, with an IP it doesn't receive the broadcast packets. Yet without, it can't send. Thoughts?
Fixed. Working now after adding broadcast capability to socket.
Hi, sorry for the delay. In fact on my side i did a function for broadcast and another one for unicast. Broadcast: https://github.com/inverse-inc/packetfence/blob/feature/go_dhcp/go/dhcp/serverif.go#L70 Unicast: https://github.com/inverse-inc/packetfence/blob/feature/go_dhcp/go/dhcp/serverif.go#L70