← Kỹ sư mạng← Network Engineer
Kỹ sư mạngNetwork Engineer19 Th7, 2026Jul 19, 202622 phút đọc19 min read

An ninh mạngNetwork Security

Thuộc bộ kiến thức Network Engineer Roadmap.

Tổng quan

Network security (an ninh mạng) là tập hợp các policy, control, kiến trúc và công nghệ nhằm bảo vệ tính bí mật (confidentiality), tính toàn vẹn (integrity) và tính sẵn sàng (availability) của dữ liệu khi nó di chuyển trên mạng và khi lưu trữ. Với một network engineer, bảo mật không phải là một tính năng gắn thêm về sau — nó là một thuộc tính thiết kế mà bạn đưa vào ngay từ addressing plan, routing, switching, segmentation và cấu hình của từng thiết bị.

Note này được viết theo góc nhìn phòng thủ (defensive). Mục tiêu là hiểu các cuộc tấn công đủ sâu để phát hiện (detect)ngăn chặn (prevent) chúng, cũng như thiết kế mạng “fail safe” — chứ không phải để thực hiện tấn công. Ở mọi chỗ mô tả một cuộc tấn công, trọng tâm luôn là detection và mitigation.

Note này bao gồm:

Bảo mật phụ thuộc rất nhiều vào một addressing/subnetting plan chính xác (./05-ip-addressing-and-subnetting.md), vì segmentation, ACL và firewall rule đều được biểu diễn theo subnet. Nếu muốn hệ thống hóa kiến thức này, CompTIA Security+ là certification đầu vào tự nhiên — xem ./18-certifications-and-learning-path.md.

Kiến thức nền tảng

CIA triad

Mọi security control cuối cùng đều phục vụ một hoặc nhiều trong ba mục tiêu:

Thuộc tínhTrả lời câu hỏiVí dụ trên mạng
Confidentiality (bí mật)Chỉ bên được phép mới đọc được dữ liệu?Encryption (TLS, IPsec, MACsec), ACL, VLAN segmentation, access control
Integrity (toàn vẹn)Dữ liệu có bị thay đổi khi truyền/lưu trữ không?HMAC/chữ ký số, TLS integrity, IPsec AH/ESP, checksum, anti-spoofing filter
Availability (sẵn sàng)Dịch vụ có truy cập được khi cần không?DDoS mitigation, redundancy, rate limiting, QoS, load balancing

Một mở rộng phổ biến bổ sung Authentication, Authorization, Accounting (AAA) và non-repudiation. Mọi quyết định thiết kế đều có thể truy về một trong các thuộc tính này — nếu một control không phục vụ thuộc tính nào, hãy đặt câu hỏi vì sao nó tồn tại.

Defense-in-depth

Defense-in-depth nghĩa là xếp lớp nhiều control độc lập, sao cho việc một lớp bị lỗi hoặc bị vượt qua không làm sụp đổ toàn hệ thống. Kẻ tấn công vượt qua được perimeter firewall vẫn còn phải đối mặt với segmentation, host firewall, IDS/IPS, authentication và encryption.

Phòng thủ nhiều lớp, từ Internet vào trong
  1. Lớp 1
    Perimeter firewall / edge router ACLEdge / NGFW hướng ra Internet — + DDoS protection, anti-spoofing (BCP38)
  2. Lớp 2
    DMZ cho dịch vụ publicweb, mail, reverse proxy
  3. Lớp 3
    Internal segmentation firewall / VLAN ACLbảo vệ internal core
  4. Lớp 4
    Control theo segment, NAC, 802.1Xsegment Users và Servers
  5. Lớp 5
    Host firewall, EDR, IDS/IPS
  6. Lớp 6
    Encryption, IAM, MFA, logging

Không lớp nào được tin là hoàn hảo. Đây là điều ngược lại với mô hình cũ “vỏ cứng, ruột mềm” (hard shell, soft center), nơi một perimeter mạnh bảo vệ một mạng nội bộ phẳng và được tin tưởng hoàn toàn.

Least privilege

Least privilege (đặc quyền tối thiểu) chỉ cấp cho mỗi user, device và service đúng mức truy cập cần thiết để làm việc — không hơn. Trên mạng, điều này được dịch thành:

