Static.sh 822 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. set -e
  3. # Write Netplan
  4. sudo touch /etc/netplan/01-netcfg.yaml
  5. # Changes dhcp from 'yes' to 'no'
  6. # sed -i "s/dhcp4: yes/dhcp4: no/g" /etc/netplan/01-netcfg.yaml
  7. # Ask for input on network configuration
  8. read -p "Enter the static IP of the server in CIDR notation: " staticip
  9. read -p "Enter the IP of your gateway: " gatewayip
  10. read -p "Enter the IP of DNS Server 1" DNS1
  11. read -p "Enter the IP of DNS Server 2" DNS2
  12. read -p "Enter the name of the seach domain" domain
  13. echo
  14. cat > /etc/netplan/01-netcfg.yaml <<EOF
  15. network:
  16. version: 2
  17. renderer: networkd
  18. ethernets:
  19. ens160
  20. addresses:
  21. - $staticip
  22. gateway4: $gatewayip
  23. nameservers:
  24. addresses:
  25. - $DNS1
  26. - $DNS2
  27. search:
  28. - $domain
  29. EOF
  30. sudo netplan apply
  31. echo "==========================="
  32. echo