[Asterisk-code-review] sip_nat_settings: Update script for latest Linux. (asterisk[master])
Alexander Traud
asteriskteam at digium.com
Wed Aug 26 10:42:46 CDT 2020
Alexander Traud has uploaded this change for review. ( 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, 10 insertions(+), 7 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/14/14814/1
diff --git a/contrib/scripts/sip_nat_settings b/contrib/scripts/sip_nat_settings
index 2a4fc07..b8a13f8 100755
--- a/contrib/scripts/sip_nat_settings
+++ b/contrib/scripts/sip_nat_settings
@@ -33,12 +33,12 @@
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`
+if [ -x "${WGET}" ]; then
+ externip=`${WGET} -q -O- http://ipv4.icanhazip.com`
+elif [ -x "${FETCH}" ]; then
+ externip=`${FETCH} -q -o - http://ipv4.icanhazip.com`
else
- echo "no binary found to contact http://www.whatismyip.org"
+ echo "no binary found to contact http://ipv4.icanhazip.com"
exit 1
fi
@@ -49,8 +49,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 | sed -e 's/^.*\sUP\s\s*\([0-9./]*\)\s*$/localnet = \1/'
+ else
+ ip --brief -family inet address show scope global up | sed -e 's/^.*\sUP\s\s*\([0-9./]*\)\s*$/localnet = \1/'
+ 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: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200826/a6f0d934/attachment.html>
More information about the asterisk-code-review
mailing list