summaryrefslogtreecommitdiff
path: root/src/op_mode/show_ip_external.sh
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-05-17 11:19:07 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-05-17 11:19:07 +0000
commita03b89039266b8e2a9cf95eef026365a863a8431 (patch)
tree17d3575be4404bcdc3071b5b6a103c8938cf42ab /src/op_mode/show_ip_external.sh
parent9347dc53c5bd3d5712121524ea16f3030d735601 (diff)
downloadvyos-1x-a03b89039266b8e2a9cf95eef026365a863a8431.tar.gz
vyos-1x-a03b89039266b8e2a9cf95eef026365a863a8431.zip
op-mode: T4429: Ability to detect external IP address
In some cases, it is useful to detect own external IP address for example if the host behind NAT Send curl request to random online service from the list to detect IP address ; show ip external ; 192.0.2.95
Diffstat (limited to 'src/op_mode/show_ip_external.sh')
-rwxr-xr-xsrc/op_mode/show_ip_external.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/op_mode/show_ip_external.sh b/src/op_mode/show_ip_external.sh
new file mode 100755
index 000000000..275d05278
--- /dev/null
+++ b/src/op_mode/show_ip_external.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+# Detect an external IP address
+# Use random services for checking
+
+
+array=(
+ ipinfo.io/ip
+ ifconfig.me
+ ipecho.net/plain
+ icanhazip.com
+ v4.ident.me
+ checkip.amazonaws.com
+)
+
+size=${#array[@]}
+index=$(($RANDOM % $size))
+
+curl --silent ${array[$index]} | tr -d "[:space:]" && echo