Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ident.me for private networks #53

Open
randyramig opened this issue Dec 13, 2020 · 0 comments
Open

Using ident.me for private networks #53

randyramig opened this issue Dec 13, 2020 · 0 comments

Comments

@randyramig
Copy link

Like many people, I have an ISP (Comcast/Xfinity) where my internal network is private behind the public IP address that the ISP provides. The script isn't useful in its current form because it is obtaining the IP address of the local machine and for that local machine is a non-routable private address. Below is what I did, I did not have permissions to push a topic branch and create a PR.

I updated the script as follows for my needs:

  1. Added the -r option. This takes an argument in the form of "v4" or "v6" which maps to using v4.ident.me or v6.ident.me servers used to look up the public facing IP address for my network.
identme_ver=

while getopts "hH:i:p:r:u:vV" opt; do
        case $opt in
                h)
                        usage
                        ;;

                H)
                        custom_host="$custom_host $OPTARG"
                        ;;

                i)
                        local_interface_addr=$OPTARG
                        ;;

                p)
                        YDNS_PASSWD=$OPTARG
                        ;;

                u)
                        YDNS_USER=$OPTARG
                        ;;

                r)
                        identme_ver=$OPTARG
                        ;;

                v)
                        show_version
                        ;;

                V)
                        verbose=1
                        ;;
        esac
done
  1. If -r [v4|v6] is specified, use ident.me for the current_ip lookup:
if [ "$identme_ver" != "" ]; then
        # Obtain current address via ident.me
        current_ip=$(curl -s ${identme_ver}.ident.me)
elif [ "$local_interface_addr" != "" ]; then
        # Retrieve current local IP address for a given interface

    if hash ip 2>/dev/null; then
        current_ip=$(ip addr | awk '/inet/ && /'${local_interface_addr}'/{sub(/\/.*$/,"",$2); print $2}')
    fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant