Static.sh 785 B

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