Get the list of IPs known to your node and save them to the file peers_ips.txt
. Then count how many IPs are in the file.
$ src/bitcoin-cli getnodeaddresses 0 | jq -r '.[] | .address' > peer_ips.txt
$ wc -l peer_ips.txt
Get the list of nodes known to Bitnodes and save their IPs to the file ip_list.txt
:
$ curl https://bitnodes.io/api/v1/snapshots/latest/ | jq -r '.nodes | keys[]' > ip_list.txt
Optionally filter onion addresses:
$ grep -v "onion" ip_list.txt > filtered.txt
Since the peers clearnet IPs are formatted like [_IP_]:_PORT_
, to get only the IPs we need to filter the Port and brackets as well:
$ sed 's/\(.*\):.*/\1/;s/[][]//g' filtered.txt > filtered_clean.txt