::arg().set("urlredirector","Where we send hosts to that need to be url redirected")="127.0.0.1";
::arg().set("smtpredirector","Our smtpredir MX host")="a.misconfigured.powerdns.smtp.server";
::arg().set("local-address","Local IP addresses to which we bind")="0.0.0.0";
+ ::arg().setSwitch("local-address-nonexist-fail","Fail to start if one or more of the local-address's do not exist on this server")="yes";
::arg().set("local-ipv6","Local IP address to which we bind")="";
+ ::arg().setSwitch("local-ipv6-nonexist-fail","Fail to start if one or more of the local-ipv6 addresses do not exist on this server")="yes";
::arg().set("query-local-address","Source IP address for sending queries")="0.0.0.0";
::arg().set("query-local-address6","Source IPv6 address for sending queries")="::";
::arg().set("overload-queue-length","Maximum queuelength moving to packetcache only")="0";
g_localaddresses.push_back(locala);
if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) {
- L<<Logger::Error<<"binding UDP socket to '"+locala.toStringWithPort()+": "<<strerror(errno)<<endl;
- throw PDNSException("Unable to bind to UDP socket");
+ if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-address-nonexist-fail") ) {
+ L<<Logger::Error<<"IPv4 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
+ continue;
+ } else {
+ L<<Logger::Error<<"binding UDP socket to '"+locala.toStringWithPort()+": "<<strerror(errno)<<endl;
+ throw PDNSException("Unable to bind to UDP socket");
+ }
}
d_sockets.push_back(s);
L<<Logger::Error<<"UDP server bound to "<<locala.toStringWithPort()<<endl;
}
g_localaddresses.push_back(locala);
if(::bind(s, (sockaddr*)&locala, sizeof(locala))<0) {
- L<<Logger::Error<<"binding to UDP ipv6 socket: "<<strerror(errno)<<endl;
- throw PDNSException("Unable to bind to UDP ipv6 socket");
+ if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-ipv6-nonexist-fail") ) {
+ L<<Logger::Error<<"IPv6 Address " << localname << " does not exist on this server - skipping UDP bind" << endl;
+ continue;
+ } else {
+ L<<Logger::Error<<"binding to UDP ipv6 socket "<< localname <<": "<<strerror(errno)<<endl;
+ throw AhuException("Unable to bind to UDP ipv6 socket");
+ }
}
d_sockets.push_back(s);
struct pollfd pfd;
}
if(::bind(s, (sockaddr*)&local, local.getSocklen())<0) {
- L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
- throw PDNSException("Unable to bind to TCP socket");
+ if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-address-nonexist-fail") ) {
+ L<<Logger::Error<<"IPv4 Address " << *laddr << " does not exist on this server - skipping TCP bind" << endl;
+ continue;
+ } else {
+ L<<Logger::Error<<"binding to TCP socket " << *laddr << ": "<<strerror(errno)<<endl;
+ throw AhuException("Unable to bind to TCP socket");
+ }
}
listen(s,128);
L<<Logger::Error<<"Failed to set IPv6 socket to IPv6 only, continuing anyhow: "<<strerror(errno)<<endl;
}
if(bind(s, (const sockaddr*)&local, local.getSocklen())<0) {
- L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
- throw PDNSException("Unable to bind to TCPv6 socket");
+ if( errno == EADDRNOTAVAIL && ! ::arg().mustDo("local-ipv6-nonexist-fail") ) {
+ L<<Logger::Error<<"IPv6 Address " << *laddr << " does not exist on this server - skipping TCP bind" << endl;
+ continue;
+ } else {
+ L<<Logger::Error<<"binding to TCPv6 socket" << *laddr << ": "<<strerror(errno)<<endl;
+ throw AhuException("Unable to bind to TCPv6 socket");
+ }
}
listen(s,128);