Network Defense
Network Security Fundamentals
Network defense is a critical strategy for protecting computer networks from unauthorized access, misuse, and cyber threats.
Firewall Configuration
UFW (Uncomplicated Firewall) Setup
## Install UFW
sudo apt-get install ufw
## Default security policy
sudo ufw default deny incoming
sudo ufw default allow outgoing
## Allow specific services
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
## Enable firewall
sudo ufw enable
Firewall Rule Management
graph TD
A[Incoming Traffic] --> B{Firewall Rules}
B --> |Allowed| C[Permitted Services]
B --> |Blocked| D[Dropped Packets]
Intrusion Detection
Tool |
Function |
Key Features |
Fail2Ban |
IP Blocking |
Prevents brute-force attacks |
Snort |
Packet Inspection |
Real-time traffic analysis |
Netstat |
Connection Tracking |
Network connection monitoring |
Advanced Network Protection
IP Tables Configuration
## Block specific IP ranges
sudo iptables -A INPUT -s 192.168.1.0/24 -j DROP
## Limit connection rate
sudo iptables -A INPUT -p tcp --syn -m limit --limit 1/s -j ACCEPT
Secure Network Protocols
SSL/TLS Configuration
## Generate strong SSL configuration
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
## Disable weak protocols
sudo sed -i 's/^#Protocol.*/Protocol 2/' /etc/ssh/sshd_config
Network Segmentation
graph TD
A[Main Network] --> B[DMZ]
A --> C[Internal Network]
B --> D[Public Servers]
C --> E[Sensitive Resources]
Intrusion Prevention
Fail2Ban Configuration
## Install Fail2Ban
sudo apt-get install fail2ban
## Configure SSH protection
sudo bash -c 'cat << EOF >> /etc/fail2ban/jail.local
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 3600
EOF'
## Restart Fail2Ban
sudo systemctl restart fail2ban
LabEx Network Security Best Practices
- Implement multi-layer network security
- Use VPN for remote access
- Regularly update network security rules
- Monitor network traffic patterns
Advanced Defensive Techniques
Port Scanning Prevention
## Block port scanning attempts
sudo iptables -N SCANNER
sudo iptables -A SCANNER -p tcp --tcp-flags SYN,ACK SYN,ACK -m state --state NEW -j REJECT
sudo iptables -A INPUT -p tcp -j SCANNER
Conclusion
Effective network defense requires a comprehensive approach combining multiple security layers, continuous monitoring, and adaptive strategies.