* dnsmasq doesn't have bind-dynamic, only allow listening on
* private/local IP addresses (see RFC1918/RFC3484/RFC4193)
*/
- if (!virSocketAddrIsPrivate(&tmpipdef->address)) {
+ if (!dnsmasqCapsGet(caps, DNSMASQ_CAPS_BINDTODEVICE) &&
+ !virSocketAddrIsPrivate(&tmpipdef->address)) {
unsigned long version = dnsmasqCapsGetVersion(caps);
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Publicly routable address %s is prohibited. "
"The version of dnsmasq on this host (%d.%d) "
- "doesn't support the bind-dynamic option, "
- "which is required for safe operation on a "
- "publicly routable subnet "
+ "doesn't support the bind-dynamic option or "
+ "use SO_BINDTODEVICE on listening sockets, "
+ "one of which is required for safe operation "
+ "on a publicly routable subnet "
"(see CVE-2012-3411). You must either "
"upgrade dnsmasq, or use a private/local "
"subnet range for this network "
if (strstr(buf, "--bind-dynamic"))
dnsmasqCapsSet(caps, DNSMASQ_CAPS_BIND_DYNAMIC);
- VIR_INFO("dnsmasq version is %d.%d, --bind-dynamic is %s",
- (int)caps->version / 1000000, (int)(caps->version % 1000000) / 1000,
- dnsmasqCapsGet(caps, DNSMASQ_CAPS_BIND_DYNAMIC)
- ? "present" : "NOT present");
+ /* if this string is a part of the --version output, dnsmasq
+ * has been patched to use SO_BINDTODEVICE when listening,
+ * so that it will only accept requests that arrived on the
+ * listening interface(s)
+ */
+ if (strstr(buf, "--bind-interfaces with SO_BINDTODEVICE"))
+ dnsmasqCapsSet(caps, DNSMASQ_CAPS_BINDTODEVICE);
+
+ VIR_INFO("dnsmasq version is %d.%d, --bind-dynamic is %spresent, "
+ "SO_BINDTODEVICE is %sin use",
+ (int)caps->version / 1000000,
+ (int)(caps->version % 1000000) / 1000,
+ dnsmasqCapsGet(caps, DNSMASQ_CAPS_BIND_DYNAMIC) ? "" : "NOT ",
+ dnsmasqCapsGet(caps, DNSMASQ_CAPS_BIND_DYNAMIC) ? "" : "NOT ");
return 0;
fail:
typedef enum {
DNSMASQ_CAPS_BIND_DYNAMIC = 0, /* support for --bind-dynamic */
+ DNSMASQ_CAPS_BINDTODEVICE = 1, /* uses SO_BINDTODEVICE for --bind-interfaces */
DNSMASQ_CAPS_LAST, /* this must always be the last item */
} dnsmasqCapsFlags;