Shell · Inline
My IP Addresses
Shows the local address of each active network interface and your public IP address. The public address is looked up at api.ipify.org.
- Language
- Shell
- Output
- Inline
- Keyword
ip- Arguments
- None
- Timeout
- 15 s
- Licence
- MIT
- Author
- Docktopus
- File
- my-ip-addresses.zsh (734 bytes)
- Downloads
- 1
In Docktopus: Settings → Scripts → Browse Community Scripts. Read the source before you run any script.
Source
my-ip-addresses.zsh · sha256 c0f19e609f85…#!/bin/zsh
# @docktopus.schemaVersion 1
# @docktopus.title My IP Addresses
# @docktopus.mode inline
# @docktopus.icon network
# @docktopus.keyword ip
# @docktopus.description Shows the local address of each active network interface and your public IP address. The public address is looked up at api.ipify.org.
# @docktopus.timeout 15
# @docktopus.author Docktopus
found=0
for interface in $(/sbin/ifconfig -lu); do
address=$(/usr/sbin/ipconfig getifaddr "$interface" 2>/dev/null)
if [[ -n "$address" ]]; then
echo "Local ($interface): $address"
found=1
fi
done
(( found )) || echo "Local: not connected"
public=$(/usr/bin/curl -fsS --max-time 8 https://api.ipify.org 2>/dev/null)
echo "Public: ${public:-unavailable}"