Update external address automatically on failover - Q for a dev

Assuming that your CGNAT doesn’t cause an issue with source port rewriting, see

for a way to automatically update Asterisk when your public IP address changes.

My perl script in that thread uses a list of public STUN servers to detect IP address changes. This was made several years ago, so I ran a test to see how many are still working. I found 64; you may wish to update the stunlist.txt file with this data:

77.72.169.211:3478
77.72.169.212:3478
212.227.67.34:3478
81.187.30.115:3478
85.17.88.164:3478
85.214.119.212:3478
88.218.220.40:3478
94.23.17.185:3478
91.151.52.200:3478
217.74.179.29:3478
213.140.209.236:3478
212.227.67.33:3478
77.72.169.213:3478
138.201.60.199:3478
213.251.48.147:3478
216.93.246.18:3478
45.15.102.34:3478
83.125.8.47:3478
138.201.243.186:3478
23.253.102.137:3478
143.198.60.79:3478
193.43.148.37:3478
52.76.91.67:3478
195.242.206.1:3478
77.72.169.210:3478
194.169.214.30:3478
193.28.184.4:3478
176.62.31.10:3478
142.250.21.127:19302
51.89.71.129:3478
111.206.174.2:3478
92.222.127.114:3478
185.88.7.40:3478
109.68.96.189:3478
139.162.62.29:3478
185.39.86.17:3478
195.254.254.20:3478
23.21.92.55:3478
35.158.233.7:3478
91.217.201.14:3478
104.45.13.239:3478
212.45.38.40:3478
212.101.4.120:3478
52.24.174.49:3478
161.53.1.100:3478
217.0.12.1:3478
85.93.219.114:3478
82.97.157.254:3478
82.113.193.63:3478
154.73.34.8:3478
64.131.63.217:3478
70.42.198.30:3478
66.51.128.11:3478
20.93.239.173:3478
83.211.9.232:3478
185.125.180.70:3478
194.61.59.25:3478
195.35.115.37:3478
193.22.119.20:3478
185.45.152.22:3478
74.125.197.127:19302
172.217.199.127:19302
142.251.2.127:19302
172.253.127.127:19302

If you modify the perl script to make it more robust or otherwise improve it, I would greatly appreciate it if you post the update here.