• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Checking Nameservers

January 15, 2023

Handy little script to see if nameserver is on an array.

#!/bin/bash
declare -a servers=("127.0.0.53" "127.0.0.52" "127.0.0.51")
client=$(cat /etc/resolv.conf | grep nameserver)
for i in "${servers[@]}"
do
  if [[ $client =~ $i ]]
  then 
    using_unbound="true"
    break
  else
    using_unbound="false"
  fi
done
echo $using_unbound "|" $client

#!/bin/bash declare -a servers=("127.0.0.53" "127.0.0.52" "127.0.0.51") client=$(cat /etc/resolv.conf | grep nameserver) for i in "${servers[@]}" do if [[ $client =~ $i ]] then using_unbound="true" break else using_unbound="false" fi done echo $using_unbound "|" $client

Filed Under: Linux Tagged With: check, nameservers

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023