DNS dinamici: come ottenerli e configurarli: differenze tra le versioni

Riga 57: Riga 57:
...
...
</pre>
</pre>
=== Esempi di script per estrarre l'IP pubblico dal router ===
==== Fritz!Box ====
Quello che segue è un esempio di script per interrogare il proprio router e ottenere l'IP pubblico associato alla sua WAN.
<pre>
#!/bin/bash
#
# Script to fetch external IP from Fritz!Box router, it can be used in the
# configuration of ddclient by adding
#
#    use=cmd, cmd=/path/to/script/fritzbox_ext_ip.sh
#
# Since you need to declare both a username and password in this script,
# restrict file permissions to "600".
# Do not forget to:
# * make this script executable;
# * make sure that both "TR-064" and "UPnP" protocols are enabled in the router;
# "Network --> Network settings --> Access Settings in the Home Network".
# * create a dedicated user on the fritzbox router
# "System --> Fritz!Box users".
# You can substitute your actual router LAN IP to "http://fritz.box" if necessary.
#
curl --anyauth --user nome_utente:password_utente http://fritz.box:49000/upnp/control/wanpppconn1 -H "Content-Type: text/xml; charset="utf-8"" -H "SoapAction:urn:dslforum-org:service:WANPPPConnection:1#GetExternalIPAddress" -d "<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'> <s:Body> <u:GetExternalIPAddress xmlns:u='urn:dslforum-org:service:WANPPPConnection:1'></u:GetExternalIPAddress> </s:Body> </s:Envelope>" | sed -n -e 's#^.*<NewExternalIPAddress>\(.*\)</NewExternalIPAddress>.*$#\1#p'
</pre>
'''NOTE'''
* Sostituire nel soprastante script il nome utente e la password creati per permettere al presente script di interrogare il router. Tali credenziali sono ovviamente associate all'utente "nome_utente" che si suppone essere già stato creato con l'apposità funzionalità del router ("Sistema --> Utenti FRITZ!Box").
* Nel router devono essere spuntate entrambe le seguenti opzioni "Consentire l'accesso alle applicazioni" e "Trasmettere le informazioni di stato tramite UPnP" ("Rete domestica --> Schema rete --> Impostazioni rete")
* Script testato con "''Fritz!Box 7530''" (''Fritz!OS 7.02'').
* Altri script utili per i router Fritz!Box disponibili [https://github.com/elbosso/FritzBoxShell qui]


== Approfondimenti ==
== Approfondimenti ==
2 894

contributi