-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfritzboxip
More file actions
executable file
·33 lines (25 loc) · 862 Bytes
/
Copy pathfritzboxip
File metadata and controls
executable file
·33 lines (25 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
FBIP=192.168.178.1
NETCAT=`which netcat`
[ -z "$NETCAT" ] && NETCAT=`which nc`
[ -z "$NETCAT" ] && exit 1
INTERFACE_NS="urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
WANIP_NS="urn:schemas-upnp-org:service:WANIPConnection:1"
NS="$WANIP_NS"
REQUEST="GetExternalIPAddress"
SED='/^<NewExternalIP/ s,</\?NewExternalIPAddress>,,gp'
BODY="<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">
<s:Body><u:$REQUEST xmlns:u=$NS /></s:Body>
</s:Envelope>
"
LENGTH=`echo -n "$BODY" | wc -c`
( $NETCAT $FBIP 49000 | sed -ne "$SED" ) <<EOF
POST /upnp/control/WANCommonIFC1 HTTP/1.1
Content-Type: text/xml; charset="utf-8"
Connection: close
HOST: $FBIP:49000
Content-Length: $LENGTH
SOAPACTION: "$NS#$REQUEST"
$BODY
EOF