From bab23f75eb1f7f441b263938093920b26aa42537 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Thu, 6 Jul 2017 06:51:52 +0000 Subject: [PATCH] Configure DHCP server --- build.sh | 14 +++++++++++ files/dhcpd.conf.d/192.168.82.0.conf | 6 +++++ files/interfaces.d/eth0 | 8 +++++++ patches/06-dhcp-server.diff | 36 ++++++++++++++++++++++++++++ patches/series | 1 + 5 files changed, 65 insertions(+) create mode 100644 files/dhcpd.conf.d/192.168.82.0.conf create mode 100644 files/interfaces.d/eth0 create mode 100644 patches/06-dhcp-server.diff diff --git a/build.sh b/build.sh index d29d4dd..36854f8 100755 --- a/build.sh +++ b/build.sh @@ -244,6 +244,8 @@ chmod 644 "$ROOTFS_DIR/etc/hostname" echo "127.0.1.1 $HOSTNAME" >>"$ROOTFS_DIR/etc/hosts" +install -m 644 files/interfaces.d/eth0 "$ROOTFS_DIR/etc/network/interfaces.d/" + ## # Add user. # @@ -318,6 +320,18 @@ systemctl disable hwclock.sh fake-hwclock save EOF +## +# ISC DHCP server +# +on_chroot << EOF +apt-get install -y isc-dhcp-server +EOF + +apply_patch '06-dhcp-server.diff' + +install -d "$ROOTFS_DIR/etc/dhcp/dhcpd.conf.d/" +install -m 644 files/dhcpd.conf.d/192.168.82.0.conf "$ROOTFS_DIR/etc/dhcp/dhcpd.conf.d/" + ## # Unmount virtual file systems. # diff --git a/files/dhcpd.conf.d/192.168.82.0.conf b/files/dhcpd.conf.d/192.168.82.0.conf new file mode 100644 index 0000000..6456869 --- /dev/null +++ b/files/dhcpd.conf.d/192.168.82.0.conf @@ -0,0 +1,6 @@ +subnet 192.168.82.0 netmask 255.255.255.0 { + range 192.168.82.2 192.168.82.254; + + option routers 192.168.82.1; + option broadcast-address 192.168.82.255; +} diff --git a/files/interfaces.d/eth0 b/files/interfaces.d/eth0 new file mode 100644 index 0000000..d211483 --- /dev/null +++ b/files/interfaces.d/eth0 @@ -0,0 +1,8 @@ +auto eth0 +allow-hotplug eth0 +iface eth0 inet static + netmask 255.255.255.0 + network 192.168.82.0 + gateway 192.168.82.1 + broadcast 192.168.82.255 + address 192.168.82.1 diff --git a/patches/06-dhcp-server.diff b/patches/06-dhcp-server.diff new file mode 100644 index 0000000..8e9cc06 --- /dev/null +++ b/patches/06-dhcp-server.diff @@ -0,0 +1,36 @@ +--- rootfs.orig/etc/dhcp/dhcpd.conf ++++ rootfs/etc/dhcp/dhcpd.conf +@@ -10,20 +10,22 @@ + ddns-update-style none; + + # option definitions common to all supported networks... +-option domain-name "example.org"; +-option domain-name-servers ns1.example.org, ns2.example.org; ++option domain-name "barnacleos.local"; ++option domain-name-servers 8.8.8.8, 8.8.4.4; + + default-lease-time 600; + max-lease-time 7200; + + # If this DHCP server is the official DHCP server for the local + # network, the authoritative directive should be uncommented. +-#authoritative; ++authoritative; + + # Use this to send dhcp log messages to a different log file (you also + # have to hack syslog.conf to complete the redirection). + log-facility local7; + ++include "/etc/dhcp/dhcpd.conf.d/192.168.82.0.conf"; ++ + # No service will be given on this subnet, but declaring it helps the + # DHCP server to understand the network topology. + +--- rootfs.orig/etc/default/isc-dhcp-server ++++ rootfs/etc/default/isc-dhcp-server +@@ -18,4 +18,4 @@ + + # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? + # Separate multiple interfaces with spaces, e.g. "eth0 eth1". +-INTERFACES="" ++INTERFACES="eth0" diff --git a/patches/series b/patches/series index d1ed418..9f6463a 100644 --- a/patches/series +++ b/patches/series @@ -3,3 +3,4 @@ 03-useradd.diff 04-swap.diff 05-path.diff +06-dhcp-server.diff