navilg / godaddy-ddns

Dynamic DNS with GoDaddy
https://medium.com/linux-shots
MIT License
53 stars 14 forks source link

Status: NOT OK - Request #6

Closed haditannous closed 3 years ago

haditannous commented 3 years ago

Hi,

When i am checking the log i am getting: "Status: NOT OK - Request"

How can i troubleshoot that ?

Thank you

navilg commented 3 years ago

@haditannous can you confirm if you are using latest script ? if not please clone the latest (master) script and try Please make sure your key and secret are correct.

If issue persists, run the script using below command and copy paste the command outputs from terminal. NOTE: Make sure to mask or remove the key and secret before posting here.

 bash -x godaddy-ddns.sh
navilg commented 3 years ago

Latest release https://github.com/navilg/godaddy-ddns/releases/tag/vZ.2 repo: https://github.com/navilg/godaddy-ddns/tree/master

navilg commented 3 years ago

REPOSTING AFTER REMOVING PUBLIC IP. DELETED ORIGINAL POST AS IT CONTAINED PUBLIC IP

Hi,

Thank you for your response. i've just cloned the repository again using git clone https://github.com/navilg/godaddy-ddns.git

and configured the properties file and still not working.

Below is the output of the command

root@Apache:/home/hadi/godaddy-ddns# bash -x godaddy-ddns.sh

getDNSRecordStatus=1000
getPubIPStatus=1000
setDNSRecordStatus=1000
addCronJobsStatus=1000
initialize
+++ dirname godaddy-ddns.sh
++ cd .
++ pwd
DIR=/home/hadi/godaddy-ddns
properties_file=/home/hadi/godaddy-ddns/godaddy-ddns.properties
logfile=/home/hadi/godaddy-ddns/godaddy-ddns.log
source /home/hadi/godaddy-ddns/godaddy-ddns.properties
++ domain=youknewthatalready.com
++ name=www
++ ttl=600
++ key=imsureitscorrect
++ secret=imsureitscorrect
headers='Authorization: sso-key imsureitscorrect:imsureitscorrect'
return 0
getDNSRecord
++ curl -s -X GET -H 'Authorization: sso-key imsureitscorrect:imsureitscorrect' https://api.godaddy.com/v1/domains/youknewthatalready.com/records/A/www
result='[]'
checkconnection=0
grep -w code
echo '[]'
grep -w message
checkerror=1
'[' 1 -ne 0 -a 0 -eq 0 ']'
++ grep -oE '\b([0-9]{1,3}.){3}[0-9]{1,3}\b'
++ echo '[]'
dnsIp=
++ echo '[]'
++ cut -d , -f 3
++ cut -d : -f 2
existingTtl='[]'
[[ [] == [] ]]
existingTtl=0
return 0
getDNSRecordStatus=0
[[ 0 -eq 0 ]]
getPubIP
++ curl -s GET http://ipinfo.io/json
ret='{
"ip": "X.XX.XXX.XX",
"hostname": "X.XX.XXX.XX.dynamic-dsl-ip.omantel.net.om",
"city": "London",
"region": "England",
"country": "GB",
"loc": "51.5085,-0.1257",
"org": "AS28885 Oman Telecommunications Company (S.A.O.G)",
"postal": "EC1A",
"timezone": "Europe/London",
"readme": "https://ipinfo.io/missingauth"
}'
checkret=0
[[ 0 -eq 0 ]]
++ echo '{' '"ip":' '"X.XX.XXX.XX",' '"hostname":' '"X.XX.XXX.XX.dynamic-dsl-ip.omantel.net.om",' '"city":' '"London",' '"region":' '"England",' '"country":' '"GB",' '"loc":' '"51.5085,-0.1257",' '"org":' '"AS28885' Oman Telecommunications Company '(S.A.O.G)",' '"postal":' '"EC1A",' '"timezone":' '"Europe/London",' '"readme":' '"https://ipinfo.io/missingauth"' '}'
++ grep -oE '\b([0-9]{1,3}.){3}[0-9]{1,3}\b'
currentIp='X.XX.XXX.XX
X.XX.XXX.XX'
return 0
getPubIPStatus=0
'[' 0 -eq 0 -a 0 -eq 0 ']'
setDNSRecord
'[' '' '!=' 'X.XX.XXX.XX
X.XX.XXX.XX' -o 0 -ne 600 ']'
request='{"data":"X.XX.XXX.XX
X.XX.XXX.XX","ttl":600}'
++ curl -i -s -X PUT -H 'Authorization: sso-key imsureitscorrect:imsureitscorrect' -H 'Content-Type: application/json' -d '[{"data":"X.XX.XXX.XX' 'X.XX.XXX.XX","ttl":600}]' https://api.godaddy.com/v1/domains/youknewthatalready.com/records/A/www
nresult='HTTP/1.1 400 Bad Request
Content-Type: application/json
Content-Length: 176
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Request-Id: 98262440e59c1db84d342032801a981a
X-DataCenter: PHX3
Expires: Fri, 16 Oct 2020 09:45:43 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Fri, 16 Oct 2020 09:45:43 GMT
Connection: close

