Skip to content

Instantly share code, notes, and snippets.

@mshafiee
Created May 8, 2022 13:36
Show Gist options
  • Save mshafiee/0b3e93c34c154dad0cab5be4724cb72c to your computer and use it in GitHub Desktop.
Save mshafiee/0b3e93c34c154dad0cab5be4724cb72c to your computer and use it in GitHub Desktop.
Ubuntu 20.04.4 - Scripting Netplan for custom DNS address
sudo snap install yq
sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bk_`date +%Y%m%d%H%M`
cat /etc/netplan/00-installer-config.yaml | yq -e '.network.ethernets.ens160.nameservers.addresses[0]="192.168.10.11" | .network.ethernets.ens160.nameservers.addresses[1]="192.168.10.12"' | sudo tee /etc/netplan/00-installer-config.yaml
sudo netplan apply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment