Preparing the release of v3.9.0
[ddclient.git] / sample-get-ip-from-fritzbox
blob87b986ed95966237f0dd59649670e09280ef89d0
1 #!/bin/bash
2 #
3 # Scirpt to fetch IP from fritzbox
5 # Contributed by @Rusk85 in request #45
6 # Script can be used in the configuration by adding
8 # use=cmd, cmd=/etc/ddclient/get-ip-from-fritzbox
10 # All credits for this one liner go to the author of this blog:
11 # http://scytale.name/blog/2010/01/fritzbox-wan-ip
12 # As the author explains its not required to tamper with the provided IP for the FritzBox
13 # as it always binds to that address for UPnP.
14 # Disclaimer: It might be necessary to make the script executable
16 curl -s -H 'Content-Type: text/xml; charset="utf-8"' \
17 -H 'SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress' \
18 --data-binary '<?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:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1" /></s:Body></s:Envelope>' \
19 http://169.254.1.1:49000/upnp/control/WANCommonIFC1 | \
20 sed -n -e 's#^.*<NewExternalIPAddress>\(.*\)</NewExternalIPAddress>.*$#\1#p'