Add DNS options to each ethernet interface

Loading

How to add DNS options to each connected ethernet interface via bash:

for device in $( nmcli device | awk '($2=="ethernet" && $3=="connected") {print $1}'); do
printf "1) %s" "$device interface BEFORE value"
nmcli con show $device | grep ipv4.dns-options:
nmcli con mod $device +ipv4.dns-option rotate,timeout:3
printf "2) %s" "$device interface AFTER value"
nmcli con show $device | grep ipv4.dns-options:
done
printf "3) restarted NetworkManager\n"
systemctl restart NetworkManager
sleep 1
printf "4) show update /etc/resolv.conf\n\n"
cat /etc/resolv.conf

Leave a Reply