Last active
July 8, 2026 08:33
-
-
Save ruzfi/0bfea1b0de2d813d94fe0695368cc452 to your computer and use it in GitHub Desktop.
This is my Kali Linux xfce4-genmon-plugin script to show multiple VPN/tuntap ip address usually for exercise lab setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| interfaces="$(ip tuntap show | cut -d : -f1)" # Get all VPN tuntap interfaces | |
| TOOLTIP=$(ss -s | head -n 3 | grep -Ev "^$") | |
| output="" | |
| ip_to_copy="" | |
| for interface in $interfaces; do | |
| ip="$(ip a s "${interface}" 2>/dev/null | grep -o -P '(?<=inet )[0-9]{1,3}(\.[0-9]{1,3}){3}')" | |
| if [ "${ip}" != "" ]; then | |
| output="${output} ${interface}: ${ip}" | |
| # Priority Logic: Overwrite if tun0, otherwise only set if empty | |
| if [ "${interface}" = "tun0" ]; then | |
| ip_to_copy="${ip}" | |
| elif [ "${ip_to_copy}" = "" ]; then | |
| ip_to_copy="${ip}" | |
| fi | |
| fi | |
| done | |
| if [ "${output}" != "" ]; then | |
| printf "<icon>network-vpn-symbolic</icon><txt>${output}</txt>" | |
| # Check for xclip and ensure we actually have an IP to copy | |
| if command -v xclip >/dev/null 2>&1 && [ "${ip_to_copy}" != "" ]; then | |
| # Using %s in printf is safer for variable injection | |
| printf "<tool>VPN IP ${ip_to_copy} (click to copy)\n\n${TOOLTIP}</tool>" | |
| printf "<txtclick>sh -c 'printf \"%%s\" \"%s\" | xclip -selection clipboard'</txtclick>" "${ip_to_copy}" | |
| else | |
| printf "<tool>${TOOLTIP}</tool>" | |
| fi | |
| else | |
| printf "<txt></txt>" | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use on your fresh installed xfce4 kali linux machine
chmod+x /path/to/xfce4-panel-genmon-multiple-vpnip.sh