Network segmentation

Segmentation chia mạng thành các zone cô lập, để một sự cố ở zone này không thể lan tự do (“lateral movement”) sang zone khác. Các kỹ thuật:

Các zone điển hình: user VLAN, server VLAN, voice VLAN, guest/BYOD, IoT/OT, management và DMZ. Traffic giữa các zone phải đi qua một điểm thực thi chính sách (firewall hoặc thiết bị L3 có ACL).

DMZ (Demilitarized Zone)

DMZ là một segment bán tin cậy nằm giữa Internet không tin cậy và mạng nội bộ được tin cậy. Nó chứa các dịch vụ cần truy cập được từ bên ngoài — web server, reverse proxy, mail gateway, DNS. Nếu một host trong DMZ bị chiếm, kẻ tấn công vẫn bị ngăn cách với mạng nội bộ bởi lớp firewall thứ hai.

Internet ── Firewall A ── DMZ (web, mail, DNS) ── Firewall B ── Internal LAN

Nguyên tắc:

Khái niệm chính

Firewall

Firewall thực thi một security policy lên traffic đi qua một ranh giới, cho phép hoặc từ chối các luồng dựa trên rule. Firewall đã tiến hóa qua nhiều thế hệ, từ packet filter đơn giản đến NGFW nhận biết ngữ cảnh.

Packet-filtering (stateless) firewall

Hoạt động ở Layer 3/4. Nó kiểm tra từng packet một cách độc lập dựa trên rule tĩnh (source/destination IP, protocol, port, flag). Nó không giữ state, nên không biết một packet có thuộc một connection đã thiết lập hay không — bạn phải viết rule tường minh cho cả hai chiều. Nhanh và rẻ, nhưng thô.

Stateful inspection firewall

Duy trì một state table của các connection đang hoạt động. Khi một host nội bộ khởi tạo connection, firewall ghi lại và tự động cho phép traffic trả về tương ứng, đồng thời drop các packet inbound không mời mà không khớp session nào. Đây là baseline cho gần như mọi firewall hiện đại.

Circuit-level gateway

Hoạt động ở session layer (L5). Nó kiểm tra TCP handshake và giám sát tính hợp lệ của session, rồi chuyển tiếp traffic mà không kiểm tra payload. SOCKS proxy là ví dụ kinh điển. Nhẹ nhưng không có khả năng nhìn vào nội dung ứng dụng.

Application-layer / proxy firewall

Hoạt động ở Layer 7 và kết thúc (terminate) connection thay cho client, đóng vai trò trung gian. Nó hiểu các protocol cụ thể (HTTP, FTP, DNS, SMTP), có thể inspect và filter nội dung, ẩn cấu trúc nội bộ và ép đúng protocol. Latency cao hơn và tốn tài nguyên hơn.

Next-Generation Firewall (NGFW)

Kết hợp stateful inspection với:

Bảng so sánh các loại firewall

LoạiOSI layerStateful?Inspect payload?App awarenessĐiểm mạnhĐiểm yếu
Packet-filtering (stateless)L3–L4KhôngKhôngKhôngNhanh, đơn giản, rẻThô, không có session context, dễ misconfig
Stateful inspectionL3–L4KhôngKhôngTheo dõi session, chặn inbound không mờiKhông thấy L7
Circuit-level gatewayL5Có (session)KhôngKhôngKiểm tra session nhẹKhông inspect nội dung
Application-layer / proxyL7Theo protocolFilter nội dung sâu, ẩn nội bộLatency, theo từng protocol, nặng tài nguyên
Next-Generation (NGFW)L3–L7Có (DPI)Nhận biết app/user/threat-intel, IPS tích hợpChi phí, phức tạp, TLS-inspection gây lo ngại privacy

Access Control List (ACL)

ACL là một danh sách có thứ tự các rule permit/deny áp lên interface của router/switch hoặc zone của firewall. Trên Cisco IOS có hai loại chính:

