Integrating Ubuntu Cobbler with a DHCP Server for Automated OS Deployment
Cobbler simplifies network-based OS installations by automating PXE boot, kickstart file distribution, and package management. When paired with a DHCP server, it eliminates manual IP assignment—allowing clients to automatically retrieve network settings and initiate installations. Below is a structured guide to configuring this integration on Ubuntu.
Before starting, ensure your Ubuntu server has:
192.168.1.2).apt, nano).Update your package list and install Cobbler along with required components (DHCP server, TFTP server, and xinetd for TFTP management):
sudo apt update
sudo apt install cobbler cobbler-web isc-dhcp-server tftpd-hpa xinetd -y
This installs Cobbler (the core tool), ISC DHCP (for IP allocation), TFTP (for boot files), and xinetd (to manage TFTP as a service).
Edit Cobbler’s main configuration file to define its network identity and enable DHCP/TFTP management:
sudo nano /etc/cobbler/settings
Update the following key parameters:
server: Set to your Cobbler server’s static IP (e.g., 192.168.1.2). This tells clients where to find Cobbler’s files.next_server: Also set to your Cobbler server’s IP (same as server). This points clients to the TFTP server for boot files.manage_dhcp: Set to 1 to allow Cobbler to generate and manage the DHCP configuration file (avoids manual edits).default_password_crypted: Generate a default root password for installed systems using openssl passwd -1 (e.g., $1$rLza5zNH$xLKFqWoK32/IA/zslG3Up0) and paste it here.Save and exit the file.
Cobbler uses a template to generate the DHCP configuration file. Edit the template to define your network’s IP range, gateway, DNS, and PXE boot settings:
sudo nano /etc/cobbler/dhcp.template
Add/modify the following block (customize values for your network):
subnet 192.168.1.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.1.100 192.168.1.200; # IP range for clients
option routers 192.168.1.1; # Gateway
option domain-name-servers 8.8.8.8, 8.8.4.4; # DNS servers
filename "pxelinux.0"; # Boot file for PXE
next-server $next_server; # Cobbler server (from settings)
default-lease-time 21600; # 6-hour lease
max-lease-time 43200; # 12-hour max lease
}
Key notes:
192.168.1.0/24 with your subnet.next-server uses $next_server (a Cobbler variable that auto-replaces with the next_server value from /etc/cobbler/settings).TFTP serves the initial boot files (e.g., pxelinux.0) to clients. Edit the TFTP configuration file to enable the service and set the root directory:
sudo nano /etc/xinetd.d/tftp
Modify the service tftp section to enable TFTP and specify the root directory (where Cobbler stores boot files):
service tftp
{
disable = no # Enable TFTP
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot # Root directory for TFTP files
per_source = 11
cps = 100 2
flags = IPv4
}
Save and exit.
After making changes, run cobbler sync to apply them. This command:
/etc/cobbler/dhcp.template).pxelinux.0) to the TFTP root directory (/var/lib/tftpboot).Run the command:
sudo cobbler sync
Restart the DHCP and TFTP services to load the new configurations:
sudo systemctl restart isc-dhcp-server
sudo systemctl restart xinetd
Enable them to start on boot (optional but recommended):
sudo systemctl enable isc-dhcp-server
sudo systemctl enable xinetd
Ensure the DHCP service is running without errors:
sudo systemctl status isc-dhcp-server
Look for “active (running)” in the output.
On a client machine connected to the same network, release and renew its IP address to verify it receives an IP from Cobbler’s range:
sudo dhclient -r eth0 # Release current IP
sudo dhclient eth0 # Request new IP
ip a # Check assigned IP (should be in 192.168.1.100-200 range)
Set the client to boot from the network (via BIOS/UEFI: prioritize “Network Boot” or “PXE”). If configured correctly, the client should:
pxelinux.0 boot file from the Cobbler server (TFTP).To automate OS installation (e.g., Ubuntu Server), import an OS image and create a kickstart file:
Download an Ubuntu ISO (e.g., ubuntu-22.04-live-server-amd64.iso) and place it in /tmp. Import it into Cobbler:
sudo cobbler import --path /tmp/ubuntu-22.04-live-server-amd64.iso --name ubuntu-22.04
This creates a “distro” (OS distribution) in Cobbler.
Generate a default kickstart file (for automated installation):
sudo cobbler profile edit --name ubuntu-22.04 --kickstart /var/lib/cobbler/kickstarts/ubuntu-22.04.seed
Customize the kickstart file (e.g., partitioning, user creation) as needed.
Link the distro to a system profile (used to install specific machines):
sudo cobbler profile add --name ubuntu-22.04-profile --distro ubuntu-22.04 --kickstart /var/lib/cobbler/kickstarts/ubuntu-22.04.seed
manage_dhcp is set to 1 in /etc/cobbler/settings.systemctl status xinetd) and boot files exist in /var/lib/tftpboot./var/log/cobbler/cobbler.log for details.By following these steps, you’ll have a fully integrated Cobbler-DHCP setup that automates IP allocation and OS deployment over your network.