[Asterisk-code-review] sip_nat_settings: Update script for latest Linux. (asterisk[master])
Kevin Harwell
asteriskteam at digium.com
Fri Aug 28 15:48:52 CDT 2020
Kevin Harwell has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14814 )
Change subject: sip_nat_settings: Update script for latest Linux.
......................................................................
sip_nat_settings: Update script for latest Linux.
With the latest Linux, 'ifconfig' is not installed on default anymore.
Furthermore, the output of the current net-tools 'ifconfig' changed.
Therefore, parsing failed. This update uses 'ip addr show' instead.
Finally, the service for the external IP changed.
Change-Id: I9b1a7c3f457e3553b50a3e9a55524e40d70245a0
---
M contrib/scripts/sip_nat_settings
1 file changed, 7 insertions(+), 12 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, approved; Approved for Submit
George Joseph: Looks good to me, but someone else must approve
diff --git a/contrib/scripts/sip_nat_settings b/contrib/scripts/sip_nat_settings
index 2a4fc07..444fb67 100755
--- a/contrib/scripts/sip_nat_settings
+++ b/contrib/scripts/sip_nat_settings
@@ -31,16 +31,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-WGET=`which wget`
-FETCH=`which fetch`
-if [ -x ${WGET} ]; then
- externip=`${WGET} -q -O- http://www.whatismyip.org`
-elif [ -x ${FETCH} ]; then
- externip=`${FETCH} -q -o - http://www.whatismyip.org`
-else
- echo "no binary found to contact http://www.whatismyip.org"
- exit 1
-fi
+# see http://unix.stackexchange.com/q/22615
+externip=`dig @resolver1.opendns.com -4 myip.opendns.com A +short`
# optional parameter: network interface to use. By default: none.
IFACE="$1"
@@ -49,8 +41,11 @@
case "$OS" in
Linux)
echo "externip = $externip"
- /sbin/ifconfig $IFACE | grep 'inet addr:' | grep Bcast \
- | sed -e 's/^.*Bcast:\([0-9.]*\)\s*Mask:\([0-9.]*\)\s*$/localnet = \1\/\2/'
+ if [ -x "${IFACE}" ]; then
+ ip --brief -family inet address show scope global up dev $IFACE | awk '{print "localnet = " $3}'
+ else
+ ip --brief -family inet address show scope global up | awk '{print "localnet = " $3}'
+ fi
;;
OpenBSD|FreeBSD)
if [ "${OS}" = "FreeBSD" ]; then
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14814
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I9b1a7c3f457e3553b50a3e9a55524e40d70245a0
Gerrit-Change-Number: 14814
Gerrit-PatchSet: 4
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200828/f4cd9ed3/attachment.html>
More information about the asterisk-code-review
mailing list