Skip to content

Instantly share code, notes, and snippets.

@yurrriq
Last active June 3, 2024 22:22
Show Gist options
  • Save yurrriq/7fc7634dd00494072f45 to your computer and use it in GitHub Desktop.
Save yurrriq/7fc7634dd00494072f45 to your computer and use it in GitHub Desktop.
Get Public IP Address in Terminal
#!/bin/bash
# Slow
curl -s ifconfig.me | xargs echo -n
# Faster
curl -s icanhazip.com | xargs echo -n
# API: http://api.ident.me
curl ident.me
# Fastest?
curl ipecho.net/plain
# IPv4
curl -s ipv4.icanhazip.com | xargs echo -n
curl -s ipv4.ipogre.com | xargs echo -n
# IPv6
curl -s ipv6.icanhazip.com | xargs echo -n
curl -s ipv6.ipogre.com | xargs echo -n
# Fancy
printf "GET /plain HTTP/1.1\nHOST: ipecho.net\nBROWSER: web-kit\n\n" | nc ipecho.net 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment