dotfiles/bin/myip

26 lines
540 B
Plaintext
Raw Normal View History

2023-12-23 20:13:47 -07:00
#!/bin/bash
# List system's WAN and LAN ip addresses
# Depends on ifconfig and awk
2024-05-08 19:54:51 -06:00
declare -r ipv4="$(curl --max-time 1 -s https://api4.ipify.org)"
2023-12-23 20:13:47 -07:00
2024-05-08 19:54:51 -06:00
if [[ -n "$ipv4" ]]; then
echo "IPv4 (WAN): $ipv4"
2023-12-23 20:13:47 -07:00
else
2024-05-08 19:54:51 -06:00
echo "IPv4 (WAN): Not available"
2023-12-23 20:13:47 -07:00
fi
2024-05-08 19:54:51 -06:00
declare -r ipv6="$(curl --max-time 1 -s https://api6.ipify.org)"
2023-12-23 20:13:47 -07:00
2024-05-08 19:54:51 -06:00
if [[ -n "$ipv6" ]]; then
echo "IPv6 (WAN): $ipv6"
else
echo "IPv6 (WAN): Not available"
2023-12-23 20:13:47 -07:00
fi
2024-05-08 19:54:51 -06:00
declare -r ipv64="$(curl --max-time 1 -s https://api64.ipify.org)"
2023-12-23 20:13:47 -07:00
2024-05-08 19:54:51 -06:00
if [[ -n "$ipv64" ]]; then
echo "First Resolved: $ipv64"
2023-12-23 20:13:47 -07:00
fi