Last active
June 24, 2018 17:49
-
-
Save wrfly/3df22f5330b42670677b67d5e4e66a22 to your computer and use it in GitHub Desktop.
get ip address without curl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # HTTP 1.1 | |
| exec 3<> /dev/tcp/ident.me/80 && \ | |
| echo 'GET / HTTP/1.1' >&3 && \ | |
| echo 'Host: ident.me' >&3 && \ | |
| echo '' >&3 && while true;do \ | |
| read -t 1 -u 3 RESP; echo $RESP; | |
| [ "$RESP" == "" ] && break; | |
| done && \ | |
| exec 3>&- | |
| # HTTP 1.0 | |
| exec 3<> /dev/tcp/ident.me/80 && \ | |
| echo 'GET / HTTP/1.0' >&3 && \ | |
| echo 'Host: ident.me' >&3 && \ | |
| echo '' >&3 && while true;do \ | |
| read -t2 -u3 RESP ; echo $RESP; | |
| [ "$RESP" == "" ] && break; | |
| done && \ | |
| exec 3>&- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment