5

This question might stem from a fundamental misunderstanding of IP multicast, so please correct me if I'm off base.

I'm trying to write C code to find the IP address of all the DHCP servers on the network. The use case is this:

  1. Client broadcasts DHCP discover.
  2. My proprietary relay agent picks up the packet, adds some essential information, and forwards it UNICAST to the DHCP server at a known IP address.

The problem I'm having is telling the relay agent where the DHCP server(s) is(are). I found that multicast address 224.0.0.12 is reserved by IANA for DHCP servers, so I figured I'd just configure the servers to listen for that multicast traffic. But whenever I configure a linux socket option to IP_ADD_MEMBERSHIP to 224.0.0.12, it uses IGMP, which is an entirely separate protocol which I don't want to have to implement.

Am I just misunderstanding how multicast works? Shouldn't I be able to send a ping from the relay agent to 224.0.0.12 and have it return a ping response from all DHCP servers?


Additional Info:

  • the interfaces on all the boxes do have MULTICAST listed when I do an ifconfig
  • I have added the multicast route using ip route add 224.0.0.0/4 dev eth0 on all boxes
David Dombrowsky
  • 1,655
  • 3
  • 20
  • 32
  • Could you check that multicast routing is configured? http://www.dancres.org/bjspj/docs/docs/linux.html – ChristopheD May 10 '12 at 16:15
  • could you post the code, so we might find an error in the application ? – dwalter May 10 '12 at 16:42
  • You have to use IGMP for multicast; it does sound like there's perhaps a misunderstanding here. The kernel does all the IGMP for you, just like it does ARP and IP without you worrying about it. The issue is that with broadcast, routing is (fairly) easy: packets just go everywhere. To receive a multicast reply though, you have to accept that IGMP is used, to tell the routers on the network you're interested in the multicast packets. If you don't tell them, how can they know to forward messages on the group to you? DHCP normally uses broadcast though anyway, I think. – Nicholas Wilson May 30 '12 at 15:42
  • No, you should not be able to ping a multicast address and have anyone that's a member of that multicast address respond - that's not how ping and multicast works. Unless you're developing your own OS, you don't have to implement IGMP yourself. You could issue a dhcp query on the _broadcast_ (not multicast) address, and determin the IP address of the DHCP server that responds. – nos Jun 01 '12 at 22:55

2 Answers2

2

Perhaps you should do what clients do - broadcast (not multicast!) on the target network with a DHCPDISCOVER packet? I have a couple of running, working DHCP servers and none of them are listening on the 224 network.

You'll probably also want to either request your existing address, or send along a DHCPRELEASE for any offers you get back, so as not to tie up addresses in fake reservations on the servers.

brepro
  • 143
  • 3
0

In a general IPv4 setting use broadcast to UDP port 67, not multicast. The broadcast request should be answered by all DHCP servers on your network. Take a look at the details explained on the Wikipedia page or read the broadcast explanation in RFC 2131, Section 3. Also see this thread.

Community
  • 1
  • 1
Christian
  • 1,499
  • 2
  • 12
  • 28