diff options
| author | Christian Poessinger <christian@poessinger.com> | 2022-06-10 20:07:57 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-10 20:07:57 +0200 | 
| commit | 299e16aae6d2b1038be5b3d492000c590050b4c9 (patch) | |
| tree | 100cd850c2d3564cb8f335f0c67efb9bcfe78059 | |
| parent | 18b303734d84c0c5677ea4d872ec068ffcab4cad (diff) | |
| parent | a03b89039266b8e2a9cf95eef026365a863a8431 (diff) | |
| download | vyos-1x-299e16aae6d2b1038be5b3d492000c590050b4c9.tar.gz vyos-1x-299e16aae6d2b1038be5b3d492000c590050b4c9.zip | |
Merge pull request #1326 from sever-sever/T4429
op-mode: T4429: Ability to detect external IP address
| -rw-r--r-- | op-mode-definitions/show-ip.xml.in | 6 | ||||
| -rwxr-xr-x | src/op_mode/show_ip_external.sh | 19 | 
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 d342ac192..d21c38ccc 100644 --- a/op-mode-definitions/show-ip.xml.in +++ b/op-mode-definitions/show-ip.xml.in @@ -7,6 +7,12 @@            <help>Show IPv4 networking 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 (ARP) table</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 | 
