Page 1 of 1

ip address / conky

Posted: 27 May 2016 10:17
by amnesix
First, I apologize if I post this in the wrong category.

My problem : I use Conky to follow the eventual difference between :
  • my public IP address (from my provider)
    my VPN-generated IP address
I use(d) for this purpose in conky the following lines (in .conkyrc) :

Code: Select all

${color orange}${alignr}${texeci 68400 wget -O - http://ip.tupeux.com | tail}
${color grey}external IP VPN:  ${color red}${alignr}${texeci 60 wget -O - http://ip.tupeux.com | tail}
and, of course, now, it just doesn't work anymore.

It seems to me that the problem lies by the server (ip.tupeux.com), which just doesn't answer (I can't ping it...), and of course it could be temporary.

But just in case, I'd like to have an other way to display my IP addresses through conky. So maybe there are other servers which serve the problem, which I could use the way I use ip.tupeux.com, or maybe there is another way.

If anyone has an idea, i'd love to hear it !

Thank you !

Re: ip address / conky

Posted: 27 May 2016 14:24
by ilu
No idea about conky or your problem, sorry, but https://isitup.org/check.php?domain=tupeux.com shows that that domain is down.
For inquiries like that I usually use http://whatismyip.org. Don't know whether that works with conky though.

Re: ip address / conky

Posted: 13 Oct 2016 07:22
by Cehio
Got myself something similar, it too stopped working correctly. Could this be due to the fact that I use proxy server? Here is the address of my ISP, if that matters.

Re: ip address / conky

Posted: 13 Oct 2016 09:37
by Zill
The following command returns the current IP address:

Code: Select all

dig +short myip.opendns.com @resolver1.opendns.com
As this command simply produces an output to stdout, hopefully you will be able to use it with conky.

p.s. My thanks go to "Krinkle" for publishing this command.

Re: ip address / conky

Posted: 13 Oct 2016 09:52
by Arjen Balfoort
solydxk-conky uses this bash:

Code: Select all

#!/bin/bash

# Reference: http://www.linuxjournal.com/content/validating-ip-address-bash-script
#
# Test an IP address for validity:
# Usage:
#      valid_ip IP_ADDRESS
#      if [[ $? -eq 0 ]]; then echo good; else echo bad; fi
#   OR
#      if valid_ip IP_ADDRESS; then echo good; else echo bad; fi
#
function valid_ip()
{
    local  ip=$1
    local  stat=1

    if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
        OIFS=$IFS
        IFS='.'
        ip=($ip)
        IFS=$OIFS
        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
            && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
        stat=$?
    fi
    return $stat
}

# Try three different sources
IP=$(curl -f solydxk.com/ip.php)
if valid_ip "$IP"; then
  echo "$IP"
  exit
fi

sleep 10
IP=$(curl -f ident.me)
if valid_ip "$IP"; then
  echo "$IP"
  exit
fi

sleep 10
IP=$(curl -f checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
if valid_ip "$IP"; then
  echo "$IP"
fi

Re: ip address / conky

Posted: 13 Oct 2016 13:15
by mhwelsh

Code: Select all

dig +short myip.opendns.com @resolver1.opendns.com
This requires dnsutils to be installed it was not present in my installation.
It is now and it works a treat.

martin welsh