From f9ba389e22faa292eea23f067136501eb6b482a9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 29 Jun 2020 12:26:59 -0600 Subject: [PATCH] add vps-myip --- vps-myip/README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++ vps-myip/install.sh | 17 ++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 vps-myip/README.md create mode 100644 vps-myip/install.sh diff --git a/vps-myip/README.md b/vps-myip/README.md new file mode 100644 index 0000000..2c8fac8 --- /dev/null +++ b/vps-myip/README.md @@ -0,0 +1,63 @@ +--- +title: VPS My IP +homepage: https://webinstall.dev/vps-myip +tagline: | + VPS My IP answers the question "what's my IP address?" +linux: true +description: | + Creates permanent swap space that will be activated on each boot. + + `vps-myip` will contact ipify.org to tell you your IP addresses: + + 1. `api.ipify.org` for your IPv4 or A address + 2. `api6.ipify.org` for your IPv6 or AAAA address +--- + +Example output: + +```txt +IPv4 (A) : 136.36.196.101 +IPv6 (AAAA): 2605:a601:a919:9800:f8be:f2c4:9ad7:9763 +``` + +### What is an IP address? + +An IP or Internet Protocol address is basically the phone number of your +computer or server. + +Whenever you visit a domain - such as https://google.com - the `google.com` part +is _resolved_ to the IP address using, quite literally, the internet's Contacts +list, known as DNS. + +### How to get your IP address? + +Due to how complex networking can be, the most reliable way to get your IP +address is basically to "make a call" to another server and ask it to tell you +what shows up on the "called id", as it were. + +_IPify_ is such a service. + +You likely have an IPv4 or A address as well as an IPv6 or AAAA address. + +To find out your IPv4 or A address: + +```bash +curl -s https://api.ipify.org +``` + +To find out your IPv6 or AAAA address: + +```bash +curl -s https://api6.ipify.org +``` + +To find out either address: + +```bash +curl -s https://api46.ipify.org +``` + +You can also use the `ifconfig`, `ip`, or `ipconfig` commands to figure this +out, but they may give you incorrect information if the network setup is complex +(as is the case... most of the time - home and business networks, cloud +networks, etc). diff --git a/vps-myip/install.sh b/vps-myip/install.sh new file mode 100644 index 0000000..aa6980c --- /dev/null +++ b/vps-myip/install.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +{ + set -e + set -u + + ipv4=$(curl -s https://api.ipify.org) + ipv6=$(curl -s https://api6.ipify.org) + + if [ -n "$ipv4" ]; then + echo "IPv4 (A) : $ipv4" + fi + + if [ -n "$ipv6" ] && [ "ipv6" != "ipv4" ]; then + echo "IPv6 (AAAA): $ipv6" + fi +} -- 2.25.1