1. 내 공인 IP 확인
curl https://ipinfo.im/api/ip
2. 전체 IP 정보 (JSON)
curl https://ipinfo.im/api/
3. 특정 IP 조회
curl "https://ipinfo.im/api/?ip=8.8.8.8"
4. jq로 JSON 정렬 출력
curl -s https://ipinfo.im/api/ | jq .
5. 특정 필드만 추출
# 국가 코드만
curl -s "https://ipinfo.im/api/?ip=1.1.1.1" | jq -r '.country'
# ISP만
curl -s "https://ipinfo.im/api/?ip=1.1.1.1" | jq -r '.org'
6. 변수에 저장
MY_IP=$(curl -s https://ipinfo.im/api/ip)
echo "공인 IP: $MY_IP"
7. 국가 코드로 조건 분기
COUNTRY=$(curl -s "https://ipinfo.im/api/?ip=$IP" | jq -r '.country')
if [ "$COUNTRY" = "KR" ]; then
echo "한국 IP입니다"
fi
8. 여러 IP 일괄 조회
for IP in 8.8.8.8 1.1.1.1 168.126.63.1; do
INFO=$(curl -s "https://ipinfo.im/api/?ip=$IP")
echo "$IP → $(echo $INFO | jq -r '.country') | $(echo $INFO | jq -r '.org')"
sleep 0.1
done
9. 파일에서 일괄 조회
while IFS= read -r IP; do
curl -s "https://ipinfo.im/api/?ip=$IP" | jq -r '[.ip, .country, .city, .org] | @tsv'
done < ip_list.txt
10. CSV로 출력
echo "ip,country,city,org" > result.csv
for IP in 8.8.8.8 1.1.1.1; do
curl -s "https://ipinfo.im/api/?ip=$IP" | jq -r '[.ip,.country,.city,.org] | @csv' >> result.csv
done
지금 바로 → ipinfo.im