IP & Network Tools

NETOPSIYON IP

Checking Your Public IP with curl and Scripts

Use plain text and JSON output with timeouts, HTTP error handling and IPv4/IPv6 options.

Netopsiyon · Updated: November 24, 2026

The shortest lookup

curl -s https://ip.netopsiyon.com/ip

The /ip endpoint returns the connection address observed by the server as plain text. It is not necessarily your device's local address. With a VPN, proxy or NAT, the visible exit address is shown. A command run on a server reports that server's exit address, rather than your home computer's.

Add error handling to scripts

curl --fail --silent --show-error \
  --connect-timeout 3 --max-time 8 \
  https://ip.netopsiyon.com/ip

--silent hides progress output; --show-error retains error messages. --fail produces a failure exit status for HTTP errors. --connect-timeout limits connection setup, while --max-time limits the entire request. These options prevent an unresponsive external service from making automation wait indefinitely.

Check the command's exit status and validate the returned value as an IP address. Do not write error text or empty output into a configuration file as an address. Add delays to retries instead of repeatedly sending requests in a tight loop. A short-lived local cache can also avoid unnecessary lookups.

IPv4, IPv6 and JSON

IPv6 is not enabled on this service yet. In the -6 command below, replace the example hostname with a real IPv6-enabled endpoint.

curl -4 --fail --max-time 8 https://ip.netopsiyon.com/ip
curl -6 --fail --max-time 8 https://ipv6.example/ip
curl --fail --max-time 8 https://ip.netopsiyon.com/json

-4 and -6 choose the address family. IPv6 requires working support on the client, DNS and destination server. The /json response includes ip, version, user_agent, timestamp and service. Use a JSON parser instead of text matching, and do not depend on field ordering.

Other endpoints

/asn returns the AS number, /country the ISO country code, /city the city and /ua the request's User-Agent. Location fields depend on an external source and do not give an exact physical location. Unavailable data can return HTTP 503; a missing field can return 404. An IP lookup can therefore succeed while a city lookup fails.

Open a JSON response · Technical reference: curl command options

← All guides