메모
버전 2.3.0부터 애플리케이션에는 선택적 클라이언트 DNS 검색이 포함됩니다.
지리적 위치, TCP 개방형 포트 확인 및 헤더 정보를 포함한 또 다른 "내 IP 주소는 무엇입니까?" 서비스입니다. 고성능을 염두에 두고 작성되었으며 경량 고성능 HTTP 멀티플렉서인 httprouter를 사용하는 gin을 사용합니다.
whatismyip
과 활성화된 DNS discovery
사용하여 ifconfig.es 라이브 사이트를 살펴보세요.
명령줄에서 쉽게 공용 IP를 얻으세요.
curl ifconfig.es
127.0.0.1
curl -6 ifconfig.es
::1
DNS 공급자의 IP를 가져옵니다.
curl -L dns.ifconfig.es
2a04:e4c0:47::67 (Spain / OPENDNS)
-tls-bind
)가 필요합니다. UDP 포트는 TLS 서버에 사용되는 포트와 동일합니다.X-Real-IP
)를 신뢰하여 프록시 뒤에서 실행할 수 있습니다. 또한 클라이언트 포트를 확인하기 위한 사용자 지정 헤더도 지원합니다. 프록시가 IP에 대한 헤더(예: CDN의 고정 헤더)만 추가할 수 있는 경우 클라이언트 포트는 알 수 없음으로 표시됩니다.hup
신호가 존중됩니다.curl -H "Accept: application/json" https://ifconfig.es/
와 동일) DNS 검색은 클라이언트가 <uuid>.dns.ifconfig.es
에 요청하도록 강제하여 작동합니다. 이 DNS 요청은 whatismyip
바이너리에 포함된 microdns 서버에 의해 처리됩니다. 검색 서버를 실행하려면 다음 형식의 구성 파일을 생성해야 합니다.
---
domain : dns.example.com
redirect_port : " :8000 "
resource_records :
- " 1800 IN SOA xns.example.com. hostmaster.example.com. 1 10000 2400 604800 1800 "
- " 3600 IN NS xns.example.com. "
ipv4 :
- " 127.0.0.2 "
ipv6 :
- " aaa:aaa:aaa:aaaa::1 "
example.com의 DNS 기관은 하위 도메인 영역 dns.example.com
whatismyip
서비스를 실행하는 서버에 위임했습니다.
클라이언트는 curl -L dns.example.com
리디렉션을 따라 dns.example.com
URL을 요청할 수 있습니다.
리디렉션을 방지하려면 실제 ifconfig.es와 같은 유효한 URL을 제공할 수 있습니다.
curl $( uuidgen ) .dns.ifconfig.es
curl $( cat /proc/sys/kernel/random/uuid ) .dns.ifconfig.es
Golang >= 1.22가 필요합니다.
make build
Usage of whatismyip:
-bind string
Listening address (see https://pkg.go.dev/net?#Listen) (default ":8080")
-enable-http3
Enable HTTP/3 protocol. HTTP/3 requires --tls-bind set, as HTTP/3 starts as a TLS connection that then gets upgraded to UDP. The UDP port is the same as the one used for the TLS server.
-enable-secure-headers
Add sane security-related headers to every response
-geoip2-asn string
Path to GeoIP2 ASN database
-geoip2-city string
Path to GeoIP2 city database
-resolver string
Path to the resolver configuration. It actually enables the resolver for DNS client discovery.
-template string
Path to template file
-tls-bind string
Listening address for TLS (see https://pkg.go.dev/net?#Listen)
-tls-crt string
When using TLS, path to certificate file
-tls-key string
When using TLS, path to private key file
-trusted-header string
Trusted request header for remote IP (e.g. X-Real-IP). When using this feature if -trusted-port-header is not set the client port is shown as 'unknown'
-trusted-port-header string
Trusted request header for remote client port (e.g. X-Real-Port). When this parameter is set -trusted-header becomes mandatory
-version
Output version information and exit
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb
-bind " " -tls-bind :8081 -tls-crt ./test/server.pem -tls-key ./test/server.key
-resolver ./test/resolver.yml
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb
-bind " " -tls-bind :8081 -tls-crt ./test/server.pem -tls-key ./test/server.key -enable-http3
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb
-trusted-header X-Real-IP -trusted-port-header X-Real-Port -template mytemplate.tmpl
github에서 최신 버전을 다운로드하세요.
도커 허브에서는 초경량(~4MB) 이미지를 사용할 수 있습니다. 버전 2.1.2
부터 바이너리는 upx를 사용하여 압축됩니다.
make docker-run
docker run --tty --interactive --rm
-v $PWD / < path to city database > :/tmp/GeoIP2-City-Test.mmdb:ro
-v $PWD / < path to ASN database > :/tmp/GeoLite2-ASN-Test.mmdb:ro -p 8080:8080
dcarrillo/whatismyip:latest
-geoip2-city /tmp/GeoIP2-City-Test.mmdb
-geoip2-asn /tmp/GeoLite2-ASN-Test.mmdb