3

How do I switch DNS by command-line?

I mean like, changing between Google DNS or OpenDNS and whatever the system default is.

Owen_AR
  • 371

1 Answers1

1

Here's a little script to achieve that, replace the IPs with your DNS servers and add this script to your path

#!/bin/bash
if [ $1 == "1" ]; then
echo "nameserver 10.1.0.1" > /etc/resolv.conf 
fi
if [ $1 == "2" ]; then
echo "nameserver 10.1.0.2" > /etc/resolv.conf
fi