Problems with gen_udp on multi-homed hosts

Gregory Haskins gregory.haskins@REDACTED
Tue Nov 16 16:31:47 CET 2010

Hi All,

I am trying to develop a custom DHCP server against 14B on that is
sitting on a multi-homed linux host.  I only want the server to
listen/respond on one of these interfaces, but I am having trouble
getting gen_udp to behave in a way I would expect.

My system has the following interfaces:

3> inet:getiflist().
4> inet:ifget("virbr0", [addr]).
5> inet:ifget("br0", [addr]).

and I am interested in packets only on

So if I gen_udp:open() _without_ {ip, ?ADDR} set, I can see the
broadcasts coming from (as well as from the other
interfaces) as I would expect.  However, the {udp, Socket, ..} message I
get has a inet:sockname() of {}, and if I try to reply with a
broadcast of {} to the same socket, it goes out on the
"br0" interface.

So the obvious solution to me after googling was to use the {ip,
{}} option on the open.  The open() call succeeds with this
option set, but I never see any packets (even though I have sniffed the
line and they are indeed being sent.  As a sanity check, I also set a
bogus IP in the open(), and it does indeed exception out, so it seems
like it is taking the option I set.

I am running out of ideas outside of abandoning gen_udp() in favor of a
ports driver, and/or not writing the DHCP portion of my code in Erlang.
 Neither is particularly attractive, especially given that this seems
like a fairly straight forward sockets app and I would think it could be
made to work.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the erlang-questions mailing list