preparation-scripts/installation/dhcp.sh

24 lines
587 B
Bash
Raw Normal View History

2024-11-18 20:14:39 +01:00
#!/bin/bash
2024-11-23 15:16:52 +01:00
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2024 Interstellar Development
2024-11-18 20:14:39 +01:00
sudo apt update
sudo apt install -y isc-dhcp-server
2024-11-18 20:49:49 +01:00
config="default-lease-time 600;
max-lease-time 7200;
2024-11-18 21:25:26 +01:00
subnet 192.168.16.0 netmask 255.255.255.0 {
range 192.168.16.10 192.168.16.100;
2024-11-18 20:49:49 +01:00
option subnet-mask 255.255.255.0;
2024-11-18 21:25:26 +01:00
option domain-name-servers 192.168.16.1;
2024-11-18 20:14:39 +01:00
}"
2024-11-18 20:39:01 +01:00
echo -e "INTERFACES='$1'" | sudo tee /etc/default/isc-dhcp-server >/dev/null
2024-11-18 20:22:57 +01:00
2024-11-18 20:16:54 +01:00
echo -e "$config" | sudo tee /etc/dhcp/dhcpd.conf >/dev/null
2024-11-18 20:18:51 +01:00
2024-11-18 20:22:57 +01:00
systemctl start isc-dhcp-server
systemctl enable isc-dhcp-server