Các quy tắc quan trọng về hành vi ACL:

  1. Direction quan trọng — ACL được áp in hoặc out trên interface, tính theo góc nhìn của router. Luôn suy luận từ góc nhìn của router.
  2. Thứ tự quan trọng — rule được duyệt từ trên xuống; rule khớp đầu tiên thắng và dừng xử lý. Đặt rule cụ thể trước rule tổng quát.
  3. Implicit deny — mọi ACL kết thúc bằng một deny any vô hình. Nếu không khớp gì, packet bị drop. Luôn có một permit tường minh cho traffic bạn muốn.

Ví dụ ACL trên Cisco

Standard named ACL — chỉ cho phép management subnet truy cập VTY (SSH) của router:

ip access-list standard MGMT-ONLY
 permit 10.10.99.0 0.0.0.255
 deny   any log
!
line vty 0 4
 access-class MGMT-ONLY in
 transport input ssh

Extended named ACL — policy inbound ở Internet edge trên outside interface:

ip access-list extended INTERNET-IN
 ! Cho phép traffic trả về của connection đã thiết lập
 permit tcp any any established
 ! Chỉ publish web server DMZ trên 443
 permit tcp any host 203.0.113.10 eq 443
 ! Cho phép DNS inbound tới resolver DMZ
 permit udp any host 203.0.113.11 eq 53
 ! Anti-spoofing: drop packet giả mạo source là dải nội bộ của ta (BCP38)
 deny   ip 10.0.0.0 0.255.255.255 any log
 deny   ip 172.16.0.0 0.15.255.255 any log
 deny   ip 192.168.0.0 0.0.255.255 any log
 ! Deny tường minh có log (ghi lại implicit deny)
 deny   ip any any log
!
interface GigabitEthernet0/0
 description ** Internet uplink **
 ip access-group INTERNET-IN in

Lưu ý wildcard mask (nghịch đảo của subnet mask): 0.0.0.255 khớp một /24. Xem ./05-ip-addressing-and-subnetting.md để nắm phần tính toán.

Kỷ luật default-deny cũng áp dụng cho host Linux. Ví dụ inbound với nftables (hiện đại):

table inet filter {
  chain input {
    type filter hook input priority 0; policy drop;   # default-deny
    ct state established,related accept                # traffic trả về (stateful)
    iif "lo" accept                                    # loopback
    tcp dport 22 ip saddr 10.10.99.0/24 accept         # SSH chỉ từ mgmt subnet
    tcp dport 443 accept                               # HTTPS public
    ct state invalid drop
    ip protocol icmp icmp type echo-request limit rate 5/second accept
  }
}

Tương đương với iptables:

iptables -P INPUT DROP                                          # default-deny
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -s 10.10.99.0/24 --dport 22 -j ACCEPT  # SSH chỉ từ mgmt
iptables -A INPUT -p tcp --dport 443 -j ACCEPT                  # HTTPS
iptables -A INPUT -m conntrack --ctstate INVALID -j DROP

IDS vs IPS

Intrusion Detection System (IDS) giám sát traffic và cảnh báo (alert) khi thấy hoạt động khả nghi. Intrusion Prevention System (IPS) nằm inline và có thể chặn (block) traffic độc hại theo thời gian thực.

Phương pháp phát hiện:

Phạm vi triển khai:

Khía cạnhIDSIPS
Vị tríPassive / out-of-band (SPAN, TAP)Inline (nằm trên đường đi của traffic)
Hành độngPhát hiện & cảnh báoPhát hiện, cảnh báo & chặn/drop
Ảnh hưởng tới trafficKhông (không ảnh hưởng luồng)Thêm latency; lỗi có thể gián đoạn traffic
Rủi ro false positiveBỏ sót cảnh báoChặn nhầm traffic hợp lệ
Dùng điển hìnhForensics, visibility, monitoringBảo vệ chủ động ở perimeter/biên segment

Engine phát hiện: signature vs anomaly (như trên) — áp dụng cho cả IDS và IPS. Các engine mã nguồn mở phổ biến gồm Snort, Suricata (NIDS/NIPS) và Zeek (network security monitoring). NGFW hiện đại nhúng sẵn chức năng IPS.

Cloud security group & NACL

Trong môi trường cloud, mô hình firewall được chia thành hai lớp (thuật ngữ AWS; các provider khác tương tự):

