dhcp4 icon indicating copy to clipboard operation
dhcp4 copied to clipboard

Use syscall.SO_BINDTODEVICE to only bind on specific interface

Open fdurand opened this issue 8 years ago • 5 comments

Added a way to bind the broadcast socket to the specific interface instead of all interfaces.

fdurand avatar Feb 24 '17 19:02 fdurand

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.

fdurand avatar Mar 07 '17 00:03 fdurand

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...

krolaw avatar Apr 13 '17 20:04 krolaw

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?

krolaw avatar Apr 13 '17 21:04 krolaw

Fixed. Working now after adding broadcast capability to socket.

krolaw avatar Apr 13 '17 22:04 krolaw

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

fdurand avatar May 20 '17 00:05 fdurand