Skip to content

Instantly share code, notes, and snippets.

@gaukas
Forked from yurrriq/ipconfig.sh
Created May 8, 2021 01:35
Show Gist options
  • Save gaukas/629f0789c230af489511f62738e0886e to your computer and use it in GitHub Desktop.
Save gaukas/629f0789c230af489511f62738e0886e 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