DNS Latency and Route Invalid script

Need two scripts:

  1. Change DNS by checking latency if it is higher than 15ms through script.

  2. Need to send email when specific Route is invalid