Skip to content

Instantly share code, notes, and snippets.

@wrfly
Last active June 24, 2018 17:49
Show Gist options
  • Select an option

  • Save wrfly/3df22f5330b42670677b67d5e4e66a22 to your computer and use it in GitHub Desktop.

Select an option

Save wrfly/3df22f5330b42670677b67d5e4e66a22 to your computer and use it in GitHub Desktop.
get ip address without curl
#!/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