I want to fetch my public IP and display it in CLI using ipify API.
Therefore I created file /root/.profile with this code:
root@clancy:~# cat /root/.profile #!/bin/sh currentWANIP="$(curl http://api.ipify.org/ 2> /dev/null)" echo echo "My current WAN IP is: $currentWANIP" && echo
Unfortunately this is not working.
Verifying this using
curl in CLI fails with error:
root@clancy:~# curl http://api.ipify.org/ curl: (6) Could not resolve host: api.ipify.org
However, there's no general DNS failure, means I can resolve any other domain, e.g.
root@clancy:~# nslookup openwrt.org Server: 172.16.1.1 Address: 172.16.1.1#53 Name: openwrt.org Address 1: 18.104.22.168 Address 2: 2a03:b0c0:3:d0::1af1:1 root@clancy:~# nslookup cloudflare.com Server: 172.16.1.1 Address: 172.16.1.1#53 Name: cloudflare.com Address 1: 22.214.171.124 Address 2: 126.96.36.199 Address 3: 2606:4700::6810:85e5 Address 4: 2606:4700::6810:84e5
Can you please advise how to fix this issue?