1
0
src/niceties/ifpublic

21 lines
500 B
Plaintext
Raw Normal View History

2022-10-21 11:35:40 -06:00
#!/bin/sh
2022-10-21 23:24:18 -06:00
: HTTP APIs that return your public IP address [both v4 and v6] "\
https://icanhazip.com
https://ifconfig.io
http://icanhazip.com
http://ifconfig.io/
"
PUBLIC_IP_FETCH_URL="https://icanhazip.com"
PUBLIC_IP6_FETCH_URL="$PUBLIC_IP_FETCH_URL"
2022-10-21 23:42:01 -06:00
printf "%s / %s\n" \
"$(curl -4 --connect-timeout 5 --silent "$PUBLIC_IP_FETCH_URL")" \
"$(curl -6 --connect-timeout 5 --silent "$PUBLIC_IP6_FETCH_URL")" \
2022-10-22 07:45:24 -06:00
| sed -e 's/ \/ $//' \
-e 's/^ \/ //' \
-e 's/^$/[error fetching address]/'
2022-10-21 23:24:18 -06:00
2022-10-21 11:35:40 -06:00
exit 0