summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op-mode-definitions/show-ip.xml.in6
-rwxr-xr-xsrc/op_mode/show_ip_external.sh19
2 files changed, 25 insertions, 0 deletions
diff --git a/op-mode-definitions/show-ip.xml.in b/op-mode-definitions/show-ip.xml.in
index 91564440d..30c08f8e8 100644
--- a/op-mode-definitions/show-ip.xml.in
+++ b/op-mode-definitions/show-ip.xml.in
@@ -7,6 +7,12 @@
<help>Show IPv4 routing information</help>
</properties>
<children>
+ <node name="external">
+ <properties>
+ <help>Show IPv4 external address</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/show_ip_external.sh</command>
+ </node>
<node name="neighbors">
<properties>
<help>Show IPv4 Neighbor Discovery (ND) information</help>
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