Can dhcpclient handle broadcasting ?
Hello, I'm trying to use dhcpclient to test broadcasting of a DHCP Discover. I am root so I can use source port 68. I'm sending the packet to the broadcast address. I get the following error (returned by sendmsg, called from "sendfromto"): "Permission denied". Is it possible to use dhcpclient from FreeRADIUS in broadcast mode ? Regards, Nicolas. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
OK, the answer is no. It fails because: "If the socket protocol supports broadcast and the specified address is a broadcast address for the socket protocol, sendmsg() will fail if the SO_BROADCAST option is not set for the socket." The socket set up by dhcpclient.c needs something like this : int so_broadcast = 1; status = setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &so_broadcast, sizeof so_broadcast); De : freeradius-users-bounces+nicolas.chaigneau=capgemini.com@lists.freeradius.org [mailto:freeradius-users-bounces+nicolas.chaigneau=capgemini.com@lists.freeradius.org] De la part de Chaigneau, Nicolas Envoyé : mercredi 9 juillet 2014 09:54 À : freeradius-users@lists.freeradius.org Objet : Can dhcpclient handle broadcasting ? Hello, I'm trying to use dhcpclient to test broadcasting of a DHCP Discover. I am root so I can use source port 68. I'm sending the packet to the broadcast address. I get the following error (returned by sendmsg, called from "sendfromto"): "Permission denied". Is it possible to use dhcpclient from FreeRADIUS in broadcast mode ? Regards, Nicolas. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
Additionally, I've noticed that : - if the client host has multiple interfaces, - and at least one of them already has an IP address, Then the source IP address cannot be 0.0.0.0 (even with "Packet-Src-IP-Address=0.0.0.0"). An actual IP address is automatically used as source.
From what I understand, this is modified by the device driver.
I've first tried to force the interface with setsockopt and option "SO_BINDTODEVICE", but this apparently doesn't do anything useful... So I've done the following: Add an option to dhcpclient allowing to specify which network interface to use. Open a raw socket on the low level packet interface. This allows packet data to be left unchanged by the device driver. Encode Ethernet (send to ff:ff:ff:ff:ff:ff), IP and UDP layers manually. And let FreeRADIUS do the DHCP stuff, as before. (This required new specific socket / send / recv functions.) Maybe there's a better way to do this... I couldn't find one, though. Regards, Nicolas. -----Message d'origine----- De : freeradius-users-bounces+nicolas.chaigneau=capgemini.com@lists.freeradius.org [mailto:freeradius-users-bounces+nicolas.chaigneau=capgemini.com@lists.freeradius.org] De la part de Alan DeKok Envoyé : mercredi 9 juillet 2014 21:37 À : FreeRadius users mailing list Objet : Re: Can dhcpclient handle broadcasting ? Chaigneau, Nicolas wrote:
The socket set up by dhcpclient.c needs something like this :
Yes. It should probably do that automatically if dhcpclient.c detects that the destination address isn't a unicast one. Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
Chaigneau, Nicolas wrote:
Additionally, I've noticed that : - if the client host has multiple interfaces, - and at least one of them already has an IP address, Then the source IP address cannot be 0.0.0.0 (even with "Packet-Src-IP-Address=0.0.0.0"). An actual IP address is automatically used as source. From what I understand, this is modified by the device driver.
Yes.
I've first tried to force the interface with setsockopt and option "SO_BINDTODEVICE", but this apparently doesn't do anything useful...
It works only if you're root. And it should mean that packets sent from the device use the devices IP address.
So I've done the following:
Add an option to dhcpclient allowing to specify which network interface to use.
That's good.
Open a raw socket on the low level packet interface. This allows packet data to be left unchanged by the device driver.
Yes.
Encode Ethernet (send to ff:ff:ff:ff:ff:ff), IP and UDP layers manually. And let FreeRADIUS do the DHCP stuff, as before.
That's how most DHCP clients work. :)
(This required new specific socket / send / recv functions.)
Yes.
Maybe there's a better way to do this... I couldn't find one, though.
Not really. It would have been nice to have a socket API to create packets. Oh well. Alan DeKok.
participants (2)
-
Alan DeKok -
Chaigneau, Nicolas