ControlPhạm viStateful?Rule
Security Group (SG)Instance / ENI (như host firewall)Stateful — traffic trả về tự động được cho phépChỉ có allow rule; implicit deny
Network ACL (NACL)Ranh giới subnetStateless — phải allow tường minh cả hai chiềuCó cả allow deny rule, duyệt theo số thứ tự

Vì SG là stateful, bạn chỉ cần định nghĩa rule inbound (hoặc outbound) và phản hồi được cho phép tự động. NACL là stateless như packet filter cổ điển, nên bạn phải mở port trả về ephemeral một cách tường minh. Đây chỉ là tóm tắt — nội dung đầy đủ (SG, NACL, thiết kế VPC, cloud NAT, private endpoint) ở ./16-cloud-networking.md.

Zero-Trust Architecture (ZTA)

Zero Trust thay thế mô hình lấy perimeter làm trung tâm bằng nguyên tắc “never trust, always verify” (không bao giờ tin, luôn xác minh). Không user, device hay vị trí mạng nào được tin ngầm — mọi yêu cầu truy cập đều được authenticate, authorize và encrypt, bất kể nó xuất phát từ trong hay ngoài mạng công ty.

Các nguyên lý cốt lõi (NIST SP 800-207):

Các cơ chế chính:

So với mô hình cũ: một VPN truyền thống, khi đã kết nối, thường đặt user vào một mạng phẳng được tin cậy. ZTNA thay vào đó môi giới quyền truy cập tới từng ứng dụng và không bao giờ để lộ toàn mạng. Cơ chế VPN được trình bày ở ./12-vpn-and-tunneling.md.

Kiến thức cơ bản về encryption cho network engineer

Encryption bảo vệ confidentiality (và, kèm authentication, integrity) của dữ liệu khi truyền và khi lưu trữ.

Các protocol thực tế kết hợp cả hai: crypto asymmetric thực hiện authentication và key exchange, rồi một cipher symmetric nhanh bảo vệ dữ liệu thực.

ProtocolLayerBảo vệDùng điển hình
TLSL4–L7 (trên TCP/UDP)Session ứng dụngHTTPS, email bảo mật, API
IPsecL3Packet IPVPN site-to-site và remote-access
MACsec (802.1AE)L2Ethernet frame trên một linkMã hóa link switch-to-switch/host-to-switch trong LAN/DC

TLS và IPsec được trình bày chi tiết ở ./12-vpn-and-tunneling.md.

Các cuộc tấn công mạng phổ biến — và cách phòng thủ

Phần dưới đây mang tính phòng thủ: mỗi cuộc tấn công là gì và cách phát hiện, giảm thiểu. Cố tình không phải là hướng dẫn thực hiện tấn công.

DoS / DDoS (Denial of Service / Distributed DoS)

Là gì: các nỗ lực làm cạn kiệt tài nguyên của mục tiêu để người dùng hợp lệ không được phục vụ. DDoS dùng nhiều nguồn phân tán (thường là botnet). Ba nhóm lớn:

Phòng thủ / mitigation:

Spoofing

Là gì: giả mạo một identity nguồn — IP spoofing (giả source IP), MAC spoofing, DNS spoofing, hoặc email spoofing — để giả danh một thực thể tin cậy hoặc né filter.

Phòng thủ:

MITM (Man-in-the-Middle)

Là gì: kẻ tấn công lén chuyển tiếp/thay đổi traffic giữa hai bên đang tin rằng họ giao tiếp trực tiếp.

Phòng thủ:

ARP poisoning / ARP spoofing

Là gì: vì ARP cổ điển không có authentication, kẻ tấn công cùng segment L2 có thể gửi ARP reply giả để gán MAC của mình với IP của host khác (thường là gateway), tạo điều kiện cho MITM hoặc DoS.

Phòng thủ:

VLAN hopping

Là gì: đưa frame vào một VLAN mà kẻ tấn công không nên chạm tới, qua switch spoofing (thương lượng trunk) hoặc double-tagging (lồng hai tag 802.1Q).

Phòng thủ:

Ví dụ hardening access-port trên Cisco:

interface range GigabitEthernet0/1 - 24
 switchport mode access
 switchport access vlan 20
 switchport nonegotiate
 spanning-tree portfast
 spanning-tree bpduguard enable
 switchport port-security
 switchport port-security maximum 2
 switchport port-security violation restrict

