-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetworkingConfigurator
44 lines (31 loc) · 1.12 KB
/
NetworkingConfigurator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# networks in our network are always 24, but if yours differ, edit acordingly
echo "\e[0;96m Please put /24 at the end \e[0m"
# fetch ip
read -p 'ip: ' ip
#fetch gateway
read -p 'gateway: ' gateway
# This grabs the hostname
read -p 'hostname: ' host_name
# This sets the hostname varirable
hostnamectl set-hostname $host_name
# This deletes the machine id
sudo rm -f /etc/machine-id
# This deletes the machine id
sudo rm -f /var/lib/dbus/machine-id
# This sets up the machine id
sudo systemd-machine-id-setup
# chancge the hostname of the system in /etc/hosts
sed -i 's/debian/$host_name/g' /etc/hosts
#change the networking to static if set on dhcp
sed -i 's/dhcp/static/g' /etc/network/interfaces
# delete previous networking if present
sed -i '/address/d' /etc/network/interfaces
sed -i '/gateway/d' /etc/network/interfaces
#set ip and gateway
echo ' address '$ip >> /etc/network/interfaces
echo ' gateway '$gateway >> /etc/network/interfaces
# This restarts networking
sudo systemctl restart networking
echo "\e[0;91m Please restart the system! \e[0m"
# When you use Linux don't Panic!
# Nick Matthews & Pieter Visscher 2023 GPLv3