1
0
Files
src/ifpublic/ifpublic

20 lines
462 B
Plaintext
Raw Normal View History

2022-10-21 13:35:40 -04:00
#!/bin/sh
2022-10-22 01:24:18 -04: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-22 01:42:01 -04: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 09:41:39 -04:00
| sed -e 's/ \/ $//g' \
-e 's/^ \/ //g'
2022-10-22 01:24:18 -04:00
2022-10-21 13:35:40 -04:00
exit 0