Best Practices

Tài liệu tham khảo

Part of the Network Engineer Roadmap knowledge base.

Overview

Network security is the collection of policies, controls, architectures, and technologies that protect the confidentiality, integrity, and availability of data as it moves across and rests on a network. For a network engineer, security is not a bolt-on feature that a separate team adds later — it is a design property that you bake into addressing plans, routing, switching, segmentation, and every device configuration.

This note is written from a defensive point of view. The goal is to understand attacks well enough to detect and prevent them and to design networks that fail safely — not to perform them. Everywhere an attack is described, the emphasis is on detection and mitigation.

This note covers:

Security depends heavily on a correct addressing and subnetting plan (./05-ip-addressing-and-subnetting.md), because segmentation, ACLs, and firewall rules are all expressed in terms of subnets. If you want to formalize this knowledge, CompTIA Security+ is the natural entry-level certification — see ./18-certifications-and-learning-path.md.

Fundamentals

The CIA triad

Every security control ultimately serves one or more of three goals:

PropertyQuestion it answersNetwork examples
ConfidentialityCan only authorized parties read the data?Encryption (TLS, IPsec, MACsec), ACLs, VLAN segmentation, access control
IntegrityHas the data been altered in transit or at rest?HMAC/digital signatures, TLS integrity, IPsec AH/ESP, checksums, anti-spoofing filters
AvailabilityIs the service reachable when needed?DDoS mitigation, redundancy, rate limiting, QoS, load balancing

A common extension adds Authentication, Authorization, and Accounting (AAA), and non-repudiation. Every design decision can be traced back to one of these properties — if a control does not serve one, question why it exists.

Defense-in-depth

Defense-in-depth means layering independent controls so that the failure or bypass of any one layer does not compromise the whole system. An attacker who gets past the perimeter firewall still faces segmentation, host firewalls, IDS/IPS, authentication, and encryption.

Defence in depth, from the Internet inwards
  1. Layer 1
    Perimeter firewall / edge router ACLsEdge / NGFW facing the Internet — + DDoS protection, anti-spoofing (BCP38)
  2. Layer 2
    DMZ for public-facing servicesweb, mail, reverse proxy
  3. Layer 3
    Internal segmentation firewall / VLAN ACLsguards the internal core
  4. Layer 4
    Per-segment controls, NAC, 802.1XUsers and Servers segments
  5. Layer 5
    Host firewalls, EDR, IDS/IPS
  6. Layer 6
    Encryption, IAM, MFA, logging

No single layer is trusted to be perfect. This is the opposite of the old “hard shell, soft center” model where a strong perimeter protected a flat, fully trusted internal network.

Least privilege

Least privilege grants every user, device, and service only the access it needs to do its job — nothing more. On the network this translates to:

Network segmentation

Segmentation divides a network into isolated zones so that a compromise in one zone cannot freely spread (“lateral movement”) to others. Techniques:

Typical zones: user VLANs, server VLANs, voice VLAN, guest/BYOD, IoT/OT, management, and the DMZ. Traffic between zones must pass through a policy enforcement point (firewall or L3 device with ACLs).

The DMZ (Demilitarized Zone)

A DMZ is a semi-trusted network segment that sits between the untrusted Internet and the trusted internal network. It hosts services that must be reachable from the outside — web servers, reverse proxies, mail gateways, DNS. If a DMZ host is compromised, the attacker is still separated from the internal network by a second firewall layer.

Internet ── Firewall A ── DMZ (web, mail, DNS) ── Firewall B ── Internal LAN

Rules of thumb:

Key Concepts

Firewalls

A firewall enforces a security policy on traffic crossing a boundary, allowing or denying flows based on rules. Firewalls have evolved through several generations, from simple packet filters to context-aware NGFWs.

Packet-filtering (stateless) firewall

Operates at Layer 3/4. It examines each packet in isolation against static rules (source/destination IP, protocol, port, flags). It keeps no state, so it cannot tell whether a packet belongs to an established connection — you must write explicit rules for both directions. Fast and cheap, but coarse.

Stateful inspection firewall

Maintains a state table of active connections. When an internal host initiates a connection, the firewall records it and automatically permits the corresponding return traffic, dropping unsolicited inbound packets that do not match an existing session. This is the baseline for virtually all modern firewalls.

