modified: nfig1.py
[GalaxyCodeBases.git] / etc / Server / getip.sh
blob88441db12d0b0495338a9838ecdff70005422a66
1 #!/bin/bash
3 # http://www.linuxquestions.org/questions/linux-networking-3/how-can-i-get-my-external-ip-address-from-behind-a-nat-333878/
5 get-current-ip() {
7 xc=1
8 until (( xc == 0 )) ; do
10 case $(( RANDOM % 5 )) in
12 0) ip=$(wget -t 2 -T 5 -q -O- http://showip.codebrainz.ca/) ;;
13 # 1) ip=$(wget -t 2 -T 5 -q -O- http://www.whatismyip.com/automation/n09230945.asp) ;;
14 2) ip=$(wget -t 2 -T 5 -q -O- http://www.showmyip.com/simple/) ;;
15 3) ip=$(wget -t 2 -T 5 -q -O- http://cfaj.freeshell.org/ipaddr.cgi) ;;
16 4) ip=$(wget -t 2 -T 5 -q -O- https://secure.informaction.com/ipecho/) ;;
17 1) ip=$(wget -t 2 -T 5 -q -O- http://icanhazip.com/) ;;
19 esac
21 xc=$?
23 done
25 #echo -n "${ip//[^0-9.]}" #if you don't want a trailing newline
26 echo "$ip" #if you want or don't mind newlines
29 get-current-ip