Parcourir la source

Remove Network.sh
Add dhcp.sh
Add static.sh

chagood il y a 2 ans
Parent
commit
aa0280fe89
2 fichiers modifiés avec 53 ajouts et 0 suppressions
  1. 34 0
      Static.sh
  2. 19 0
      dhcp.sh

+ 34 - 0
Static.sh

@@ -0,0 +1,34 @@
+#!/bin/bash
+
+set -e
+
+# Write Netplan
+sudo touch /etc/netplan/01-netcfg.yaml
+# Changes dhcp from 'yes' to 'no'
+# sed -i "s/dhcp4: yes/dhcp4: no/g" /etc/netplan/01-netcfg.yaml
+# Ask for input on network configuration
+read -p "Enter the static IP of the server in CIDR notation: " staticip 
+read -p "Enter the IP of your gateway: " gatewayip
+read -p "Enter the IP of DNS Server 1" DNS1
+read -p "Enter the IP of DNS Server 2" DNS2
+read -p "Enter the name of the seach domain" domain
+echo
+cat > /etc/netplan/01-netcfg.yaml <<EOF
+network:
+  version: 2
+  renderer: networkd
+  ethernets:
+    ens160
+      addresses:
+        - $staticip
+      gateway4: $gatewayip
+      nameservers:
+        addresses: 
+        - $DNS1
+        - $DNS2
+        search:
+        - $domain
+EOF
+sudo netplan apply
+echo "==========================="
+echo

+ 19 - 0
dhcp.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+
+# Write Netplan
+sudo touch /etc/netplan/01-netcfg.yaml
+
+echo
+cat > /etc/netplan/01-netcfg.yaml <<EOF
+network:
+  version: 2
+  ethernets:
+    ens160:
+      dhcp4: yes
+      dhcp-identifier: mac
+EOF
+sudo netplan apply
+echo "==========================="
+echo