There are several pretty good websites that can tell you your IP address.

You can open them in a browser or use the terminal to get your IP address.

curl ident.me
curl ip.zxc.sx
curl ifconfig.me
curl icanhazip.com
curl ipinfo.io
curl 2ip.ru

If you don’t have a curl installed, you can use wget.

wget -qO- ident.me
wget -qO- ip.zxc.sx
wget -qO- ifconfig.me
wget -qO- icanhazip.com
wget -qO- ipinfo.io

Note that 2ip.ru doesn’t support wget.

If you don’t have anything rather than shell (sh, bash) and awk, you can use the following command.

(exec 3<>/dev/tcp/ident.me/80; echo -e "GET / HTTP/1.0\nHost: ident.me\n" >&3; awk 'NR>1 { print }' RS='\r\n\r\n' <&3)
(exec 3<>/dev/tcp/ip.zxc.sx/80; echo -e "GET / HTTP/1.0\nHost: ip.zxc.sx\n" >&3; awk 'NR>1 { print }' RS='\r\n\r\n' <&3)
(exec 3<>/dev/tcp/ifconfig.me/80; echo -e "GET / HTTP/1.0\nHost: ifconfig.me\n" >&3; awk 'NR>1 { print }' RS='\r\n\r\n' <&3)
(exec 3<>/dev/tcp/icanhazip.com/80; echo -e "GET / HTTP/1.0\nHost: icanhazip.com\n" >&3; awk 'NR>1 { print }' RS='\r\n\r\n' <&3)
(exec 3<>/dev/tcp/ipinfo.io/80; echo -e "GET / HTTP/1.0\nHost: ipinfo.io\n" >&3; awk 'NR>1 { print }' RS='\r\n\r\n' <&3)

Note that 2ip.ru doesn’t support this method.

If you have ONLY shell, you can use the following command.

(exec 3<>/dev/tcp/ident.me/80; echo -e "GET / HTTP/1.0\nHost: ident.me\n" >&3; cat <&3)
(exec 3<>/dev/tcp/ip.zxc.sx/80; echo -e "GET / HTTP/1.0\nHost: ip.zxc.sx\n" >&3; cat <&3)
(exec 3<>/dev/tcp/ifconfig.me/80; echo -e "GET / HTTP/1.0\nHost: ifconfig.me\n" >&3; cat <&3)
(exec 3<>/dev/tcp/icanhazip.com/80; echo -e "GET / HTTP/1.0\nHost: icanhazip.com\n" >&3; cat <&3)
(exec 3<>/dev/tcp/ipinfo.io/80; echo -e "GET / HTTP/1.0\nHost: ipinfo.io\n" >&3; cat <&3)

Note that 2ip.ru doesn’t support this method.

Just by the way, here is the source code of the ip.zxc.sx.

<?php
header("Content-Type: text/plain");
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
    $client_ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
} else {
    $client_ip = $_SERVER['REMOTE_ADDR'];
}
echo $client_ip . "\n";
?>