Master comprehensive network security concepts, tools, and best practices
Network security encompasses policies, practices, and technologies designed to protect network infrastructure, data in transit, and connected systems from unauthorized access, misuse, malfunction, modification, destruction, or improper disclosure.
Viruses, worms, trojans, ransomware, and spyware that infiltrate systems to steal data or cause damage.
Distributed Denial of Service attacks overwhelm systems with traffic to make them unavailable.
Attackers intercept communications between two parties to eavesdrop or manipulate data.
Social engineering attacks to trick users into revealing credentials or sensitive information.
Exploiting vulnerabilities in database queries to access or manipulate data.
Attacks targeting unknown vulnerabilities before patches are available.
External Attack Vectors:
├── Internet-facing services (Web, Email, DNS)
├── Remote access (VPN, RDP, SSH)
├── Cloud services and APIs
├── Supply chain (third-party vendors)
└── Social engineering
Internal Attack Vectors:
├── Insider threats (malicious employees)
├── Lateral movement (compromised accounts)
├── Unpatched systems
├── Misconfigured services
└── Weak access controls
Divide your network into isolated segments to limit the blast radius of security incidents.
Enterprise Network Architecture:
Internet
│
├──[Firewall]──→ DMZ (Demilitarized Zone)
│ ├── Web Servers
│ ├── Mail Servers
│ └── Public DNS
│
├──[Firewall]──→ Corporate Network
│ ├── User Workstations (VLAN 10)
│ ├── Printers (VLAN 20)
│ └── Servers (VLAN 30)
│
├──[Firewall]──→ Secure Zone
│ ├── Database Servers
│ ├── Financial Systems
│ └── HR Systems
│
└──[Firewall]──→ Management Network
├── Network Devices
├── Security Appliances
└── Backup Systems
Never trust, always verify. Assume breach and verify every access request.
Layer 1: Perimeter Security (Firewalls, IPS)
Layer 2: Network Security (Segmentation, Access Controls)
Layer 3: Endpoint Security (Antivirus, EDR)
Layer 4: Application Security (WAF, Input Validation)
Layer 5: Data Security (Encryption, DLP)
Layer 6: Identity & Access Management (MFA, IAM)
Layer 7: Monitoring & Response (SIEM, SOC)
Inspect packets based on source/destination IP, ports, and protocols.
# iptables example
# Allow HTTP traffic
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Allow HTTPS traffic
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Allow SSH from specific IP
iptables -A INPUT -p tcp -s 192.168.1.100 --dport 22 -j ACCEPT
# Drop all other incoming traffic
iptables -A INPUT -j DROP
Track connection states and make decisions based on connection context.
Include deep packet inspection, application awareness, and integrated IPS.
The DMZ (Demilitarized Zone) is a network segment that sits between the external network and internal network.
DMZ Best Practices:
1. Place public-facing services in DMZ
- Web servers
- Email gateways
- DNS servers
- VPN endpoints
2. Implement dual firewalls
- External firewall: Internet → DMZ
- Internal firewall: DMZ → Internal Network
3. DMZ Rules:
- Allow: Internet → DMZ (ports 80, 443)
- Allow: DMZ → Internet (for updates)
- Deny: DMZ → Internal Network (except specific services)
- Allow: Internal Network → DMZ (for management)
| Feature | IDS (Detection) | IPS (Prevention) |
|---|---|---|
| Mode | Passive monitoring | Inline, active blocking |
| Action | Alert only | Alert and block |
| Impact | No traffic impact | Can affect traffic flow |
| Response | Manual intervention needed | Automatic response |
Match traffic patterns against known attack signatures.
# Snort rule example
alert tcp any any -> $HOME_NET 80 (
msg:"SQL Injection Attempt";
content:"UNION SELECT";
nocase;
sid:1000001;
rev:1;
)
Identify deviations from normal behavior patterns using machine learning.
Use rules and algorithms to identify suspicious behavior.
Connect entire networks securely over the internet.
Office A Network Internet Office B Network
(10.0.1.0/24) (10.0.2.0/24)
│ │
├─[VPN Gateway]──── IPSec Tunnel ────[VPN Gateway]
│ │
Users/Servers Users/Servers
Allow individual users to securely connect to corporate network.
Browser-based VPN access without client software.
| Protocol | Security | Speed | Use Case |
|---|---|---|---|
| IPSec | Very High | Fast | Site-to-site VPN |
| OpenVPN | Very High | Medium | Remote access, flexible |
| WireGuard | Very High | Very Fast | Modern, lightweight |
| SSL/TLS | High | Medium | Web-based access |
| PPTP | Low (deprecated) | Fast | Not recommended |
# Server configuration
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
keepalive 10 120
cipher AES-256-CBC
auth SHA256
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
Encrypts data in transit for web traffic, email, and more.
# Generate SSL certificate with Let's Encrypt
certbot certonly --standalone -d example.com -d www.example.com
# Configure Nginx with TLS 1.3
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
# HSTS header
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
Network-layer encryption for site-to-site VPNs.
Ensures that session keys cannot be compromised even if private key is compromised.
# Enable PFS in Nginx
ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256';
ssl_prefer_server_ciphers on;
Combine multiple authentication factors:
Authenticate once to access multiple systems.
Use digital certificates instead of passwords.
Roles:
├── Admin (Full access)
├── Developer (Code repositories, Dev servers)
├── Analyst (Read-only access to databases)
└── Guest (Limited public resources)
User Assignment:
- john@example.com → Developer, Analyst
- sarah@example.com → Admin
Access decisions based on attributes (user, resource, environment).
Enforce security policies for devices connecting to network.
Device ←→ Switch ←→ RADIUS Server ←→ Authentication Database
│ │ │ │
│ │ │ │
1. EAP Request │ │
├────────→ │ │
2. EAP Response │ │
←────────┤ │ │
3. Forward to RADIUS │ │
│ ├───────────→ │
4. Verify credentials │ │
│ │ ├────────────────────→
5. Access Granted/Denied │ │
←─────────────────────┤ │
| Protocol | Encryption | Security Level | Status |
|---|---|---|---|
| WEP | RC4 | Very Low | ❌ Deprecated |
| WPA | TKIP | Low | ❌ Deprecated |
| WPA2 | AES-CCMP | High | ✅ Acceptable |
| WPA3 | AES-GCMP | Very High | ✅ Recommended |
WPA2/WPA3-Enterprise Configuration:
1. RADIUS Server Setup
- Install FreeRADIUS or commercial solution
- Configure user database (LDAP, AD)
- Generate server certificates
2. Access Point Configuration
- Enable WPA2/WPA3-Enterprise
- Set authentication server IP
- Configure RADIUS shared secret
3. Client Configuration
- Install CA certificate
- Configure EAP method (PEAP, EAP-TLS)
- Enter credentials
Centralized logging, correlation, and analysis platform.
# Logstash configuration for firewall logs
input {
file {
path => "/var/log/firewall.log"
start_position => "beginning"
}
}
filter {
grok {
match => { "message" => "%{SYSLOGBASE} %{GREEDYDATA:firewall_message}" }
}
if "DENY" in [firewall_message] {
mutate {
add_tag => ["blocked"]
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "firewall-%{+YYYY.MM.dd}"
}
}
1. Preparation
└── Develop IR plan, tools, team training
2. Detection & Analysis
└── Identify security events, determine severity
3. Containment
├── Short-term: Isolate affected systems
└── Long-term: Apply temporary fixes
4. Eradication
└── Remove threat, patch vulnerabilities
5. Recovery
└── Restore systems, monitor for re-infection
6. Post-Incident Review
└── Document lessons learned, update procedures
# Emergency network isolation
# 1. Isolate compromised host at switch level
interface GigabitEthernet0/1
shutdown
description "QUARANTINED - Security Incident"
# 2. Block IP at firewall
iptables -I INPUT -s 192.168.1.50 -j DROP
iptables -I FORWARD -s 192.168.1.50 -j DROP
# 3. Disable user account
net user compromised_user /active:no
# 4. Update IPS signatures for identified threat
International standard for information security management systems (ISMS).
20 prioritized security controls for cyber defense.
Security considerations for SDN architectures.
# Docker network isolation
docker network create --driver bridge isolated_network
# Kubernetes NetworkPolicy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress