| 1 |
## |
| 2 |
## Debian-Installer NetBoot Assistant: installbox |
| 3 |
## ================================================ |
| 4 |
## |
| 5 |
## This example shows how to set up a machine with two NICs as an 'installbox'. |
| 6 |
## Interface wlp1s0 is connected to the internet, enp2s0 serves the installer: |
| 7 |
## __ |
| 8 |
## __/ \__ ┌────────────────────┐ |
| 9 |
## / \ ┌────────┐ wlp1s0 │ installbox │ |
| 10 |
## ( Internet )──┤ router ├─··········─┤di-netboot-assistant│ |
| 11 |
## \__ __/ └────────┘ └─────────┬──────────┘ |
| 12 |
## \__/ │ enp2s0 |
| 13 |
## │ |
| 14 |
## ┌─────────┴─────────┐ |
| 15 |
## │ client computer │ |
| 16 |
## │ to be installed │ |
| 17 |
## └───────────────────┘ |
| 18 |
|
| 19 |
## Install packages, stop dnsmasq and prevent it from starting at boot: |
| 20 |
# apt install di-netboot-assistant dnsmasq nftables debian-installer-netboot-amd64 |
| 21 |
# systemctl stop dnsmasq |
| 22 |
# systemctl disable dnsmasq |
| 23 |
# cp /usr/share/doc/di-netboot-assistant/examples/dnsmasq.conf.simple \ |
| 24 |
# /etc/dnsmasq.d/netboot-installer |
| 25 |
|
| 26 |
## Prepare location for debian-installer-netboot-amd64 images: |
| 27 |
# mkdir -p /var/lib/tftpboot/d-i/n-pkg/ |
| 28 |
|
| 29 |
## Customize the following interface variable, check all following commands, and |
| 30 |
## finally execute this file like 'sudo bash README.installbox' for a quick start. |
| 31 |
|
| 32 |
LAN_IF="${LAN_IF:-enp2s0}" |
| 33 |
|
| 34 |
set -ex |
| 35 |
|
| 36 |
## Make packaged installer files available: |
| 37 |
mount -o bind,ro /usr/lib/debian-installer/ /var/lib/tftpboot/d-i/n-pkg/ |
| 38 |
di-netboot-assistant rebuild-menu |
| 39 |
di-netboot-assistant install daily |
| 40 |
|
| 41 |
## Configure the netboot interface: |
| 42 |
ip address add 192.168.0.10/24 dev $LAN_IF |
| 43 |
ip link set $LAN_IF up |
| 44 |
|
| 45 |
## Enable forwarding: |
| 46 |
sysctl -w net.ipv4.ip_forward=1 |
| 47 |
|
| 48 |
## Configure masquerading: |
| 49 |
nft add table nat |
| 50 |
nft add chain nat prerouting { type nat hook prerouting priority 0 \; } |
| 51 |
nft add chain nat postrouting { type nat hook postrouting priority 100 \; } |
| 52 |
#nft add rule nat postrouting oifname $WAN_IF masquerade |
| 53 |
nft add rule nat postrouting masquerade |
| 54 |
|
| 55 |
## Provide DNS, DHCP and a TFTP server for the netboot clients: |
| 56 |
systemctl start dnsmasq |
| 57 |
|
| 58 |
|
| 59 |
##### Hints for persistent configuration: |
| 60 |
# echo '/usr/lib/debian-installer/ /var/lib/tftpboot/d-i/n-pkg/ none bind,ro 0 0' >> /etc/fstab |
| 61 |
|
| 62 |
# cat >> /etc/network/interfaces.d/static <<EOF |
| 63 |
#auto enp2s0 |
| 64 |
#iface enp2s0 inet static |
| 65 |
# address 192.168.0.10/24 |
| 66 |
#EOF |
| 67 |
|
| 68 |
# systemctl enable dnsmasq |
| 69 |
|
| 70 |
# echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/netboot-installer.conf |
| 71 |
|
| 72 |
# systemctl enable nftables.service |
| 73 |
# cp /etc/nftables.conf /etc/nftables.conf.orig |
| 74 |
# nft list ruleset > /etc/nftables.conf |