What is my IP address?

{{ .IP }}

Multiple command line HTTP clients are supported, including curl, httpie, GNU Wget and fetch.

CLI examples:

$ curl ifconfig.co
{{ .IP }}

$ http -b ifconfig.co
{{ .IP }}

$ wget -qO- ifconfig.co
{{ .IP }}

$ fetch -qo- https://ifconfig.co
{{ .IP }}
{{ if .IsLookupCountryEnabled }}

Country lookup:

$ http ifconfig.co/country
{{ .Country }}
{{ end }} {{ if .IsLookupCityEnabled }}

City lookup:

$ http ifconfig.co/city
{{ .City }}
{{ end }}

JSON output:

$ http ifconfig.co/json
{ {{ if .IsLookupCityEnabled }}
    "city": "{{ .City }}",{{ end }}{{ if .IsLookupCountryEnabled }}
    "country": "{{ .Country }}",{{ end }}{{ if .IsLookupAddrEnabled }}
    "hostname": "{{ .Hostname }}",{{ end }}
    "ip": "{{ .IP }}",
    "ip_decimal": {{ .IPDecimal }}
}

Setting the Accept header to application/json also works.

Plain output:

Always returns the IP address including a trailing newline, regardless of user agent.

$ http ifconfig.co/ip
{{ .IP }}
{{ if .IsLookupPortEnabled }}

Testing port connectivity:

$ http ifconfig.co/port/8080
{
    "ip": "{{ .IP }}",
    "port": 8080,
    "reachable": false
}
{{ end }}