diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c index 14dcaea8060..b9af4e8ea6d 100644 --- a/src/core/tcp_main.c +++ b/src/core/tcp_main.c @@ -2782,6 +2782,13 @@ int tcp_init(struct socket_info* sock_info) /* continue since this is not critical */ } } + + /* Allow bind to non local address. Required when daemon started before network initialized */ + if (setsockopt(sock_info->socket, IPPROTO_IP, IP_FREEBIND, + (void*)&optval, sizeof(optval)) ==-1) { + LM_WARN("setsockopt freebind: %s\n", strerror(errno)); + /* continue since this is not critical */ + } #ifdef HAVE_TCP_DEFER_ACCEPT /* linux only */ if ((optval=cfg_get(tcp, tcp_cfg, defer_accept))){ diff --git a/src/core/udp_server.c b/src/core/udp_server.c index cff4ef0b65c..96ba8ebcf6f 100644 --- a/src/core/udp_server.c +++ b/src/core/udp_server.c @@ -339,6 +339,14 @@ int udp_init(struct socket_info* sock_info) } #endif + /* Allow bind to non local address. Required when daemon started before network initialized */ + optval = 1; + if (setsockopt(sock_info->socket, IPPROTO_IP, IP_FREEBIND, + (void*)&optval, sizeof(optval)) ==-1) { + LM_WARN("setsockopt freebind: %s\n", strerror(errno)); + /* continue since this is not critical */ + } + #ifdef USE_MCAST if ((sock_info->flags & SI_IS_MCAST) && (setup_mcast_rcvr(sock_info->socket, addr, sock_info->mcast.s)<0)){ diff --git a/src/modules/sctp/sctp_server.c b/src/modules/sctp/sctp_server.c index e2301f0e1e6..686139c8350 100644 --- a/src/modules/sctp/sctp_server.c +++ b/src/modules/sctp/sctp_server.c @@ -469,6 +469,14 @@ static int sctp_init_sock_opt_common(int s, int af) } } + /* Allow bind to non local address. Required when daemon started before network initialized */ + optval = 1; + if (setsockopt(s, IPPROTO_IP, IP_FREEBIND, + (void*)&optval, sizeof(optval)) ==-1) { + LM_WARN("sctp_init_sock_opt_common: setsockopt freebind %s\n", strerror(errno)); + /* continue since this is not critical */ + } + /* set receive buffer: SO_RCVBUF*/ if (cfg_get(sctp, sctp_cfg, so_rcvbuf)){ optval=cfg_get(sctp, sctp_cfg, so_rcvbuf);