Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use syscall.SO_BINDTODEVICE to only bind on specific interface #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fdurand
Copy link

@fdurand fdurand commented Feb 24, 2017

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

Copy link
Owner

@krolaw krolaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find! Bit busy with other things, but will look at further as soon as I can.

@fdurand
Copy link
Author

fdurand commented Mar 7, 2017

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.

@krolaw
Copy link
Owner

krolaw commented Apr 13, 2017

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
Copy link
Owner

krolaw commented Apr 13, 2017

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
Copy link
Owner

krolaw commented Apr 13, 2017

Fixed. Working now after adding broadcast capability to socket.

@fdurand
Copy link
Author

fdurand commented May 20, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants