Wie kann ich die IP-Addresse mit meinem PI zu meiner 1&1 Domain senden?

Über die Domain ^^
Meine Website war schon länger erreichbar. Ich meine vor den 48 Stunden, aber die Profilseite bei 1und1 wurde ne weile nicht aktualisiert ^^
 
Ohh achso..
Mir ist aufgefallen, dass meine IPv4-Addresse irgendwie nicht verfügbar ist. Im router kann ich sie einsehen. Mit curl ipinfo.io auch.
Aber nicht mit ipconfig /all, wieistmeineip.net oder http://icanhazip.com nicht. Letzteres wird ja im Script verwendet. (Ich glaube deswegen funktioniert noip2 auch nicht).
Sollte ich im Script nicht vielleicht auch curl ipinfo.io verwenden?
 
Jap kannste,
einfach
Code:
WANIPSITE="http://icanhazip.com"
durch
Code:
WANIPSITE="ipinfo.io/ip"
ersetzen

Edit: habe gerade in einen deiner vorherigen Post gesehen, das bei deinen Code CFID Fragezeichenstehen, das kann man leer lassen, also
Code:
CFID=
Also CFID= und danach nichts in der Zeile

Was gibt das Script eigentlich für eine Rückmeldung wenn de es ausführst?

Denn wenn die CFID nicht eingetragen wird zeigt das Script die an und Updatet die IP trotzdem.
Die angezeigte CFID kannste dann auch in das Script einfügen
 
Zuletzt bearbeitet:
Effektiv hat sich noch nichts geändert.
Kann ich so das Script etwas ausgeben lassen?
*/1 * * * * /usr/local/bin/cf-ddns.sh >> /var/log/dyndns.log
 
du kanns in das verzeichnis vom Script wechseln und
Code:
./scriptname.sh -f true
eingeben das -f true ist dafür, das auch die IP geupdatet wird, falls die immer noch die gleiche IP wie vorher ist.

Das Script wird schon sagen wenn was Falsch ist

Edit habe es mal getestet, mit:
*/1 * * * * /usr/local/bin/cf-ddns.sh >> /var/log/dyndns.log
wird etwas ins log geschrieben.

