#!/usr/bin/bash

# This example script parses /etc/resolv.conf to retrive DNS information.
# This script is expected to print the nameserver values to stdout.
# RHEL specific implementation, use NetworkManager information.

[ ! -z "$1" ] || exit 1

nmcon=$(nmcli -g GENERAL.CONNECTION device show "$1" 2>/dev/null)

if [ -z "$nmcon" ]; then
exit 0
fi

nmcli -g IP4.DNS -e no connection show "$nmcon" 2>/dev/null | sed 's, | ,\n,g'

nmcli -g IP6.DNS -e no connection show "$nmcon" 2>/dev/null | sed 's, | ,\n,g'