{"code":"INVALID_BODY","fields":[{"code":"INVALID_BODY","message":"unexpected EOF","path":"records"}],"message":"Request body doesn'''t fulfill schema, see details in fields"}' ++ echo 'HTTP/1.1 400 Bad Request Content-Type: application/json Content-Length: 176 Strict-Transport-Security: max-age=15724800; includeSubDomains X-Request-Id: 98262440e59c1db84d342032801a981a X-DataCenter: PHX3 Expires: Fri, 16 Oct 2020 09:45:43 GMT Cache-Control: max-age=0, no-cache, no-store Pragma: no-cache Date: Fri, 16 Oct 2020 09:45:43 GMT Connection: close

++ grep -i http ++ awk '{first=$1;$1="";print $0;first;}' {"code":"INVALID_BODY","fields":[{"code":"INVALID_BODY","message":"unexpected EOF","path":"records"}],"message":"Request body doesn'''t fulfill schema, see details in fields"}' ' stat=' 400 Bad Request ++ echo 400 Bad $'Request\r' ++ awk '{print $NF}' ++ sed 's/\r$//'

st=Request
[[ Request == \O\K ]]
return 1
setDNSRecordStatus=1
[[ 0 -ne 0 ]]
[[ 1 -eq 0 ]]
[[ 0 -ne 0 ]]
[[ 1 -eq 1 ]]
writeLog 1 Request
[[ 1 -eq 0 ]]
[[ 1 -eq 100 ]]
echo 'DNS Name: www.youknewthatalready.com'
echo 'DNS IP: '
echo 'TTL: '
echo 'Status: NOT OK - Request'
return 1
[[ 1 -eq 0 ]]
root@Apache:/home/hadi/godaddy-ddns#
navilg commented 3 years ago

@haditannous Can u plz check if record type created is of 'A' type in godaddy. It seems like www record is not of type as 'A'.

If 'www' record is not of 'A' type. You can delete this record from godaddy manage dns page, if feasible and then run the script. It will automatically create an 'A' type record with name mentioned in properties file.

haditannous commented 3 years ago

@navilg when it initially did the test www was cname record, but then i've changed it to A type and did the test again and still the same result.

Below are the outputs for the bash command without www as a record (neither cname nor A) and with www as an A record:

Without an A record for WWW

root@Apache:/home/hadi/godaddy-ddns# bash -x godaddy-ddns.sh

{"code":"INVALID_BODY","fields":[{"code":"INVALID_BODY","message":"unexpected EOF","path":"records"}],"message":"Request body doesn'\''t fulfill schema, see details in fields"}' ++ echo 'HTTP/1.1 400 Bad Request Content-Type: application/json Content-Length: 176 Strict-Transport-Security: max-age=15724800; includeSubDomains X-Request-Id: cf40fc6347594185a57a953315fcc3ed X-DataCenter: PHX3 Expires: Fri, 16 Oct 2020 16:27:39 GMT Cache-Control: max-age=0, no-cache, no-store Pragma: no-cache Date: Fri, 16 Oct 2020 16:27:39 GMT Connection: close

{"code":"INVALID_BODY","fields":[{"code":"INVALID_BODY","message":"unexpected EOF","path":"records"}],"message":"Request body doesn'\''t fulfill schema, see details in fields"}' ++ grep -i http ++ awk '{first=$1;$1="";print $0;first;}' ' stat=' 400 Bad Request ++ echo 400 Bad $'Request\r' ++ sed 's/\r$//' ++ awk '{print $NF}'

With an A record for WWW

root@Apache:/home/hadi/godaddy-ddns# bash -x godaddy-ddns.sh

{"code":"INVALID_BODY","fields":[{"code":"INVALID_BODY","message":"unexpected EOF","path":"records"}],"message":"Request body doesn'\''t fulfill schema, see details in fields"}' ++ echo 'HTTP/1.1 400 Bad Request Content-Type: application/json Content-Length: 176 Strict-Transport-Security: max-age=15724800; includeSubDomains X-Request-Id: e1c419fb1373e08b4f41f5a1328780ed X-DataCenter: PHX3 Expires: Fri, 16 Oct 2020 16:29:39 GMT Cache-Control: max-age=0, no-cache, no-store Pragma: no-cache Date: Fri, 16 Oct 2020 16:29:39 GMT Connection: close

{"code":"INVALID_BODY","fields":[{"code":"INVALID_BODY","message":"unexpected EOF","path":"records"}],"message":"Request body doesn'\''t fulfill schema, see details in fields"}' ++ grep -i http ++ awk '{first=$1;$1="";print $0;first;}' ' stat=' 400 Bad Request ++ echo 400 Bad $'Request\r' ++ sed 's/\r$//' ++ awk '{print $NF}'

Thank you

navilg commented 3 years ago

Hi,

Your hostname includes ip address, due to that the data created in payload is getting created with two same ip addresses as scripts detects two ips.

ret='{ "ip": "X.XX.XXX.XX", "hostname": "X.XX.XXX.XX.dynamic-dsl-ip.omantel.net.om", "city": "London", "region": "England",

Due to this, IP address is not getting formatted.

currentIp='X.XX.XXX.XX X.XX.XXX.XX'

I will be checking and fixing this.

Thanks for reporting this

navilg commented 3 years ago

Reopening for test.

@haditannous Could you please clone fresh copy from master and check if it works. Make sure 'www' record is created as 'A' type.

Thanks

haditannous commented 3 years ago

@navilg thx a lot. it's working now