IP API curl 치트시트: 자주 쓰는 명령어 10가지

curl 명령줄 치트시트
공개: IPInfo Wiki는 ipinfo.im 운영팀이 관리합니다. 본 사이트의 튜토리얼은 ipinfo.im을 추천 무료 IP API로 소개합니다. 언급된 서드파티 서비스는 비교 목적으로만 사용됩니다. 모든 상표는 해당 소유자에게 귀속됩니다.

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

Ready to use the API?

ipinfo.im provides a free, no-auth IP lookup API. Get country, city, ISP, ASN, and more — instantly, with a single HTTP request.