[Home]

Summary:ASTERISK-18327: [patch] Monitoring own ip with res_stun_monitor fails when local ip changes
Reporter:Wolfram Joost (wjoost)Labels:
Date Opened:2011-08-23 12:07:24Date Closed:2011-12-01 15:17:15.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/res_stun_monitor
Versions:1.8.5.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Linux, kernel 3.0.1, glibc 2.12.2, armAttachments:( 0) asterisk-stun-monitor.diff
( 1) jira_asterisk_18327_v1.8.patch
Description:Monitoring the own ip address with res_stun_monitor fails when the own local ip address changes.

In function stun_start_monitor in file res_stun_monitor.c the socket used to communicate to the stun server is created. Then 'connect' is called for this socket. As a side affect of the connect, the socket gets bound to the ip address of the network interface which is used to communicate to the stun server. If this ip address is changed this socket doesn't work any more because it's still bound to the previous ip address.
In this situation the log shows: "[Aug 23 18:19:42] WARNING[4193]: stun.c:406 ast_stun_request: ast_stun_request send #1 failed error -1, retry".
I use asterisk on my internet router which changes it's ip address every 24hours (forced by the internet provider).
I think the best solution would be not to call connect and use sendto and recvfrom.
Comments:By: Wolfram Joost (wjoost) 2011-08-28 05:32:59.454-0500

Patch against asterisk 1.8.5.0

By: Richard Mudgett (rmudgett) 2011-11-22 18:37:22.001-0600

The [^jira_asterisk_18327_v1.8.patch] file does the following:

Don't keep the STUN socket open between STUN monitor checks.

Keeping the STUN socket always open will cause the STUN monitor to fail if
the STUN server address or our own address changes.  

* Fix the reverse problem of the STUN server address changing after the
initial DNS resolution by using the dnsmgr to refresh the DNS resolution.  
However, refreshing the DNS resolution may not be desireable for all
cases, as a result the stunservermonitor option is added to enable this.  

* Fix ast_stun_request() return value consistency.


By: Richard Mudgett (rmudgett) 2011-11-22 18:46:28.466-0600

Please test.

By: Richard Mudgett (rmudgett) 2011-11-23 17:54:16.820-0600

Use the latest patch from reviewboard:
https://reviewboard.asterisk.org/r/1595/