Marcus Penate 141ac1c9dd Initial commit: DHCP whitelist service for direct link connections
Features:
- Docker-based DHCP server with MAC address whitelisting
- Binds to specific ethernet interface only
- NO DNS/gateway advertised (direct link only, not a router)
- Configurable network parameters (subnet, DHCP range, lease times)
- Systemd service integration for Arch/Manjaro
- Test environment with isolated network (172.20.0.0/24)
- Auto-configuration script to detect network settings
- Complete Makefile with management targets

Security:
- Only responds to whitelisted MAC addresses
- deny unknown-clients configuration
- Runs in Docker container for isolation

Configuration:
- Copy .example files to create your config
- interface.conf: Network interface to bind to
- whitelist.conf: Allowed MAC addresses
- network.conf: Network parameters (optional)
2025-08-27 20:46:29 -04:00

78 lines
2.8 KiB
Makefile

.PHONY: up down install service_up service_down test autoconfig clean help
# Default target
help:
@echo "Available targets:"
@echo " up - Start DHCP server in userland mode"
@echo " down - Stop DHCP server"
@echo " install - Install as systemd service (requires sudo)"
@echo " service_up - Enable and start systemd service"
@echo " service_down - Disable and stop systemd service"
@echo " test - Run test environment with virtual network (172.20.0.0/24)"
@echo " test-clean - Clean up test environment"
@echo " autoconfig - Auto-generate configuration from current network"
@echo " clean - Remove all containers and generated files"
# Start DHCP server in userland mode
up:
@echo "Building DHCP server image..."
@docker-compose build
@echo "Starting DHCP server..."
@docker-compose up -d
@echo "DHCP server started. Check logs with: docker-compose logs -f"
# Stop DHCP server
down:
@echo "Stopping DHCP server..."
@docker-compose down
@echo "DHCP server stopped."
# Install as systemd service (requires sudo)
install:
@echo "Installing systemd service..."
@bash scripts/install-service.sh
@echo "Service installed. Use 'make service_up' to start."
# Enable and start systemd service
service_up:
@echo "Enabling and starting systemd service..."
@systemctl --user enable dhcp-whitelist.service 2>/dev/null || sudo systemctl enable dhcp-whitelist.service
@systemctl --user start dhcp-whitelist.service 2>/dev/null || sudo systemctl start dhcp-whitelist.service
@echo "Service started. Check status with: systemctl status dhcp-whitelist"
# Disable and stop systemd service
service_down:
@echo "Stopping and disabling systemd service..."
@systemctl --user stop dhcp-whitelist.service 2>/dev/null || sudo systemctl stop dhcp-whitelist.service
@systemctl --user disable dhcp-whitelist.service 2>/dev/null || sudo systemctl disable dhcp-whitelist.service
@echo "Service stopped."
# Run test environment
test:
@echo "Building test environment..."
@docker-compose -f docker-compose.test.yml build
@echo "Running tests..."
@docker-compose -f docker-compose.test.yml up --abort-on-container-exit
@$(MAKE) test-clean
@echo "Tests completed."
# Clean up test environment (always runs, even on test failure)
test-clean:
@echo "Cleaning up test environment..."
@docker-compose -f docker-compose.test.yml down -v --remove-orphans 2>/dev/null || true
@docker network rm service-dhcp-direct-link-only_test-net 2>/dev/null || true
@echo "Test cleanup complete."
# Auto-generate configuration
autoconfig:
@echo "Auto-generating configuration..."
@bash scripts/autoconfig.sh
@echo "Configuration generated. Review config/ directory before starting."
# Clean up
clean:
@echo "Cleaning up..."
@docker-compose down 2>/dev/null || true
@$(MAKE) test-clean
@rm -f config/*.tmp
@echo "Cleanup complete."