This project demonstrates a comprehensive network security lab environment designed to test and validate firewall configurations using Linux iptables. The lab simulates a realistic network topology with an attacker machine (Kali Linux), a victim server (LinuxServer), and a centralized logging infrastructure. The primary goal is to implement a honeypot/transparent shield firewall that logs attacks before blocking them, enabling security analysis and verification of attack patterns.
- Protected ports:
21(FTP),22(SSH),23(Telnet) - Tracking list
ABUSE_COUNT: every NEW attempt is--set - Ban list
ABUSE_BANNED:--rcheck --hitcount 4 --seconds 60then--update --seconds 60 -j DROP - Logging prefixes on ban:
FTP_HARD_BAN:,SSH_HARD_BAN:,TELNET_HARD_BAN: - Ordering: ban checks run before any service accepts; honeypot still logs non-SSH service probes and excess SYNs
- From attacker, attempt 5 connections within 60s to any protected port
- Expect a HARD_BAN log prefix in victim
/var/log/syslogand forwarded logs - During ban window (60s), further attempts are dropped with ban logs
- After 60s, attempts are counted again and may re-ban on threshold
- Run
cleanup/cleanup_iptables.shto flush rules and clear xt_recent lists - Recent lists cleared via
/proc/net/xt_recent/ABUSE_COUNTand/proc/net/xt_recent/ABUSE_BANNED - Use
cleanup/cleanup_all.shfor full reset (iptables + services)
┌─────────────────────────────────────────────────────────────┐
│ External Network │
│ 192.168.100.0/24 │
│ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ Cloud/R1 │ │ Kali Attacker│ │
│ │ 192.168.100.1│ │192.168.100.10│ │
│ └──────┬───────┘ └──────────────┘ │
└─────────┼───────────────────────────────────────────────────┘
│
│
┌─────────┼───────────────────────────────────────────────────┐
│ │ DMZ / Server Network │
│ │ 10.10.0.0/24 │
│ │ │
│ ┌──────▼──────┐ │
│ │ Router R2 │ │
│ │ 10.10.0.1 │ │
│ └──────┬──────┘ │
│ │ │
│ ┌──────┼──────┬──────┬────────┬──────────────┐ │
│ │ │ │ │ | │ │
│ │ LinuxServer │ BSDServer │ LogServer │ │
│ │ 10.10.0.10 │ 10.10.0.20 │ 10.10.0.30 │ │
│ │ (Gateway) │ (Gateway) │ (Collector) │ │
│ └──────┬──────┘───────┬───────┘──────────────┘ │
│ │ │ │
│ ┌──────▼──────┐───────▼───────┐ │
│ │ LAN1 │ LAN2 │ │
│ │10.10.10.0/24│ 10.10.20.0/24 │ │
│ │ │ │ │
│ │ PC1: .11 │ PC3: .11 │ │
│ │ PC2: .12 │ PC4: .12 │ │
│ └─────────────┘───────────────┘ │
└─────────────────────────────────────────────────────────────┘
- Cloud/Router R1: 192.168.100.1
- Kali Attacker: 192.168.100.10
- Router R2: 10.10.0.1
- LinuxServer (Victim/Gateway): 10.10.0.10
- Interface 1 (enp0s3): 10.10.0.10/24 (toward R2)
- Interface 2 (enp0s8): 10.10.10.1/24 (toward LAN1)
- BSDServer: 10.10.0.20
- LogServer: 10.10.0.30
- Gateway: LinuxServer (10.10.10.1)
- PC1: 10.10.10.11
- PC2: 10.10.10.12
- Gateway: BSDServer (10.10.20.1)
- PC3: 10.10.20.11
- PC4: 10.10.20.12
- OS: Kali Linux (latest)
- RAM: 2GB minimum (4GB recommended)
- Disk: 20GB minimum
- Network: 1 NIC (NAT or Bridged)
- IP: 192.168.100.10/24
- Purpose: Penetration testing, attack simulation
- OS: Ubuntu Server 20.04/22.04 LTS
- RAM: 2GB minimum (4GB recommended)
- Disk: 20GB minimum
- Network: 2 NICs
- NIC1 (enp0s3): 10.10.0.10/24 (toward R2)
- NIC2 (enp0s8): 10.10.10.1/24 (toward LAN1)
- Purpose: Firewall gateway, victim server, iptables configuration
- OS: Cisco IOS or Linux router
- Network: 2 NICs
- NIC1: 192.168.100.1/24 (toward external)
- NIC2: 10.10.0.1/24 (toward DMZ)
- Purpose: Network routing between external and DMZ
- OS: Ubuntu Server
- RAM: 1GB minimum
- Disk: 10GB minimum
- Network: 1 NIC
- IP: 10.10.0.30/24
- Purpose: Centralized log collection (rsyslog)
- OS: FreeBSD or OpenBSD
- Network: 2 NICs
- NIC1: 10.10.0.20/24 (toward DMZ)
- NIC2: 10.10.20.1/24 (toward LAN2)
- Purpose: Alternative gateway for LAN2
- OS: Any Linux distribution
- Purpose: Test internal network connectivity
- Open VMware Workstation/Player
- Go to Edit → Virtual Network Editor
- Create Custom Networks:
- VMnet2 (External Network): 192.168.100.0/24, Subnet IP: 192.168.100.0
- VMnet3 (DMZ Network): 10.10.0.0/24, Subnet IP: 10.10.0.0
- VMnet4 (LAN1): 10.10.10.0/24, Subnet IP: 10.10.10.0
-
Create New Virtual Machine
- Name:
Kali-Attacker - OS: Linux → Debian 11.x 64-bit
- RAM: 2048 MB
- Disk: 20 GB
- Network: VMnet2 (External Network)
- Name:
-
Install Kali Linux
- Use Kali Linux ISO image
- Complete standard installation
-
Configure Network
sudo ip addr add 192.168.100.10/24 dev eth0 sudo ip link set eth0 up sudo ip route add default via 192.168.100.1 -
Install Required Tools
sudo apt-get update sudo apt-get install -y nmap hping3 hydra snmpwalk nikto tcpdump
-
Create New Virtual Machine
- Name:
LinuxServer-Victim - OS: Linux → Ubuntu 64-bit
- RAM: 2048 MB
- Disk: 20 GB
- Network Adapters: 2 adapters
- Adapter 1: VMnet3 (DMZ Network)
- Adapter 2: VMnet4 (LAN1)
- Name:
-
Install Ubuntu Server
- Use Ubuntu Server 22.04 LTS ISO
- Complete standard installation
-
Configure Network Interfaces
# Interface 1 (enp0s3) - DMZ sudo ip addr add 10.10.0.10/24 dev enp0s3 sudo ip link set enp0s3 up # Interface 2 (enp0s8) - LAN1 sudo ip addr add 10.10.10.1/24 dev enp0s8 sudo ip link set enp0s8 up # Default route sudo ip route add default via 10.10.0.1 dev enp0s3
-
Run Setup Scripts
# Make scripts executable chmod +x victim_services_setup.sh AutoTableV2.sh log_viewer.sh # Setup vulnerable services sudo ./victim_services_setup.sh # Configure firewall (after services are running) sudo ./AutoTableV2.sh
If using a Linux router:
-
Create New Virtual Machine
- Name:
Router-R2 - OS: Linux → Ubuntu Server
- RAM: 512 MB
- Disk: 5 GB
- Network Adapters: 2 adapters
- Adapter 1: VMnet2 (External Network)
- Adapter 2: VMnet3 (DMZ Network)
- Name:
-
Configure Routing
# Enable IP forwarding echo 1 > /proc/sys/net/ipv4/ip_forward # Configure interfaces sudo ip addr add 192.168.100.1/24 dev eth0 sudo ip addr add 10.10.0.1/24 dev eth1 sudo ip link set eth0 up sudo ip link set eth1 up # Add routes sudo ip route add 10.10.10.0/24 via 10.10.0.10 sudo ip route add 10.10.20.0/24 via 10.10.0.20
-
Create New Virtual Machine
- Name:
LogServer - OS: Linux → Ubuntu Server
- RAM: 1024 MB
- Disk: 10 GB
- Network: VMnet3 (DMZ Network)
- Name:
-
Configure rsyslog
# Install rsyslog sudo apt-get update sudo apt-get install -y rsyslog # Configure to receive remote logs sudo nano /etc/rsyslog.conf # Uncomment: # module(load="imudp") # input(type="imudp" port="514") # module(load="imtcp") # input(type="imtcp" port="514") # Create log directory sudo mkdir -p /var/log/remote sudo chmod 755 /var/log/remote # Restart rsyslog sudo systemctl restart rsyslog
Purpose: Verifies attacker machine (Kali Linux) is properly configured before launching attacks.
Location: Run on Kali Attacker machine (192.168.100.10)
Features:
- Checks OS version and compatibility
- Verifies installation of required tools (nmap, hping3, hydra, snmpwalk, nikto, tcpdump)
- Validates network interface configuration
- Checks IP address assignment
- Verifies routing table configuration
- Tests connectivity to target
Usage:
# Make executable
chmod +x attacker_test.sh
# Run as root (some checks require root)
sudo ./attacker_test.shOutput: Displays colored status messages indicating:
- ✅ Installed tools and their paths
⚠️ Missing tools with installation suggestions- ✅ Network interface status
- ✅ IP configuration
- ✅ Routing configuration
- ✅ Connectivity test results
Purpose: Configures vulnerable services on LinuxServer for penetration testing.
Location: Run on LinuxServer machine (10.10.0.10)
Features:
- Installs required service packages (vsftpd, openssh-server, telnetd, apache2, snmpd)
- Configures SSH with vulnerable settings (root login, weak password)
- Configures FTP with write access enabled
- Enables Telnet service (unencrypted)
- Configures Apache HTTP server
- Configures SNMP with public community string
- Verifies all services are running and listening
Usage:
# Make executable
chmod +x victim_services_setup.sh
# Run as root (required for service configuration)
sudo ./victim_services_setup.shServices Configured:
- SSH (port 22): Root login enabled, password: "root"
- FTP (port 21): Local users enabled, write enabled
- Telnet (port 23): Unencrypted remote access
- HTTP (port 80): Apache web server with test page
- SNMP (port 161): Public community string
Purpose: Configures iptables firewall with honeypot/transparent shield security model.
Location: Run on LinuxServer machine (10.10.0.10)
Features:
- Installs required packages (iptables, iptables-persistent, rsyslog, iproute2)
- Configures network interfaces and routing
- Sets up rsyslog remote forwarding to LogServer
- Creates honeypot chains for attack detection and logging
- Implements anti-spoofing rules
- Configures service-specific access rules
- Unified Hard Ban for SSH/FTP/Telnet using iptables
recent(ABUSE_COUNT/ABUSE_BANNED) - Configures SYN flood protection
- Enables comprehensive logging of all attacks
- Persists firewall rules across reboots
Usage:
# Make executable
chmod +x AutoTableV2.sh
# Run as root (required for firewall configuration)
sudo ./AutoTableV2.shSecurity Model:
- Honeypot Effect: Attacks are logged first, then blocked
- Rate Limiting: SSH connections limited to 3/minute from attacker IP
- Attack Detection: Logs SYN floods, brute force, port scans, spoofing
- Transparent Shield: Allows initial connections to establish before blocking
Log Prefixes:
HONEYPOT_ATTACK_INPUT:- Attack detected on INPUT chainHONEYPOT_ATTACK_FORWARD:- Attack detected on FORWARD chainSYN_FLOOD_DROP:- SYN flood attack detectedIPTABLES_INPUT_DROP:- General dropped packets on INPUTIPTABLES_FORWARD_DROP:- General dropped packets on FORWARD
Purpose: Presents firewall and system logs in a readable, organized format.
Location: Run on LinuxServer machine (10.10.0.10)
Features:
- Interactive menu-driven interface
- Parses honeypot attack logs
- Displays SYN flood detection logs
- Shows dropped packet summaries
- Displays SSH connection attempts
- Provides attack statistics
- Real-time log monitoring
- Color-coded output for easy reading
Usage:
# Make executable
chmod +x log_viewer.sh
# Interactive mode (menu-driven)
sudo ./log_viewer.sh
# Command-line mode
sudo ./log_viewer.sh honeypot # View honeypot attacks
sudo ./log_viewer.sh synflood # View SYN flood attacks
sudo ./log_viewer.sh dropped # View dropped packets
sudo ./log_viewer.sh ssh # View SSH attempts
sudo ./log_viewer.sh stats # Show statistics
sudo ./log_viewer.sh all # View all logsMenu Options:
- View Honeypot Attack Logs
- View SYN Flood Logs
- View Dropped Packets
- View SSH Connection Attempts
- Show Attack Statistics
- Real-time Log Monitoring
- View All Logs
- Exit
- Create Virtual Machines (as described in VMware section)
- Configure Network Adapters in VMware
- Install Operating Systems on all VMs
- Configure Basic Networking (IP addresses, routes)
-
Run Pre-Flight Check:
cd /path/to/scripts chmod +x attacker_test.sh sudo ./attacker_test.sh -
Install Missing Tools (if any):
sudo apt-get update sudo apt-get install -y nmap hping3 hydra snmpwalk nikto tcpdump
-
Verify Connectivity:
ping 192.168.100.1 # Router ping 10.10.0.10 # Target (may be blocked by firewall)
-
Setup Vulnerable Services:
cd /path/to/scripts chmod +x victim_services_setup.sh sudo ./victim_services_setup.sh -
Verify Services Are Running:
sudo netstat -tuln | grep -E ':(21|22|23|80|161) '
-
Test Services (from attacker):
# From Kali machine nmap -sS 10.10.0.10 # Port scan
-
Configure Firewall:
cd /path/to/scripts chmod +x AutoTableV2.sh sudo ./AutoTableV2.sh -
Verify Firewall Rules:
sudo iptables -L -v -n # List rules sudo iptables -L -v -n -t filter | grep HONEYPOT # Check honeypot chains
-
Monitor Logs:
sudo ./log_viewer.sh
-
Reconnaissance (from attacker):
# Port scan nmap -sS 10.10.0.10 # Service enumeration nmap -sV -sC 10.10.0.10
-
Brute Force Attack (from attacker):
# SSH brute force hydra -l root -P /usr/share/wordlists/rockyou.txt 10.10.0.10 ssh -
DoS Attack (from attacker):
# SYN flood hping3 -S --flood -p 80 10.10.0.10 -
Monitor Firewall Response (on victim):
sudo ./log_viewer.sh # Select option 6 for real-time monitoring
Solution:
- Verify network configuration on both machines
- Check if firewall is blocking ICMP (expected behavior)
- Verify routing table:
ip route show
Solution:
- Check service status:
sudo systemctl status <service> - Review service logs:
sudo journalctl -u <service> - Verify ports are not in use:
sudo netstat -tuln
Solution:
- Verify netfilter-persistent is enabled:
sudo systemctl status netfilter-persistent - Manually save rules:
sudo netfilter-persistent save - Check rules file:
sudo cat /etc/iptables/rules.v4
Solution:
- Verify rsyslog is running:
sudo systemctl status rsyslog - Check kernel log:
sudo tail -f /var/log/kern.log - Verify iptables logging is enabled in firewall script
-
Vulnerable Configurations: This lab uses intentionally vulnerable service configurations for educational purposes only. DO NOT deploy these settings in production environments.
-
Weak Passwords: Services are configured with weak passwords (e.g., root:root). Change all passwords in production.
-
Open Services: Multiple services are exposed without proper hardening. In production, follow security best practices.
-
Network Isolation: This lab should be run in an isolated network environment. Do not connect to production networks.
-
Legal Compliance: Only use these scripts in authorized testing environments. Unauthorized access to computer systems is illegal.
- iptables Documentation: https://www.netfilter.org/documentation/
- Kali Linux Tools: https://www.kali.org/tools/
- rsyslog Documentation: https://www.rsyslog.com/doc/
- VMware Networking: https://docs.vmware.com/en/VMware-Workstation-Pro/