Create a gist now

Instantly share code, notes, and snippets.

@yurrriq /ipconfig.sh
Last active Aug 29, 2015

What would you like to do?
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