PS: bei mir kommt:
Code:
Missing DNS record IDfetching from Cloudflare...
 => Found CFID=56778800 , advising to save this to [COLOR=#000000]/usr/local/bin/cf-ddns.sh or set it using the -i flag
Updating DNS to 188.186.36.77

Updated succesfuly!

Habe oben natürlich CFID und IP geändert :P

Die CFID die dort angezeigt wird kannste dann auch im Script einfügen

Wenn die CFID im Script eingeben wurde kommt das:
Code:
Updating DNS to 188.186.36.77[COLOR=#000000]Updated succesfuly!

Wenn das hier kommt, dann hat sich die IP seit dem letzten ausführen nicht geändert:
Code:
WAN IP Unchanged, to update anyway use flag -f trueWAN IP Unchanged, to update anyway use flag -f true[COLOR=#000000]

mit
Code:
[COLOR=#000000]*/1 * * * * /usr/local/bin/cf-ddns.sh -f true [COLOR=#000000]>> /var/log/dyndns.log[COLOR=#000000]
Wird die IP immer geupdatet, egal ob die IP die gleiche ist wie beim letzten ausführen
 
Zuletzt bearbeitet:
du kanns in das verzeichnis vom Script wechseln und
Code:
./scriptname.sh -f true
eingeben das -f true ist dafür, das auch die IP geupdatet wird, falls die immer noch die gleiche IP wie vorher ist.

Das Script wird schon sagen wenn was Falsch ist
Es sagt immer "Permission Denied"

Edit habe es mal getestet, mit:
*/1 * * * * /usr/local/bin/cf-ddns.sh >> /var/log/dyndns.log
wird etwas ins log geschrieben.

PS: bei mir kommt:
Code:
Missing DNS record IDfetching from Cloudflare...
 => Found CFID=56778800 , advising to save this to /home/axiomgarden/cloudflare_ddns.sh or set it using the -i flag
Updating DNS to 188.186.36.77

Updated succesfuly!

Habe oben natürlich CFID und IP geändert :P

Die CFID die dort angezeigt wird kannste dann auch im Script einfügen

Wenn die CFID im Script eingeben wurde kommt das:
Code:
Updating DNS to 188.186.36.77[COLOR=#000000]Updated succesfuly![COLOR=#000000]

Im log erscheint leider nichts. Wahrscheinlich, weil der Zugriff verweigert wird (bin doch root)
 
xD daher weht der Wind ganz vergessen, mit

Code:
chmod +x ​/usr/local/bin/cf-ddns.sh

das Script ausführbar machen, sonst geht natürlich nichts :ugly:

Ach noch was, du kannst auch statt:
-f true
im Script auch das

FORCE=false

in

FORCE=true

ändern
 
Zuletzt bearbeitet:
Okay :p

jetzt kommt:
root@piserver:/# /usr/local/bin/cf-ddns.sh
WAN IP Unchanged, to update anyway use flag -f true
root@piserver:/# /usr/local/bin/cf-ddns.sh -f true
Missing DNS record ID
fetching from Cloudflare...
=> Found CFID=1187842744 , advising to save this to /usr/local/bin/cf-ddns.sh or set it using the -i flag
Updating DNS to 91.1.40.12
Updated succesfuly!

Die A www ip wurde auf CloudFlare nun geupdated :D
Aufrufbar ist die Seite über die Domain immernoch nicht
 
habs zu FORCE = true geändert.
Über die IP (91.1.40.12) kann ich die Seite aufrufen.
Nur nicht über die Domain. Da kommt so eine default-Seite von 1&1
err.PNG

Was könnte am PI falsch eingestellt sein?
 
Habe mal von oben Kopiert
Vielleicht kein Virtual Host in Apache eingestellt oder falsch?

How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS | DigitalOcean

Vielleicht auch was anderes

Also die Kurzform des Artikels:
Code:
[COLOR=#000000]cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/[COLOR=#E94849]deinedomain.net[COLOR=#000000].conf
Code:
[COLOR=#000000]nano /etc/apache2/sites-available/[COLOR=#E94849]deinedomain.net[COLOR=#000000].conf
Das hier ändern
Code:
<VirtualHost *:80>    ServerName [COLOR=#E94849]deinedomain.net    ServerAlias [COLOR=#E94849]www.deinedomain.net    DocumentRoot /var/www/example.com/public_html  [COLOR=#E94849]<hier den Pfad zur Website auf deiner Pi    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

und dann das ganze aktivieren
Code:
[COLOR=#000000]a2ensite [COLOR=#E94849]deinedomain.net[COLOR=#000000].conf

und danach Apache restarten

Code:
/etc/init.d/apache2 restart
 
Zuletzt bearbeitet:
habe keine 000-default.conf.
Liegt das vllt daran, dass ich Debian anstelle von Ubuntu nutze?

In apache2.conf befindet sich ganz unten:
# Include the virtual host configurations:
Include sites-enabled/
Include /etc/phpmyadmin/apache.conf

Im Ordner sites-enabled ist eine Verknüpfung zu 000-default.

EDIT: ok, habe nun wildcards mit follow-the-white-rabbit.net.conf
 
Zuletzt bearbeitet:
Wohin geht die Verknüpfung genau?
Theoretisch ist wenn ne Verknüpfung da ist auch die Datei da, außer die geht ins leere
Ich habe mal schnell Apache installiert in meiner 000-default ist das hier
Code:
<VirtualHost *:80>    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com


    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>



# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


Also ganz anders ausgedrückt kann man theoretisch die Datei einfach mit diesen Inhalt erstellen:
Code:
[COLOR=#000000]<VirtualHost *:80>
    ServerName [COLOR=#E94849]deinedomain.net    ServerAlias [COLOR=#E94849]www.deinedomain.net    DocumentRoot /var/www/example.com/public_html  [COLOR=#E94849]<hier den Pfad zur Website auf deiner Pi    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
 [COLOR=#000000]</VirtualHost>

 
Zuletzt bearbeitet:
Bin der Verknüpfung gefolgt und konnte dem Tutorial etwas weiter folgen. Da es schon einen Ordner für alle Web-Dokumente gibt, musste ich es etwas anpassen.
Habe nun wildcards for follow-the-white-rabbit.net.conf angelegt:

Code:
root@piserver:/# sudo a2ensite                                                  Your choices are: default default-ssl follow-the-white-rabbit.net.conf
Which site(s) do you want to enable (wildcards ok)?
follow-the-white-rabbit.net.conf
Enabling site follow-the-white-rabbit.net.conf.
To activate the new configuration, you need to run:
  service apache2 reload
root@piserver:/# service apache2 reload
[....] Reloading web server config: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
. ok

Bin den Rest gefolgt, aber immernoch das selbe Problem :(
 
Oh ich sehe, scheint wie auch immer, jetzt zu funktionieren :ugly:

Glückwunsch, wie das auch gelöst wurde
 
Zuletzt bearbeitet:
Oh ich sehe, scheint wie auch immer, jetzt zu funktionieren :ugly:

Glückwunsch, wie das auch gelöst wurde

Ich hab nixgemacht. Bin nur schlafen gegangen. (vllt ist das die Lösung aller Probleme)

Trotzdem Danke für die Hilfe =)

Ich glaube das Problem war, dass ich aus Gewohnheit immer die Domain ohne www davor angegeben hab. So funktioniert es immernoch nicht. Aber mit www. davor schon =)
Ich teste gerade mal, ob der Cronjob auch wirklich funktioniert.. Hab ne random IP bei CloudFlare eingeben und schaue, ob sie vom Pi zurückgesetzt wird. Nicht wundern, wenn meine Website kurz nicht erreichbar sein sollte
 
Du könntest auch das Script nochmal erstellen unter anderen Namen, das auch die Domain ohne www aktualisiert wird.
Code:
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail


# Automatically update your CloudFlare DNS record to the IP, Dynamic DNS
# Can retrieve cloudflare Domain id and list zone's, because, lazy


# Place at:
# /usr/local/bin/cf-ddns.sh
# run `crontab -e` and add next line:
# 0 * * * * /usr/local/bin/cf-ddns.sh >/dev/null 2>&1


# run /usr/local/bin/cf-ddns.sh in terminal to check all settings are valid


# Usage:
# cf-ddns.sh -k cloudflare-api-key \
#            -u user@example.com \
#            -h host.example.com \     # fqdn of the record you want to update
#            -z example.com \          # will show you all zones if forgot, but you need this


# Optional flags:
#            -i cloudflare-record-id \ # script will show this
#            -a true|false \           # auto get zone list and record id
#            -f false|true \           # force dns update, disregard local stored ip


# default config


# API key, see https://www.cloudflare.com/a/account/my-account,
# incorrect api-key results in E_UNAUTH error
CFKEY=


# Zone name, will list all possible if missing, eg: example.com
CFZONE=


# Domain id, will retrieve itself by default
CFID=


# Username, eg: user@example.com
CFUSER=


# Hostname to update, eg: homeserver.example.com
CFHOST=


# Cloudflare TTL for record, between 120 and 86400 seconds
CFTTL=120
# Get domain ID from Cloudflare using awk/sed and python json.tool
GETID=true
# Ignore local file, update ip anyway
FORCE=true
# Site to retrieve WAN ip, other examples are: bot.whatismyipaddress.com, https://api.ipify.org/ ...
WANIPSITE="ipinfo.io/ip"


# get parameter
while getopts a:k:i:u:h:z:f: opts; do
  case ${opts} in
    a) GETID=${OPTARG} ;;
    k) CFKEY=${OPTARG} ;;
    i) CFID=${OPTARG} ;;
    u) CFUSER=${OPTARG} ;;
    h) CFHOST=${OPTARG} ;;
    z) CFZONE=${OPTARG} ;;
    f) FORCE=${OPTARG} ;;
  esac
done


# If required settings are missing just exit
if [ "$CFKEY" = "" ]; then
  echo "Missing api-key, get at: https://www.cloudflare.com/a/account/my-account"
  echo "and save in ${0} or using the -k flag"
  exit 2
fi
if [ "$CFUSER" = "" ]; then
  echo "Missing username, probably your email-address"
  echo "and save in ${0} or using the -u flag"
  exit 2
fi
if [ "$CFHOST" = "" ]; then 
  echo "Missing hostname, what host do you want to update?"
  echo "save in ${0} or using the -h flag"
  exit 2
fi


# If the hostname is not a FQDN
if [ "$CFHOST" != "$CFZONE" ] && ! [ -z "${CFHOST##*$CFZONE}" ]; then
  CFHOST="$CFHOST.$CFZONE"
  echo " => Hostname is not a FQDN, assuming $CFHOST"
fi


# If CFZONE is missing, retrieve them all from CF
if [ "$CFZONE" = "" ]; then
  echo "Missing zone"
  if ! [ "$GETID" == true ]; then exit 2; fi
  echo "listing all zones: (if api-key is valid)"
  curl -s https://www.cloudflare.com/api_json.html \
    -d a=zone_load_multi \
    -d tkn=$CFKEY \
    -d email=$CFUSER \
    | grep -Eo '"zone_name":"([^"]+)"' \
    | cut -d':' -f2 \
    | awk '{gsub("\"","");print "* "$1}'
  echo "Please specify the matching zone in ${0} or specify using the -z flag"
  exit 2
fi


# Get current and old WAN ip
WAN_IP=`curl -s ${WANIPSITE}`
if [ -f $HOME/.wan_ip-cf2.txt ]; then
  OLD_WAN_IP=`cat $HOME/.wan_ip-cf2.txt`
else
  echo "No file, need IP"
  OLD_WAN_IP=""
fi


# If WAN IP is unchanged an not -f flag, exit here
if [ "$WAN_IP" = "$OLD_WAN_IP" ] && [ "$FORCE" = false ]; then
  echo "WAN IP Unchanged, to update anyway use flag -f true"
  exit 0
fi


# If CFID is missing retrieve and use it
if [ "$CFID" = "" ]; then
  echo "Missing DNS record ID"
  if ! [ "$GETID" == true ]; then exit 2; fi
  echo "fetching from Cloudflare..."
  if ! CFID=$(
  curl -s https://www.cloudflare.com/api_json.html \
    -d a=rec_load_all \
    -d tkn=$CFKEY \
    -d email=$CFUSER \
    -d z=$CFZONE \
    | grep -Eo '"(rec_id|name|type)":"([^"]+)"' \
    | cut -d':' -f2 \
    | awk 'NR%3{gsub("\"","");printf $0" ";next;}1' \
    | grep -E "${CFHOST//./\\.}" \
    | grep -e '"A"' \
    | grep -Eo "(^|\s)([0-9]+)(\s|$)"
  ); then
    echo " => Incorrect zone, or zone doesn't contain the A-record ${CFHOST}!"
    echo "listing all records for zone ${CFZONE}:"
    (printf "ID RECORD TYPE\n";
    curl -s https://www.cloudflare.com/api_json.html \
      -d a=rec_load_all \
      -d tkn=$CFKEY \
      -d email=$CFUSER \
      -d z=$CFZONE \
      | grep -Eo '"(rec_id|name|type)":"([^"]+)"' \
      | cut -d':' -f2 \
      | awk 'NR%3{gsub("\"","");printf $0" ";next;}1'
    )| column -t
    exit 2
  fi
  echo " => Found CFID=${CFID}, advising to save this to ${0} or set it using the -i flag"
fi


# If WAN is changed, update cloudflare
echo "Updating DNS to $WAN_IP"
RESPONSE=$(
curl -s https://www.cloudflare.com/api_json.html \
  -d a=rec_edit \
  -d tkn=$CFKEY \
  -d email=$CFUSER \
  -d z=$CFZONE \
  -d id=$CFID \
  -d ttl=$CFTTL \
  -d type=A \
  -d name=$CFHOST \
  -d "content=$WAN_IP"
) 
if [ "$RESPONSE" != "${RESPONSE%success*}" ]; then
  echo "Updated succesfuly!"
  echo $WAN_IP > $HOME/.wan_ip-cf.txt
  exit
else
  echo 'Something went wrong :('
  echo "Response: $RESPONSE"
  exit 1
fi
Wobei du erstmal bei CFHOST erstmal einen subdomain die nicht bei cloudflare existiert angibst, Dadurch werden dir die ganzen verfügbaren CFHOST angezeigt mit CFID und Type.

Nicht vergessen das Script ausführbar zu machen
Also:
Code:
chmod +x pfad/zum/script/cf_ddns2.sh

dann führste das Script ermal aus um
Dadurch werden dir erstmal, wie oben erwähnt, alle verfügbaren CFHOST und CFID angezeigt
Du brauchst die CFID von der Domain ohne www also z.B. pcgh.de, müsste als A Type angezeigt werden, die MX einfach ignorieren da die ja nicht geändert werden sollten.

Also CFID von domain.net also ohne www, muss diesmal wirklich im Script eingetragen werden, sonst geht nichts
CFHOST ist deine Domain ohne www

Die alte IP wird ja abgespeichert, weshalb man ja die Datei mit der alten IP im Script anpassen muss, habe ich oben schon getan
 
Das ist passiert:
Code:
root@piserver:~#  /usr/local/bin/cf-ddns-WO_www.sh
 => Hostname is not a FQDN, assuming follow-the-white-rabbiut.net.follow-the-white-rabbit.net
Missing DNS record ID
fetching from Cloudflare...
 => Incorrect zone, or zone doesn't contain the A-record follow-the-white-rabbiut.net.follow-the-white-rabbit.net!
listing all records for zone follow-the-white-rabbit.net:
ID          RECORD                                    TYPE
******42747  follow-the-white-rabbit.net               "A"
******42744  www.follow-the-white-rabbit.net           "A"
******42750  autodiscover.follow-the-white-rabbit.net  "CNAME"
******42756  follow-the-white-rabbit.net               "MX"
******42753  follow-the-white-rabbit.net               "MX"

Hab das Script ausgeführt und es wurde geupdated :3
DANKE!

Den Cronjob bekomm ich selbst eingestellt^^

EDIT: mir ist aufgefallen, dass ich die Seite auch über https:// aufrufen kann, Hat CloudFlare für mich schon eine SSL-Verschlüsselung aktiviert?
 
Du brauchst die obere ID mit den A Type

könnte sein das bei Cloudflare unter Cripto SSL auf flexibel gestellt ist, bei flexibel wird die Verbindung zu den Cloudflare Servern verschlüsselt und von den Cloudflare Servern geht es unverschlüsselt weiter zu deinen Pi

Wenn du ein SSL Certificat hast kannste auf Full oder Full Strikt stellen
Full ist für selbst Signierte Certifikate
Full Strikt für von CA ausgestellte oder das Cloudflare Origin CA
Ich habe z.B. Full Strikt
unter Cripto SSL unter Help kanste nachlesen
 
Zuletzt bearbeitet:
Zurück