Skip to content

Instantly share code, notes, and snippets.

@lessavin
Last active November 18, 2025 21:35
Show Gist options
  • Select an option

  • Save lessavin/1dc21cc75474bdcc4213bdbd546e52f0 to your computer and use it in GitHub Desktop.

Select an option

Save lessavin/1dc21cc75474bdcc4213bdbd546e52f0 to your computer and use it in GitHub Desktop.
Returns 1 if ISP put you under NAT.
#!/usr/bin/sh
# natcheck.sh
# Returns 1 if ISP put you under NAT.
# Source: https://superuser.com/questions/1630106/how-do-i-find-out-if-my-isp-has-put-me-behind-a-nat-will-dynamic-dns-work-with
NATCHECK_HOPS=2 # Change this value to <rounter_number>+1.
if [ $NATCHECK_HOPS -lt $(traceroute $(curl -s ifconfig.me) | grep ms | wc -l) ]
then
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment