Skip to content

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

Open
fdurand wants to merge 1 commit into
krolaw:masterfrom
fdurand:syscall.SO_BINDTODEVICE
Open

Use syscall.SO_BINDTODEVICE to only bind on specific interface#31
fdurand wants to merge 1 commit into
krolaw:masterfrom
fdurand:syscall.SO_BINDTODEVICE

Conversation

@fdurand

@fdurand fdurand commented Feb 24, 2017

Copy link
Copy Markdown

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

@krolaw krolaw left a comment

Copy link
Copy Markdown
Owner

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

fdurand commented Mar 7, 2017

Copy link
Copy Markdown
Author

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

krolaw commented Apr 13, 2017

Copy link
Copy Markdown
Owner

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

krolaw commented Apr 13, 2017

Copy link
Copy Markdown
Owner

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

krolaw commented Apr 13, 2017

Copy link
Copy Markdown
Owner

Fixed. Working now after adding broadcast capability to socket.

@fdurand

fdurand commented May 20, 2017

Copy link
Copy Markdown
Author

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