traller
Goto Top

IPv6 Aktualisierung

Hallo,
ich versuche gerade ein Script zu schreiben, um die IPv6 bei einem DynDNS Anbieter zu aktualisieren. Ich muss dafür die IPv6 in einer Zeile auslesen können. Momentan sieht es so aus:
#!/bin/bash
ip -6 addr show dev eth0 | grep inet6 | sed -e 's/inet6//;s/\/.*$//;s/ //g' >> ipv6.txt  
adresse=$(echo ipv6.txt)
rm ipv6.txt
https://dyndns/dynamic/update.php?IDENTIFIKATION&address=$adresse

wie bekomme ich bei dem Befehl zum Auslesen der IPv6 die Ausgabe in einer Zeile richtig hin? Wenn dieses in einer Zeile in die ipv6.txt geschrieben wird, kann man sich das ja mit einer Variable wieder richtig auslesen ...


Könnt ihr mir helfen?

Content-Key: 286558

Url: https://administrator.de/contentid/286558

Printed on: April 24, 2024 at 12:04 o'clock

Member: Dani
Solution Dani Oct 24, 2015 updated at 10:04:52 (UTC)
Goto Top
Moin,
probier es mal so:
https://dyndns/dynamic/update.php?IDENTIFIKATION&address=$(ip -6 addr show dev eth0 | grep inet6 | sed -e 's/inet6//;s/\/.*$//;s/ //g')  
Wie immer ungetestet.


Gruß,
Dani
Member: traller
traller Oct 24, 2015 at 10:05:50 (UTC)
Goto Top
Zitat von @Dani:

Moin,
probier es mal so:
> https://dyndns/dynamic/update.php?IDENTIFIKATION&address=$(ip -6 addr show dev eth0 | grep inet6 | sed -e 's/inet6//;s/\/.*$//;s/ //g')  
> 
Wie immer ungetestet.


Gruß,
Dani
Danke,
ich hab es nun so gemacht:
#!/bin/bash
UpdateURL=https://freedns.afraid.org/dynamic/update.php?XXXXXXXXX
ip -6 addr show dev p2p1 | grep inet6 | sed -e 's/inet6//;s/\/.*$//;s/ //g' >> ipv6.txt  
ipv6adresse=$(head -n1 ipv6.txt)
rm ipv6.txt
curl $UpdateURL'&address='$ipv6adresse  
Mitglied: 114757
114757 Oct 24, 2015 updated at 12:53:56 (UTC)
Goto Top
Moin,
wieso der umständliche Umweg über eine Textdatei ??
Würde doch eigentlich
#!/bin/bash
UpdateURL='https://freedns.afraid.org/dynamic/update.php?XXXXXXXXX'  
address=$(ip -6 addr show eth0 | grep -Po 'inet6 [\da-f:]+' | cut -d' ' -f2)  
curl "${UpdateURL}&address=$address"  
reichen.

Gruß jodel32