CURL

Program cURL je namenjen za UNIX operativni sistem i koristi se za dinamički update IP-adresa. Program se može pokrenuti na sledeći način:
curl -s –user ‘korisničko ime : lozinka’
„http://dyndns.loopia.rs/XDynDNSServer/XDynDNS.php?
hostname=mojdomen.com&
myip=moja_ip_adresa“

Obratite pažnju da gore prikazani URL mora biti u jednoj liniji.

Za utvrđivanje IP adrese koristite sledeći skript:
#!/bin/sh
curl -s –user ‘korisničko ime : lozinka’
„http://dyndns.loopia.rs/XDynDNSServer/XDynDNS.php?
hostname=mojdomen.com&
myip=“`curl -s dyndns.loopia.rs/checkip/checkip.php |
sed ‘s/^.*: \([^<]*\).*$/\1/’` ; echo

Obratite pažnju da gore prikazani URL mora biti u jednom redu. Snimite sadržaj u fajl sa imenom loopiadns.sh i uradite izmenu fajla sa chmod +x loopiadns.sh

Sledi primer loopiadns.sh :
#!/bin/sh

# First the adress we want to update, CHANGE THIS to your address
hostname=example.example.org

# Second the login:pass we’ll use, CHANGE THIS to your login and password
cred=’login:pass’

# Get IP adress from Loopia
myip=`curl -s dyndns.loopia.rs/checkip/checkip.php | sed ‘s/^.*: \([^<]*\).*$/\1/’`

# Check that we actually got anything
if [ x“$myip“ = x ]
then
echo Failed to get IP. Exiting.
exit 255
fi

# Check that we actually got anything more or less sane
# Should really check that it’s actually is an ipadress
# on the format 1.2.3.4 where each number is less than 256.
fmyip=`echo „$myip“ | tr -cd ‘0-9.’`

if [ x“$fmyip“ != x“$myip“ ]
then
echo Failed to understand IP received: „$myip“
echo Exiting
exit 255
fi

# Check if we already set this ip-adress
# We should really check DNS but since there is no good
# general command line that works similar on most UNIX
# we can’t rely on it.
tempdir=“$TMP“
[ x“$tempdir“ = x ] && tempdir=“$TMPDIR“
[ x“$tempdir“ = x ] && tempdir=/tmp

ipfile=“$tempdir“/“$hostname“.ip
if [ -r „$ipfile“ ]
then
fmyip=`grep ‘^'“$myip“‘$’ „$ipfile“`

if [ x“$myip“ = x“$fmyip“ ]
then
#echo No change detected. Wont run update.
exit 0
fi
fi

# Store the IP for future updates
if [ -d „$tempdir“ -a -w „$tempdir“ ]
then
echo „$myip“ > „$ipfile“
else
echo Warning, tempdir do not exist or is not writable: „$tempdir“
fi

# Base URL
burl=https://dyndns.loopia.rs/XDynDNSServer/XDynDNS.php

# Extra options
eops=’wildcard=NOCHG’

# Build URL
url=“$burl“‘?hostname='“$hostname“‘&’myip=“$myip“‘&'“$eops“

curl -s –user „$cred“ „$url“
echo

Was this article helpful?

Related Articles