Files
Misc-Scripts/update-dns.sh
2022-12-18 18:12:17 -06:00

28 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
if [ -f /etc/netplan/eth0.yaml ]; then
cat /etc/netplan/eth0.yaml
else
cat /etc/network/interfaces
fi
echo
read -n 1 -p "Do you wish to continue changing the DNS? (Y/n) " choice
case "$choice" in
[Nn]) exit 0; ;;
* ) if [ -f /etc/netplan/eth0.yaml ]; then
sed -i '/10.5.10.5,10.10.10.10/c\ addresses: [10.20.20.20,10.10.10.10,10.10.10.11]' /etc/netplan/eth0.yaml
sed -i '/10.10.10.10,10.5.10.5/c\ addresses: [10.20.20.20,10.10.10.10,10.10.10.11]' /etc/netplan/eth0.yaml
sed -i '/10.10.10.2,10.10.10.3/c\ addresses: [10.20.20.20,10.10.10.10,10.10.10.11]' /etc/netplan/eth0.yaml
sed -i '/10.10.10.10,10.10.10.11/c\ addresses: [10.20.20.20,10.10.10.10,10.10.10.11]' /etc/netplan/eth0.yaml
/usr/sbin/netplan apply
else
sed -i '/10.10.10.10 10.5.10.5/c\ dns-nameservers 10.20.20.20 10.10.10.10 10.10.10.11' /etc/network/interfaces
sed -i '/10.5.10.5 10.10.10.10/c\ dns-nameservers 10.20.20.20 10.10.10.10 10.10.10.11' /etc/network/interfaces
sed -i '/10.10.10.2 10.10.10.3/c\ dns-nameservers 10.20.20.20 10.10.10.10 10.10.10.11' /etc/network/interfaces
sed -i '/10.10.10.10 10.10.10.11/c\ dns-nameservers 10.20.20.20 10.10.10.10 10.10.10.11' /etc/network/interfaces
/usr/sbin/service networking restart
fi;;
esac