Circuit-level gateway

Operates at the session layer (L5). It validates the TCP handshake and monitors that sessions are legitimate, then relays traffic without inspecting payloads. SOCKS proxies are a classic example. Lightweight but no application-content visibility.

Application-layer / proxy firewall

Operates at Layer 7 and terminates connections on behalf of clients, acting as an intermediary. It understands specific protocols (HTTP, FTP, DNS, SMTP) and can inspect and filter content, hide internal structure, and enforce protocol correctness. Higher latency and more resource-intensive.

Next-Generation Firewall (NGFW)

Combines stateful inspection with:

Firewall types comparison

TypeOSI layerStateful?Inspects payload?App awarenessStrengthsWeaknesses
Packet-filtering (stateless)L3–L4NoNoNoFast, simple, cheapCoarse, no session context, easy to misconfigure
Stateful inspectionL3–L4YesNoNoTracks sessions, blocks unsolicited inboundNo L7 visibility
Circuit-level gatewayL5Yes (session)NoNoLightweight session validationNo content inspection
Application-layer / proxyL7YesYesProtocol-specificDeep content filtering, hides internalsLatency, per-protocol, resource-heavy
Next-Generation (NGFW)L3–L7YesYes (DPI)YesApp/user/threat-intel aware, integrated IPSCost, complexity, TLS-inspection privacy concerns

Access Control Lists (ACLs)

An ACL is an ordered list of permit/deny rules applied to router/switch interfaces or firewall zones. On Cisco IOS there are two main types:

Key rules of ACL behavior:

  1. Direction matters — an ACL is applied in or out on an interface, relative to the router. Always reason from the router’s perspective.
  2. Order matters — rules are evaluated top-down; the first match wins and processing stops. Put specific rules before general ones.
  3. Implicit deny — every ACL ends with an invisible deny any. If nothing matches, the packet is dropped. Always include an explicit permit for the traffic you want.

Cisco ACL examples

Standard named ACL — allow only the management subnet to reach the router VTY (SSH) lines:

ip access-list standard MGMT-ONLY
 permit 10.10.99.0 0.0.0.255
 deny   any log
!
line vty 0 4
 access-class MGMT-ONLY in
 transport input ssh

Extended named ACL — an inbound Internet edge policy on the outside interface:

ip access-list extended INTERNET-IN
 ! Allow established return traffic
 permit tcp any any established
 ! Publish the DMZ web server on 443 only
 permit tcp any host 203.0.113.10 eq 443
 ! Allow inbound DNS to the DMZ resolver
 permit udp any host 203.0.113.11 eq 53
 ! Anti-spoofing: drop packets claiming to be from our internal ranges (BCP38)
 deny   ip 10.0.0.0 0.255.255.255 any log
 deny   ip 172.16.0.0 0.15.255.255 any log
 deny   ip 192.168.0.0 0.0.255.255 any log
 ! Explicit deny with logging (documents the implicit deny)
 deny   ip any any log
!
interface GigabitEthernet0/0
 description ** Internet uplink **
 ip access-group INTERNET-IN in

Note the wildcard masks (inverse of subnet masks): 0.0.0.255 matches a /24. See ./05-ip-addressing-and-subnetting.md for the arithmetic.

The same default-deny discipline applies to Linux hosts. nftables (modern) inbound example:

table inet filter {
  chain input {
    type filter hook input priority 0; policy drop;   # default-deny
    ct state established,related accept                # stateful return traffic
    iif "lo" accept                                    # loopback
    tcp dport 22 ip saddr 10.10.99.0/24 accept         # SSH from mgmt subnet only
    tcp dport 443 accept                               # public HTTPS
    ct state invalid drop
    ip protocol icmp icmp type echo-request limit rate 5/second accept
  }
}

Equivalent iptables essentials:

iptables -P INPUT DROP                                          # default-deny
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -s 10.10.99.0/24 --dport 22 -j ACCEPT  # SSH from mgmt only
iptables -A INPUT -p tcp --dport 443 -j ACCEPT                  # HTTPS
iptables -A INPUT -m conntrack --ctstate INVALID -j DROP

IDS vs IPS

