Skip to content

Network_security

Chapter 33: Network Security & DDoS Protection

Section titled “Chapter 33: Network Security & DDoS Protection”

Network security is critical for blockchain nodes to prevent unauthorized access, DDoS attacks, and other malicious activities. This chapter covers comprehensive network protection strategies.


┌─────────────────────────────────────────────────────────────────────────────┐
│ BLOCKCHAIN NODE SECURITY ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ Internet │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ FIREWALL / LOAD BALANCER │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ - DDoS Protection (Cloudflare, AWS Shield) │ │ │
│ │ │ - Rate Limiting │ │ │
│ │ │ - IP Whitelisting │ │ │
│ │ │ - WAF (Web Application Firewall) │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ BASTION HOST / VPN │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ - SSH Key Authentication Only │ │ │
│ │ │ - 2FA/MFA │ │ │
│ │ │ - Jump Server │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ PRIVATE NETWORK (VPC) │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Validator │ │ RPC Node │ │ Archive │ │ │
│ │ │ Node │ │ Node │ │ Node │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘

Terminal window
# Install UFW
sudo apt install ufw
# Default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
# Allow SSH (with rate limiting)
sudo ufw limit 22/tcp comment 'SSH with rate limiting'
# Allow P2P networking (Ethereum)
sudo ufw allow 30303/tcp comment 'Ethereum P2P'
sudo ufw allow 30303/udp comment 'Ethereum Discovery'
# Allow RPC from specific IP only
sudo ufw allow from 10.0.0.0/8 to any port 8545 proto tcp comment 'RPC from internal'
# Allow Prometheus metrics (optional)
sudo ufw allow 9090/tcp comment 'Prometheus'
# Enable firewall
sudo ufw enable
# Check status
sudo ufw status verbose
Terminal window
# Flush existing rules
sudo iptables -F
sudo iptables -X
# Default policies
sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPT
# Allow loopback
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A OUTPUT -o lo -j ACCEPT
# Allow established connections
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Allow SSH (with rate limiting)
sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -m recent --set
sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 4 -j DROP
# Allow P2P
sudo iptables -A INPUT -p tcp --dport 30303 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 30303 -j ACCEPT
# Allow RPC only from specific IPs
sudo iptables -A INPUT -p tcp --dport 8545 -s 10.0.0.0/8 -j ACCEPT

┌─────────────────────────────────────────────────────────────────┐
│ DDoS ATTACK TYPES │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ VOLUMETRIC ATTACKS │ │
│ │ - UDP/ICMP flood │ │
│ │ - Goal: Exhaust bandwidth │ │
│ │ - Mitigation: CDN, DDoS protection service │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ PROTOCOL ATTACKS │ │
│ │ - SYN flood │ │
│ │ - Ping of death │ │
│ │ - Goal: Exhaust server resources │ │
│ │ - Mitigation: SYN cookies, connection limits │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ APPLICATION LAYER ATTACKS │ │
│ │ - HTTP flood │ │
│ │ - Slowloris │ │
│ │ - Goal: Crash web servers │ │
│ │ - Mitigation: Rate limiting, WAF │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Terminal window
# Example: Enable Cloudflare for your node
# 1. Point your domain NS to Cloudflare
# 2. Configure firewall rules in Cloudflare dashboard
# Cloudflare Page Rule example:
# Pattern: rpc.yourdomain.com/*
# Settings:
# - SSL: Full
# - Firewall: High
# - Cache Level: Cache Everything
# - Edge Cache TTL: 1 hour
┌─────────────────────────────────────────────────────────────────┐
│ AWS DDoS PROTECTION │
├─────────────────────────────────────────────────────────────────┤
│ │
│ AWS Shield Standard (Free) │
│ ━━━━━━━━━━━━━━━━━━━━━━━━ │
│ - Always-on protection │
│ - Mitigates common DDoS attacks │
│ │
│ AWS Shield Advanced ($3,000/month) │
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
│ - 24/7 access to AWS DDoS response team │
│ - Protection against sophisticated attacks │
│ - DDoS cost protection │
│ - Application layer DDoS protection │
│ │
│ Route 53 + CloudFront │
│ ━━━━━━━━━━━━━━━━━━━━━━━ │
│ - DNS-level protection │
│ - Edge caching reduces attack surface │
│ │
└─────────────────────────────────────────────────────────────────┘

