Created
March 24, 2025 16:29
-
-
Save gilangvperdana/ae2a72b9e9d7a923eac2133d5829ef21 to your computer and use it in GitHub Desktop.
Get Info Our VPN
This file contains 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/bash | |
echo "Profil VPN yang sedang berjalan:" | |
echo "-------------------------------------------------------------" | |
echo "TUN Interface | Profile | Subnet | Routing Table" | |
echo "-------------------------------------------------------------" | |
for conf in /etc/openvpn/*.conf; do | |
vpn_name=$(basename "$conf" .conf) | |
# Cek apakah OpenVPN aktif untuk profil ini | |
systemctl is-active --quiet "openvpn@$vpn_name" | |
if [[ $? -ne 0 ]]; then | |
continue | |
fi | |
# Ambil interface tun dari log journalctl | |
tun_iface=$(journalctl -u "openvpn@$vpn_name" --no-pager | grep "TUN/TAP" | grep -oP 'tun\d+' | tail -n1) | |
if [[ -z "$tun_iface" ]]; then | |
continue | |
fi | |
# Ambil subnet dari IP address pada interface tun | |
subnet=$(ip -o -f inet addr show dev "$tun_iface" | awk '{print $4}') | |
# Ambil routing yang terkait dengan tun_iface | |
routes=$(ip route show dev "$tun_iface" | awk '{print $1}' | paste -sd "," -) | |
printf "%-13s | %-7s | %-15s | %-30s\n" "$tun_iface" "$vpn_name" "$subnet" "$routes" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment