Skip to content
Snippets Groups Projects
Commit f225e9bf authored by Alexander Traud's avatar Alexander Traud Committed by Kevin Harwell
Browse files

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
parent 8907a9f0
No related branches found
No related tags found
Loading
...@@ -31,16 +31,8 @@ ...@@ -31,16 +31,8 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
WGET=`which wget` # see http://unix.stackexchange.com/q/22615
FETCH=`which fetch` externip=`dig @resolver1.opendns.com -4 myip.opendns.com A +short`
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
# optional parameter: network interface to use. By default: none. # optional parameter: network interface to use. By default: none.
IFACE="$1" IFACE="$1"
...@@ -49,8 +41,11 @@ OS=`uname -s` ...@@ -49,8 +41,11 @@ OS=`uname -s`
case "$OS" in case "$OS" in
Linux) Linux)
echo "externip = $externip" echo "externip = $externip"
/sbin/ifconfig $IFACE | grep 'inet addr:' | grep Bcast \ if [ -x "${IFACE}" ]; then
| sed -e 's/^.*Bcast:\([0-9.]*\)\s*Mask:\([0-9.]*\)\s*$/localnet = \1\/\2/' 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) OpenBSD|FreeBSD)
if [ "${OS}" = "FreeBSD" ]; then if [ "${OS}" = "FreeBSD" ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment