Skip to content

Instantly share code, notes, and snippets.

@ruzfi
Last active July 8, 2026 08:33
Show Gist options
  • Select an option

  • Save ruzfi/0bfea1b0de2d813d94fe0695368cc452 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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
@ruzfi

ruzfi commented Jul 8, 2026

Copy link
Copy Markdown
Author

How to use on your fresh installed xfce4 kali linux machine

  1. Grab this script and save to your preferred path (usually genmon script is at /usr/share/kali-themes/)
  2. Add execute permission to the script
    chmod+x /path/to/xfce4-panel-genmon-multiple-vpnip.sh
  3. Open xfce4 panel preferences then go to "Items" tab and find Generic Monitor (kali linux is having this by default if not found add manually)
Screenshot 2026-07-08 at 15-19-55
  1. Select Generic Monitor then click hamburger icon right to the remove button and it will open Generic Monitor Configuration window
Screenshot 2026-07-08 at 15-21-16
  1. Copy this saved script path and you can also configure how often this script is updated then click Save
Screenshot 2026-07-08 at 15-21-47
  1. It will loaded when any VPN/tuntap interface is available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment