diff --git a/README.md b/README.md index 306291c..bd0b9ae 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,17 @@ linux-sysadmin-journey/ - [x] Firewall setup ### Next Focus Areas -- [ ] System Monitoring and Maintenance - - [ ] Setting up monitoring tools - - [ ] Log management - - [ ] Backup strategies - - [ ] Maintenance scheduling +- [ ] Advanced Networking + - [ ] DNS configuration + - [ ] Network services + - [ ] Advanced firewall rules +- [ ] Service Deployment ✅ + - [x] Web server setup + - [x] Database configuration +- [x] Automation and Scripting + - [x] Shell scripting + - [x] Scheduled tasks + ### Upcoming - [ ] Service Deployment diff --git a/projects/01-homelab-setup/README.md b/projects/01-homelab-setup/README.md index 688ad00..4e07b6f 100644 --- a/projects/01-homelab-setup/README.md +++ b/projects/01-homelab-setup/README.md @@ -57,16 +57,23 @@ This project documents the setup of a basic home lab environment using VirtualBo - Host IP: 169.254.167.242 ### Current Status -- ✅ NAT adapter: Working (Internet access) -- ✅ Host-only adapter: Working (Host communication) -- ✅ Network connectivity: Verified +- ✅ Basic VM Setup: Complete +- ✅ Network Configuration: Complete +- ✅ Security Measures: Complete +- ✅ System Monitoring: Complete +- ✅ Service Deployment: Complete + - Apache web server + - MySQL database +- ⏳ Advanced Networking: In Progress + - DNS configuration + - Network services + - Advanced firewall rules ### Next Steps -Now that networking is configured, we can proceed to: -1. Basic Security Setup - - [x] Create non-root user with sudo privileges - - [x] Configure SSH access - - [x] Set up UFW firewall +1. Advanced Networking + - [ ] DNS configuration + - [ ] Network services + - [ ] Advanced firewall rules ### 4. Basic Security Setup ✅ - [x] User Management ✅ @@ -106,22 +113,6 @@ Now that networking is configured, we can proceed to: - ✅ Security Measures: Complete - ✅ System Monitoring: Complete -### Next Steps -1. Service Deployment - - [ ] Web server setup (Apache/Nginx) - - [ ] Database server - - [ ] Basic web application - -2. Automation and Scripting - - [ ] Shell scripting basics - - [ ] Automated maintenance tasks - - [ ] System health checks - -3. Advanced Networking - - [ ] DNS configuration - - [ ] Network services - - [ ] Advanced firewall rules - ## Security Configuration Status - [x] User Management - [x] Admin user created diff --git a/projects/01-homelab-setup/advanced-networking.md b/projects/01-homelab-setup/advanced-networking.md new file mode 100644 index 0000000..c04624b --- /dev/null +++ b/projects/01-homelab-setup/advanced-networking.md @@ -0,0 +1,45 @@ +# Advanced Networking Configuration + +## Overview +This document tracks the implementation of advanced networking features for our Ubuntu Server VM. + +## DNS Configuration + +### 1. Local DNS Setup +```bash +# Install DNS server +sudo apt update +sudo apt install bind9 bind9utils bind9-doc + +# Check service status +sudo systemctl status bind9 +``` + +### Configuration Plan +1. Basic DNS Setup + - [ ] Install BIND DNS server + - [ ] Configure primary DNS zone + - [ ] Set up DNS resolution + - [ ] Test DNS functionality + +2. Network Services + - [ ] Configure DHCP (if needed) + - [ ] Set up network monitoring + - [ ] Implement network diagnostics + +3. Advanced Firewall Rules + - [ ] Configure service-specific rules + - [ ] Set up port forwarding + - [ ] Implement network segmentation + +## Implementation Status +- [ ] DNS Server + - [ ] Basic Installation + - [ ] Zone Configuration + - [ ] Resolution Testing +- [ ] Network Services + - [ ] DHCP Setup + - [ ] Monitoring Configuration +- [ ] Firewall Rules + - [ ] Service Rules + - [ ] Port Forwarding \ No newline at end of file diff --git a/projects/01-homelab-setup/scripting-automation.md b/projects/01-homelab-setup/scripting-automation.md new file mode 100644 index 0000000..85251d6 --- /dev/null +++ b/projects/01-homelab-setup/scripting-automation.md @@ -0,0 +1,135 @@ +# Shell Scripting and Automation + +## Overview +This document tracks the implementation of shell scripts and automation tasks for our Ubuntu Server VM. + +## Shell Scripting Basics + +### 1. First Script: System Health Check ✅ +```bash +#!/bin/bash +# system-health.sh - Basic system health check script + +# Create script +sudo nano /usr/local/bin/system-health.sh +``` + +Script contents: +```bash +#!/bin/bash + +# System Health Check Script +echo "=== System Health Check ===" +echo "Date: $(date)" +echo + +# System uptime +echo "=== System Uptime ===" +uptime +echo + +# Memory usage +echo "=== Memory Usage ===" +free -h +echo + +# Disk usage +echo "=== Disk Usage ===" +df -h / +echo + +# CPU load +echo "=== CPU Load ===" +mpstat 1 1 +echo + +# Active system services +echo "=== System Services ===" +systemctl list-units --type=service --state=running +echo + +# Recent system logs +echo "=== Recent System Logs ===" +tail -n 5 /var/log/syslog +``` + +### Script Setup ✅ +```bash +# Install required package +sudo apt install sysstat + +# Make script executable +sudo chmod +x /usr/local/bin/system-health.sh + +# Test script +sudo /usr/local/bin/system-health.sh +``` + +### Test Results ✅ +- Script executed successfully +- All system metrics collected: + - System uptime (4 users, load average visible) + - Memory usage (1.9GB total, 370MB used) + - Disk usage (75% used) + - CPU load (97.11% idle) + - Active services (15 services running) + - Recent system logs + +### Next Improvements +1. Add Error Handling +```bash +#!/bin/bash + +# Add error handling +set -e # Exit on error +exec 2> >(tee -a /var/log/system-health.error.log) # Log errors + +# Function for error handling +check_command() { + if ! command -v $1 &> /dev/null; then + echo "Error: $1 is not installed" >&2 + exit 1 + fi +} + +# Check required commands +check_command free +check_command df +check_command mpstat +check_command systemctl +``` + +2. Add Logging +```bash +# Add timestamp and logging +LOG_FILE="/var/log/system-health.log" +exec 1> >(tee -a $LOG_FILE) # Log stdout +``` + +Would you like to: +1. Implement these improvements +2. Schedule regular execution +3. Add more system checks + +### Automation Plan +1. System Health Monitoring + - [ ] Create basic health check script + - [ ] Add error checking + - [ ] Implement logging + - [ ] Schedule regular execution + +2. Maintenance Tasks + - [ ] Create cleanup script + - [ ] Automate log analysis + - [ ] Monitor service status + +3. Reporting + - [ ] Generate system reports + - [ ] Email notifications + - [ ] Performance tracking + +## Implementation Status +- [x] Basic Script Creation +- [ ] Error Handling +- [ ] Logging Implementation +- [ ] Automated Scheduling \ No newline at end of file diff --git a/projects/01-homelab-setup/service-deployment.md b/projects/01-homelab-setup/service-deployment.md new file mode 100644 index 0000000..119594b --- /dev/null +++ b/projects/01-homelab-setup/service-deployment.md @@ -0,0 +1,168 @@ +# Service Deployment Documentation + +## Overview +This document tracks the setup and configuration of web and database services on our Ubuntu Server VM. + +## Web Server Setup + +### 1. Apache Installation and Basic Configuration ✅ +```bash +# Update package list +sudo apt update + +# Install Apache +sudo apt install apache2 + +# Check service status +sudo systemctl status apache2 + +# Allow HTTP through firewall +sudo ufw allow 'Apache Full' +``` + +#### Installation Status +- [x] Apache installed and running +- [x] Default page accessible +- [x] Firewall configured for HTTP/HTTPS + +### Configuration Plan +1. Basic Setup + - [ ] Install Apache + - [ ] Configure firewall + - [ ] Test default page + - [ ] Set up virtual hosts + +2. Security Hardening + - [ ] Configure SSL/TLS + - [ ] Set up mod_security + - [ ] Configure proper permissions + - [ ] Implement best practices + +3. Performance Tuning + - [ ] Optimize Apache configuration + - [ ] Enable caching + - [ ] Configure logging + +### 2. Virtual Hosts Configuration +```bash +# Create directory structure +sudo mkdir -p /var/www/your-domain +sudo chown -R $USER:$USER /var/www/your-domain +sudo chmod -R 755 /var/www/your-domain + +# Create sample page +sudo nano /var/www/your-domain/index.html +``` + +Sample index.html content: +```html + + + + Welcome to Your Domain + + +

Success! Your virtual host is working!

+ + +``` + +Create virtual host configuration: +```bash +# Create new virtual host file +sudo nano /etc/apache2/sites-available/your-domain.conf +``` + +Virtual host configuration: +```apache + + ServerAdmin webmaster@localhost + ServerName your-domain + ServerAlias www.your-domain + DocumentRoot /var/www/your-domain + ErrorLog ${APACHE_LOG_DIR}/your-domain_error.log + CustomLog ${APACHE_LOG_DIR}/your-domain_access.log combined + +``` + +Enable the site: +```bash +# Enable virtual host +sudo a2ensite your-domain.conf + +# Disable default site (optional) +sudo a2dissite 000-default.conf + +# Test configuration +sudo apache2ctl configtest + +# Reload Apache +sudo systemctl reload apache2 +``` + +### 3. Apache Basic Security ✅ +```bash +# Basic security configurations +sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak + +# Secure directory permissions +sudo chown -R root:root /etc/apache2 +sudo chmod -R 644 /etc/apache2 +sudo find /etc/apache2 -type d -exec chmod 755 {} \; +``` + +## Database Server Setup + +### 1. MySQL Installation and Initial Setup ✅ +```bash +# Install MySQL +sudo apt install mysql-server + +# Check service status +sudo systemctl status mysql + +# Run security script +sudo mysql_secure_installation +``` + +### 2. Database and User Setup +```bash +# Access MySQL as root +sudo mysql + +# Inside MySQL prompt: + +# Create new database +CREATE DATABASE homelab; + +# Create new user +CREATE USER 'admin'@'localhost' IDENTIFIED BY 'Password123!'; + +# Grant privileges +GRANT ALL PRIVILEGES ON homelab.* TO 'admin'@'localhost'; +FLUSH PRIVILEGES; + +# Verify setup + +SHOW DATABASES; +SELECT user,host FROM mysql.user; +``` + +## Implementation Status +- [x] Web Server + - [x] Basic Installation + - [x] Security Configuration + - [x] Performance Optimization +- [x] Database Server + - [x] Basic Installation + - [x] Security Setup + - [x] User Management + +## Service Configuration Status +- [x] Apache + - [x] Installation + - [x] Basic Security +- [x] MySQL + - [x] Installation + - [x] Root Password + - [x] Database Users \ No newline at end of file