Terminal window
# Install WireGuard
sudo apt install wireguard
# Generate keys
wg genkey | tee privatekey | wg pubkey > publickey
# Server configuration (/etc/wireguard/wg0.conf)
[Interface]
PrivateKey = <SERVER_PRIVATE_KEY>
Address = 10.0.0.1/24
ListenPort = 51820
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT
PostUp = iptables -A FORWARD -o wg0 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
[Peer]
PublicKey = <CLIENT_PUBLIC_KEY>
AllowedIPs = 10.0.0.2/32
# Client configuration
[Interface]
PrivateKey = <CLIENT_PRIVATE_KEY>
Address = 10.0.0.2/24
[Peer]
PublicKey = <SERVER_PUBLIC_KEY>
Endpoint = your-server-ip:51820
AllowedIPs = 10.0.0.0/24
PersistentKeepalive = 25
┌─────────────────────────────────────────────────────────────────┐
│ VPC SECURITY CONFIG │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ VPC CIDR: 10.0.0.0/16 │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Subnets: │
│ ┌────────────────────┐ ┌────────────────────┐ │
│ │ Public Subnet │ │ Private Subnet │ │
│ │ 10.0.1.0/24 │ │ 10.0.2.0/24 │ │
│ │ - Load Balancer │ │ - Validator Node │ │
│ │ - Bastion Host │ │ - RPC Node │ │
│ └────────────────────┘ └────────────────────┘ │
│ │
│ Security Groups: │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Validator SG: │ │
│ │ - Inbound: Allow 30303 from VPC │ │
│ │ - Outbound: Allow all │ │
│ ├─────────────────────────────────────────────────────────┤ │
│ │ RPC Node SG: │ │
│ │ - Inbound: Allow 8545 from ALB │ │
│ │ - Outbound: Allow 30303 to VPC │ │
│ ├─────────────────────────────────────────────────────────┤ │
│ │ Bastion SG: │ │
│ │ - Inbound: Allow 22 from VPN/Home IP │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘

PortProtocolServiceAccess Level
22TCPSSHBastion/Jump host only
30303TCP/UDPP2PPublic
8545TCPHTTP RPCInternal only
8546TCPWS RPCInternal only
9090TCPPrometheusInternal only
26656TCPTendermint P2PPublic
Terminal window
# Install fail2ban
sudo apt install fail2ban
# Configure fail2ban for SSH
sudo cat > /etc/fail2ban/jail.local << EOF
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 3600
findtime = 600
EOF
# Enable and start
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Terminal window
# Install OSSEC
wget -q https://github.com/ossec/ossec-hids/archive/3.6.0.tar.gz
tar -xzf 3.6.0.tar.gz
cd ossec-hids-3.6.0
./install.sh
# Configure active response
sudo cat >> /var/ossec/etc/ossec.conf << EOF
<active-response>
<command>host-deny</command>
<location>local</location>
<rules_id>100100</rules_id>
</active-response>
EOF
┌─────────────────────────────────────────────────────────────────┐
│ SECURITY MONITORING STACK │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ WAZUH DASHBOARD │ │
│ │ - Security alerts visualization │ │
│ │ - Compliance reporting │ │
│ │ - Threat intelligence │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ┌───────────────┼───────────────┐ │
│ ▼ ▼ ▼ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌────────────────┐│
│ │ WAZUH MANAGER │ │ WAZUH AGENT │ │ WAZUH AGENT ││
│ │ (Central) │ │ (Validator) │ │ (RPC Node) ││
│ └─────────────────┘ └─────────────────┘ └────────────────┘│
│ │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ NETWORK SEGMENTATION │
├─────────────────────────────────────────────────────────────────┤
│ │
│ DMZ (Public Facing) │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ - Load Balancer │ │
│ │ - WAF │ │
│ │ - Reverse Proxy (Nginx) │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Application Layer (Semi-Private) │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ - RPC Nodes (read-only) │ │
│ │ - Monitoring Services │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Core Layer (Private) │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ - Validator Nodes │ │
│ │ - Archive Nodes │ │
│ │ - Database Servers │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘

QuestionAnswer
How do you protect against DDoS?CDN, rate limiting, DDoS protection service, firewall rules
What is network segmentation?Dividing network into isolated segments for better security
Why use VPN for node access?Encrypts traffic, hides node IP, prevents direct attacks
What is a bastion host?Hardened server for secure admin access to private network
How do you secure P2P ports?Allow public access for P2P, restrict RPC to internal IPs

  • Implement firewall rules to restrict access
  • Use DDoS protection services (Cloudflare, AWS Shield)
  • Set up VPN or bastion host for admin access
  • Use network segmentation for defense in depth
  • Deploy intrusion detection systems
  • Monitor network traffic for anomalies

In Chapter 34: TLS/SSL Security, we’ll explore encryption for node communications.


Last Updated: 2026-02-20