An Intrusion Detection System (IDS) monitors traffic and alerts on suspicious activity. An Intrusion Prevention System (IPS) sits inline and can block malicious traffic in real time.

Detection methods:

Deployment scope:

AspectIDSIPS
PositionPassive / out-of-band (SPAN, TAP)Inline (in the traffic path)
ActionDetect & alertDetect, alert, & block/drop
Impact on trafficNone (does not affect flow)Adds latency; a failure can disrupt traffic
Risk of false positiveMissed alertLegitimate traffic blocked
Typical useForensics, visibility, monitoringActive protection at the perimeter/segment edge

Detection engines: signature vs anomaly (as above) — apply to both IDS and IPS. Popular open-source engines include Snort, Suricata (NIDS/NIPS), and Zeek (network security monitoring). Modern NGFWs embed IPS functionality directly.

Cloud security groups & NACLs

In cloud environments the firewall model is split into two layers (AWS terminology; other providers are analogous):

ControlScopeStateful?Rules
Security Group (SG)Instance / ENI (like a host firewall)Stateful — return traffic auto-allowedAllow rules only; implicit deny
Network ACL (NACL)Subnet boundaryStateless — must allow both directions explicitlyAllow and deny rules, evaluated in numbered order

Because SGs are stateful, you only define the inbound (or outbound) rule and the response is permitted automatically. NACLs are stateless like classic packet filters, so you must open ephemeral return ports explicitly. This is only a summary — the full treatment (SGs, NACLs, VPC design, cloud NAT, private endpoints) is in ./16-cloud-networking.md.

Zero-Trust Architecture (ZTA)

Zero Trust replaces the perimeter-centric model with the principle “never trust, always verify.” No user, device, or network location is trusted implicitly — every access request is authenticated, authorized, and encrypted, regardless of whether it originates inside or outside the corporate network.

Core tenets (NIST SP 800-207):

Key mechanisms:

Contrast with the legacy model: a traditional VPN, once connected, often places the user on a flat trusted network. ZTNA instead brokers access to individual applications and never exposes the broader network. VPN mechanics are covered in ./12-vpn-and-tunneling.md.

Encryption basics for the network engineer

Encryption protects confidentiality (and, with authentication, integrity) of data in transit and at rest.

Real protocols combine both: asymmetric crypto performs authentication and a key exchange, then a fast symmetric cipher protects the actual data.

ProtocolLayerProtectsTypical use
TLSL4–L7 (over TCP/UDP)Application sessionsHTTPS, secure email, APIs
IPsecL3IP packetsSite-to-site and remote-access VPNs
MACsec (802.1AE)L2Ethernet frames on a linkSwitch-to-switch/host-to-switch link encryption in the LAN/DC

TLS and IPsec are covered in depth in ./12-vpn-and-tunneling.md.

Common network attacks — and how to defend

The following is defensive: what each attack is and how to detect and mitigate it. It is deliberately not a how-to for performing attacks.

DoS / DDoS (Denial of Service / Distributed DoS)

What it is: attempts to exhaust a target’s resources so legitimate users cannot be served. A DDoS uses many distributed sources (often a botnet). Three broad categories:

Defense / mitigation:

Spoofing

What it is: forging a source identity — IP spoofing (fake source IP), MAC spoofing, DNS spoofing, or email spoofing — to impersonate a trusted entity or evade filters.

Defense:

MITM (Man-in-the-Middle)

What it is: an attacker secretly relays/alters traffic between two parties who believe they communicate directly.

Defense:

ARP poisoning / ARP spoofing

What it is: because classic ARP has no authentication, an attacker on the same L2 segment can send forged ARP replies to associate their MAC with another host’s IP (often the gateway), enabling MITM or DoS.

Defense:

VLAN hopping

What it is: getting frames onto a VLAN the attacker should not reach, via switch spoofing (negotiating a trunk) or double-tagging (nesting two 802.1Q tags).

Defense:

Cisco access-port hardening example:

interface range GigabitEthernet0/1 - 24
 switchport mode access
 switchport access vlan 20
 switchport nonegotiate
 spanning-tree portfast
 spanning-tree bpduguard enable
 switchport port-security
 switchport port-security maximum 2
 switchport port-security violation restrict

Best Practices

References