I am writing a script on 16.04; to show connection identification, especially for VPN connections, by listing active connections with

ip -o link sh up | awk 'BEGIN{FS=": "} $2!="lo" {print $2}'

and getting:


Now I want to get/return the Connection NAME, the same as from:

#: nmcli  con sh --active
NAME             UUID                                  TYPE            DEVICE  
VPN-pptp-01      22222222-2222-f48f-99d0-817335722def  vpn             enp0s25 
enp0s25          11111111-1111-43c9-9577-112ae6f11abc  802-3-ethernet  enp0s25

using the previously return active device ID, especially for ppp0 (from above)

How can this be done using nmcli or perhaps D-Bus?

1 Answer 1


You can use the following command:

nmcli -t -f NAME c show --active
  • 1
    nmcli -t -f NAME c s -a returns the connection name with no way to associate the link device, in this case "ppp0" and thus return the IP address. Further, nmcli -t -f NAME,DEVICE c s -a does not return ppp0, but instead the ethernet device interface. I need to be able to return for the link: + the IP address, + gateway IP address, + connection name for the link, in this case ppp0 Jan 8, 2019 at 8:06
  • Looks like I might have to use 'C' or Python code to solve this. Does anyone have any light to shine on this problem, i.e. For all Active Links, i.e link state up, I need to print out the following: * link device, e.g. "ppp0", "enp0s25" * Connection Name, e.g. "VPN-pptp-01", "Wired connection 1" * Connection Type, e.g. "vpn", "ethernet" * IP Address * Gateway IP Address Apr 23, 2020 at 3:25
  • It is weird that your actual VPN device did not show up as tun0 or other device with nmcli. In my box, at least 3 entries: eth0, my-VPN, and tun0. Jan 11, 2023 at 4:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .