Thiết bị mạngNetwork Devices
Thuộc bộ kiến thức Network Engineer Roadmap.
Tổng quan
Một hệ thống mạng chỉ tốt bằng những chiếc “hộp” chuyển packet giữa các host. Mỗi device trên mạng tồn tại để giải quyết một vấn đề cụ thể: kéo dài tín hiệu, cô lập traffic, forward frame, route giữa các mạng, chuyển đổi tín hiệu, bảo vệ vành đai (perimeter), hay phân phối tải. Hiểu được mỗi thiết bị giải quyết vấn đề gì — và nó hoạt động ở tầng (layer) nào của mô hình OSI — là mental model hữu ích nhất mà một network engineer có thể mang theo, vì nó cho phép bạn suy luận về hành vi (collision domain, broadcast domain, độ trễ, kiểu lỗi) mà không cần thuộc lòng datasheet của từng sản phẩm.
Ghi chú này đi qua phân loại thiết bị từ tầng physical đi lên. Bắt đầu với các thiết bị “ngốc” chỉ lặp lại tín hiệu (repeater, hub), chuyển sang các thiết bị chuyển frame ở Layer 2 (bridge, switch), rồi tới các thiết bị routing ở Layer 3 (router, multilayer switch), và cuối cùng là các “appliance” thông minh nằm ở rìa mạng trở lên (modem, gateway, access point, firewall, load balancer, proxy, IDS/IPS, storage). Chúng ta kết thúc bằng xu hướng hiện đại chuyển sang virtual/cloud appliance (NFV) và một mô hình ra quyết định thực tế để chọn đúng thiết bị.
Các chủ đề chuyên sâu được trình bày trong các file cùng cấp, có liên kết chéo xuyên suốt:
- Mô hình OSI / TCP-IP và các tầng: ./03-network-models-and-layers.md
- Switching (VLAN, STP, MAC learning): ./08-switching.md
- Routing (static, dynamic, protocols): ./07-routing.md
- Redundancy, HA, load balancing: ./09-redundancy-and-high-availability.md
- Network security, firewall, IDS/IPS: ./11-network-security.md
- Wireless networking: ./10-wireless-networking.md
Kiến thức nền tảng
Hai khái niệm cần nắm trước: collision domain và broadcast domain
Gần như mọi đặc tính của một thiết bị Layer 1/Layer 2 đều quy về việc nó tác động thế nào tới hai “domain” sau:
- Collision domain — tập hợp các thiết bị mà frame của chúng có thể va chạm (collide) trên một môi trường dùng chung (liên quan tới Ethernet half-duplex dùng CSMA/CD). Nếu hai station phát cùng lúc, cả hai frame đều hỏng và phải truyền lại. Collision domain càng lớn = càng nhiều va chạm = hiệu năng càng tệ.
- Broadcast domain — tập hợp các thiết bị đều nhận được một broadcast frame (destination MAC
FF:FF:FF:FF:FF:FF) hay traffic bị flood ở Layer 2 (ARP, DHCP discover, unknown-unicast flooding). Broadcast domain càng lớn = càng nhiều “nhiễu” broadcast và blast radius (phạm vi ảnh hưởng) về lỗi/bảo mật càng rộng.
Quy tắc nhanh cho các thiết bị kinh điển:
- Hub là một collision domain lớn và một broadcast domain lớn.
- Switch đặt mỗi port vào collision domain riêng (nên với full-duplex, va chạm gần như biến mất), nhưng mặc định mọi port vẫn nằm trong một broadcast domain (trừ khi chia bằng VLAN).
- Router kết thúc broadcast domain: mỗi interface của router là ranh giới giữa các broadcast domain. Router mặc định không forward broadcast.
Hãy nhớ kỹ: switch chia nhỏ collision domain; router chia nhỏ broadcast domain.
Thiết bị “hoạt động ở tầng” nào
Ta nói một thiết bị “hoạt động ở tầng” cao nhất mà nó đưa ra quyết định forwarding:
- Layer 1 (Physical): chỉ tái tạo/lặp lại tín hiệu điện hoặc quang. Không hiểu khái niệm frame hay address.
- Layer 2 (Data Link): quyết định dựa trên MAC address (Ethernet frame).
- Layer 3 (Network): quyết định dựa trên IP address (packet).
- Layer 4–7: kiểm tra port TCP/UDP (L4) hoặc toàn bộ nội dung application — HTTP header, TLS SNI, URL (L7).
Tầng càng cao, thiết bị càng có nhiều ngữ cảnh, quyết định càng “thông minh” và (theo lịch sử) chi phí trên mỗi đơn vị throughput càng cao.
Duplex, và vì sao hub “chết”
- Half-duplex: một station chỉ có thể gửi hoặc nhận, không đồng thời. Môi trường dùng chung (hub, coax cũ) là half-duplex, cần CSMA/CD để xử lý va chạm.
- Full-duplex: một station có thể gửi và nhận đồng thời trên một liên kết point-to-point riêng. Một port switch nối tới một host là full-duplex, loại bỏ hoàn toàn va chạm trên segment đó.
Vì switch mang lại cho mỗi host một collision domain riêng, full-duplex — với chi phí ngang hoặc rẻ hơn hub xưa — nên hub đã lỗi thời. Ngày nay bạn sẽ không triển khai hub; chúng chỉ còn sống như công cụ dạy học và, đôi khi, như cách thô sơ để “tap” traffic phục vụ monitoring (hub thật copy mọi frame ra mọi port).
Khái niệm chính
Bảng so sánh tổng hợp: thiết bị → tầng OSI → chức năng
| Thiết bị | Tầng OSI | Khóa forwarding | Collision domain | Broadcast domain | Chức năng chính |
|---|---|---|---|---|---|
| Repeater | L1 (Physical) | không (tín hiệu) | 1 (kéo dài) | 1 (kéo dài) | Tái tạo/khuếch đại tín hiệu để kéo dài khoảng cách |
| Hub | L1 (Physical) | không (flood mọi port) | 1 (mọi port) | 1 (mọi port) | Repeater đa port; kết nối môi trường dùng chung (lỗi thời) |
| Bridge | L2 (Data Link) | MAC address | 1 mỗi port/segment | 1 | Nối hai segment, học MAC, lọc traffic cục bộ |
| Switch | L2 (Data Link) | MAC address | 1 mỗi port | 1 (hoặc 1 mỗi VLAN) | Forward frame đúng port; microsegmentation |
| Multilayer / L3 switch | L2 + L3 | MAC + IP | 1 mỗi port | 1 mỗi VLAN, route giữa chúng | Switching tốc độ dây và inter-VLAN routing |
| Router | L3 (Network) | IP / longest-prefix match | 1 mỗi port | 1 mỗi interface (kết thúc chúng) | Route packet giữa các mạng IP khác nhau |
| Modem | Chủ yếu L1 | không (modulation) | n/a | n/a | Modulate/demodulate giữa tín hiệu digital và tín hiệu đường truyền |
| Wireless Access Point (AP) | L2 (bridge sang wired) | MAC | RF dùng chung (mỗi radio) | 1 (bridge vào VLAN wired) | Bridge client Wi-Fi (802.11) vào LAN có dây |
| WLAN Controller (WLC) | L2–L7 (quản trị) | n/a (control plane) | n/a | n/a | Quản lý/cấu hình tập trung nhiều AP |
| Firewall | L3–L7 | IP/port/app/state | n/a | phân tách zone | Thực thi security policy giữa các zone/mạng |
| Load balancer | L4 hoặc L7 | IP+port (L4) / nội dung HTTP (L7) | n/a | n/a | Phân phối connection/request qua một pool server |
| Reverse proxy | L7 | host/path/header HTTP | n/a | n/a | Đứng trước server: terminate TLS, cache, định tuyến |
| Forward proxy | L7 | request của client | n/a | n/a | Đứng trước client khi ra internet |
| IDS/IPS sensor | L3–L7 | signature packet/flow | n/a | n/a | Phát hiện (IDS) hoặc chặn (IPS) traffic độc hại |
| NAS | L7 (file: NFS/SMB) | request file | n/a | n/a | Storage chia sẻ mức file qua LAN |
| SAN | L2/L3 (block: FC/iSCSI) | request block | n/a | n/a | Fabric storage mức block cho server |
Phần còn lại của mục này giải thích từng nhóm thiết bị.
Layer 1 — Repeater và hub
Repeater nhận tín hiệu đã suy yếu, nhiễu và tái tạo lại một bản sạch, cho phép vượt qua độ dài cáp tối đa của môi trường (ví dụ 100 m cho copper Ethernet, hay các đoạn fiber dài). Nó không hiểu gì về dữ liệu — chỉ làm sạch và chuyển tiếp tín hiệu.
Hub là một repeater đa port. Frame đến ở một port sẽ được copy một cách “mù quáng” ra mọi port khác. Hệ quả:
- Mọi port chung một collision domain (half-duplex, cần CSMA/CD).
- Mọi port chung một broadcast domain.
- Không cô lập traffic: mọi host thấy frame của mọi host khác — vấn đề cả về bảo mật lẫn hiệu năng.
- Băng thông dùng chung: một “hub 100 Mbps” cho tổng 100 Mbps chia cho các bên đang nói.
Đó là lý do hub bị switch thay thế hoàn toàn. Xem ./08-switching.md để hiểu switch đã cải tiến ra sao.
Layer 2 — Bridge và switch
Bridge nối hai (hoặc vài) segment mạng và ra quyết định forwarding dựa trên MAC address. Nó học MAC nào nằm ở segment nào bằng cách quan sát source address, rồi chỉ forward frame qua bridge nếu đích nằm ở segment bên kia (lọc traffic cục bộ). Bridge kinh điển thường có hai port, chạy bằng phần mềm và chậm.
Switch về cơ bản là một bridge đa port mật độ cao, được tăng tốc bằng phần cứng — con ngựa thồ của LAN hiện đại. Các hành vi cốt lõi:
- MAC learning: switch xây dựng bảng MAC address (CAM table) ánh xạ
MAC → portbằng cách kiểm tra source MAC của frame đến. - Forwarding / filtering: một unicast frame có destination MAC đã biết chỉ được gửi ra đúng một port. Đây là microsegmentation — mỗi port là một collision domain riêng.
- Flooding: broadcast, multicast và unicast chưa biết (unknown unicast) được flood ra mọi port trong VLAN.
- Full-duplex: mỗi liên kết host–switch chạy full-duplex nên va chạm biến mất.
- VLAN: switch có thể chia các port thành nhiều broadcast domain (VLAN). Mỗi VLAN là một broadcast domain riêng, và cần routing để chuyển traffic giữa chúng.
- Chống loop: Spanning Tree Protocol (STP/RSTP) chặn các đường dự phòng để tránh loop Layer 2 và broadcast storm.
Các chế độ forwarding của switch: store-and-forward (nhận trọn frame, kiểm FCS rồi forward — an toàn nhất) và cut-through (bắt đầu forward ngay sau khi đọc destination MAC — độ trễ thấp nhất).
Chuyên sâu: VLAN, trunking (802.1Q), STP, EtherChannel, và MAC table trong ./08-switching.md.
Layer 3 — Router và multilayer switch
Router nối các mạng IP khác nhau và forward packet dựa trên destination IP, dùng routing table và longest-prefix match. Các tính chất chính:
- Mỗi interface nằm ở một subnet khác nhau và là ranh giới broadcast domain — router không forward broadcast, giúp kiềm chế nhiễu broadcast và thu nhỏ blast radius về lỗi/bảo mật.
- Router làm những việc switch không làm: NAT, DHCP relay, lọc bằng ACL, QoS, và chạy các routing protocol động (OSPF, BGP, EIGRP).
- Router nối LAN với WAN và internet; router thường là thứ cung cấp default gateway của bạn (xem bên dưới).
- Quyết định routing tốn CPU hơn switching, dù router hiện đại đã offload xuống phần cứng.
Multilayer switch (Layer 3 switch) kết hợp phần cứng forwarding tốc độ dây của switch với khả năng Layer 3 của router. Nó switch frame trong một VLAN và route packet giữa các VLAN (inter-VLAN routing) ở tốc độ phần cứng. Trong thiết kế campus/data-center hiện đại, L3 switch thường xử lý routing east-west nội bộ, còn một router hoặc firewall chuyên dụng lo phần edge/WAN. Phân biệt đại khái: router mạnh về đa dạng interface WAN, tính năng routing phong phú và NAT; L3 switch mạnh về routing LAN mật độ cao, throughput lớn giữa các VLAN.
Chuyên sâu về routing table, static vs dynamic routing, và các protocol: ./07-routing.md.
Default gateway
Default gateway là địa chỉ IP mà một host gửi packet tới khi đích không nằm trong subnet của chính nó. Host so sánh destination IP với subnet mask của mình; nếu đích là local, nó ARP và gửi trực tiếp; nếu đích ở xa, nó forward packet tới MAC của default gateway và để thiết bị đó route tiếp.
- Default gateway hầu như luôn là một interface trên router (hoặc L3 switch, hoặc firewall) nằm trên subnet của host.
- Trong mạng gia đình, “router”/home gateway (ví dụ
192.168.1.1) chính là default gateway. - Để có tính sẵn sàng cao, IP gateway thường là một địa chỉ ảo được hai router chia sẻ qua First Hop Redundancy Protocol (HSRP/VRRP/GLBP), nên một router hỏng không làm subnet mất đường ra — xem ./09-redundancy-and-high-availability.md.
Modem và CPE / home gateway
Modem (modulator–demodulator) chuyển đổi giữa tín hiệu digital của thiết bị bạn và tín hiệu analog/line-coded mà môi trường truy nhập của nhà mạng dùng — coax (DOCSIS cable), copper điện thoại (DSL), hay fiber (ONT cho GPON, về kỹ thuật là optical network terminal nhưng cùng vai trò). Modulation mã hóa bit lên sóng mang để truyền; demodulation khôi phục bit khi nhận. Một modem thuần túy hoạt động chủ yếu ở Layer 1 (kèm chút L2 để framing) và không tự route hay cấp IP.
CPE (Customer Premises Equipment) là thuật ngữ chung cho thiết bị tại phía khách hàng do ISP cung cấp hoặc chấp thuận: modem/ONT, và thường là một home gateway hợp nhất (còn gọi residential gateway hay “wireless router”). Một home gateway điển hình là thiết bị converged gộp nhiều chức năng trong một hộp:
- Modem hoặc interface tới điểm bàn giao (handoff) của ISP
- Router (làm NAT/PAT để nhiều host private chia sẻ một public IP)
- Switch Ethernet đa port
- Wireless access point
- DHCP server, DNS forwarder, firewall cơ bản (stateful, kèm port forwarding)
Hiểu nó là năm thiết bị trong một vỏ sẽ giải thích được hành vi của nó và cách troubleshoot. Trong môi trường doanh nghiệp, các chức năng này thường là các thiết bị riêng, chuyên dụng để đạt hiệu năng, khả năng mở rộng và quản trị tốt hơn.
Wireless access point (AP) và WLAN controller
Wireless access point bridge client 802.11 (Wi-Fi) vào LAN có dây. Nó hoạt động ở Layer 2 — một frame từ client Wi-Fi được bridge vào một VLAN wired. Mọi client trên một radio dùng chung môi trường RF (một dạng môi trường dùng chung/half-duplex với cơ chế tranh chấp riêng, CSMA/CA), đó là lý do mật độ AP và quy hoạch kênh (channel planning) rất quan trọng. AP không phải router; trong triển khai enterprise, AP chỉ làm radio + bridging, còn routing, DHCP và policy nằm ở nơi khác.
WLAN controller (WLC) quản lý tập trung nhiều AP — cấu hình, tối ưu RF (channel/power), roaming, security policy và firmware — biến hàng chục hay hàng nghìn AP “thin/lightweight” thành một hệ thống phối hợp thống nhất. Triển khai nhỏ có thể dùng AP “autonomous” hoặc AP quản lý qua cloud (controller đặt trên cloud).
Cố ý trình bày ngắn ở đây — nội dung đầy đủ (chuẩn, kênh, bảo mật, roaming) trong ./10-wireless-networking.md.
Firewall (như một thiết bị)
Firewall thực thi security policy giữa các network zone (ví dụ internet ↔ DMZ ↔ nội bộ). Các loại, theo mức độ tinh vi tăng dần:
- Packet filter (stateless) — allow/deny theo IP, protocol và port; không nhớ connection.
- Stateful firewall — theo dõi trạng thái connection (TCP handshake, flow đã thiết lập), tự động cho phép traffic quay về. Đây là mức nền tảng tiêu chuẩn.
- Next-generation firewall (NGFW) — thêm application awareness (nhận diện app bất kể port), user identity, TLS inspection và IPS tích hợp.
Firewall có thể là appliance phần cứng chuyên dụng, một tính năng trên router, hoặc một instance virtual/cloud. Nó thường nằm ở ranh giới zone và nhiều khi chính là default gateway cho các segment được bảo vệ. Nội dung đầy đủ — zone, thiết kế rule, NAT, NGFW, deep packet inspection — trong ./11-network-security.md.
Load balancer (L4 vs L7)
Load balancer phân phối traffic đến qua một pool server backend để tăng công suất, tính sẵn sàng và khả năng mở rộng. Hai tầng hoạt động:
- Load balancer Layer 4 — quyết định dựa trên IP address và port TCP/UDP. Nó forward connection mà không hiểu nội dung application: nhanh, không phụ thuộc protocol, chi phí thấp. Tốt cho throughput TCP/UDP thô.
- Load balancer Layer 7 — quyết định dựa trên nội dung application: HTTP host/path, cookie, header. Cho phép định tuyến theo nội dung (ví dụ
/api→ một pool,/images→ pool khác), TLS termination, session persistence và health check theo URL. Tốn CPU hơn, nhưng nhiều khả năng hơn.
Load balancer còn làm health check (đưa server chết ra khỏi vòng quay) và là nền tảng của tính sẵn sàng cao. Chuyên sâu — các thuật toán (round-robin, least-connections), session persistence, HA pair và DSR — trong ./09-redundancy-and-high-availability.md.
Reverse proxy và forward proxy
Cả hai đều là trung gian kết thúc một connection và mở connection mới ở phía bên kia, nhưng hướng đối diện nhau:
- Forward proxy đứng trước client đi ra. Client gửi request qua nó để tới internet. Ứng dụng: content filtering, kiểm soát truy cập, caching, ẩn/che IP client nội bộ, kiểm soát egress của doanh nghiệp.
- Reverse proxy đứng trước server. Client bên ngoài tưởng đang nói chuyện với server, nhưng proxy đứng trước một hoặc nhiều backend. Ứng dụng: TLS termination, caching, nén, định tuyến request, ẩn topology backend, và nó thường kiêm luôn L7 load balancer và WAF. Ví dụ: NGINX, HAProxy, Envoy; một edge của CDN là reverse-proxy/cache phân tán toàn cầu.
Mẹo nhớ: forward proxy phục vụ/bảo vệ client; reverse proxy phục vụ/bảo vệ server.
Các appliance khác
- IDS / IPS sensor — IDS (Intrusion Detection System) giám sát traffic và cảnh báo khi có hoạt động khả nghi; thường đặt out-of-band, được cấp traffic qua SPAN/mirror port hoặc network TAP, nên nó thấy một bản copy của traffic. IPS (Intrusion Prevention System) đặt inline và có thể drop traffic độc hại theo thời gian thực. Việc phát hiện dùng signature và/hoặc phân tích anomaly/behavioral. Ngày nay thường được gộp vào NGFW. Xem ./11-network-security.md.
- NAS (Network Attached Storage) — appliance storage mức file, chia sẻ thư mục qua LAN bằng NFS/SMB. Đơn giản, dùng chính mạng IP sẵn có, lý tưởng cho tài liệu chia sẻ và backup.
- SAN (Storage Area Network) — fabric storage mức block (Fibre Channel hoặc iSCSI trên IP) trình bày ổ đĩa thô (LUN) cho server như thể gắn cục bộ. Hiệu năng cao, độ trễ thấp; dùng cho database và ảo hóa. Phân biệt: NAS = file, SAN = block.
- Controller — trong SDN và campus fabric hiện đại, một controller trung tâm quản lý control plane (policy, topology, forwarding rule) trong khi các thiết bị lo data plane. WLC (ở trên) và SDN controller là ví dụ; điều này tách rời “mạng nên làm gì” khỏi các hộp thực thi.
Virtual, cloud và software appliance (NFV)
Trước đây mỗi chức năng ở trên là một hộp phần cứng chuyên dụng. Network Functions Virtualization (NFV) tách các network function khỏi phần cứng độc quyền và chạy chúng dưới dạng phần mềm (virtual machine hoặc container) trên server x86 tiêu chuẩn. Vì vậy ngày nay một “device” thường là một virtual appliance:
- Virtual router, virtual firewall, virtual load balancer, virtual switch (vSwitch), virtual AP.
- Trên cloud, chúng xuất hiện dưới dạng managed service: cloud load balancer (AWS ELB/ALB/NLB, GCP Cloud Load Balancing), cloud NAT gateway, virtual private gateway, security group/network ACL như firewall phân tán, và transit/virtual router.
- Lợi ích: mở rộng đàn hồi, cấp phát nhanh, giảm capex, dễ tự động hóa (infrastructure-as-code), và linh hoạt trong việc đặt chỗ (placement).
- Đánh đổi: hiệu năng phụ thuộc vào host và driver (dù DPDK/SR-IOV giúp ích), và bạn phải quản lý vòng đời phần mềm cùng license.
Liên quan: SDN tách control plane và data plane; VNF/CNF là network function được ảo hóa/container hóa; service chaining ghép nhiều VNF vào một đường đi của traffic. Mental model — device = tầng OSI + chức năng — vẫn đúng; chỉ là chức năng nay là phần mềm.
Best Practices
Mô hình chọn thiết bị (device-selection mental model)
Khớp vấn đề với tầng, rồi khớp tầng với thiết bị:
| Vấn đề bạn gặp | Thiết bị giải quyết |
|---|---|
| Tín hiệu không tới đủ xa | Repeater / fiber, hoặc cáp tốt hơn |
| Nối nhiều host trên một LAN, cô lập collision domain | Switch (không bao giờ dùng hub) |
| Chia một switch vật lý thành nhiều mạng logic | VLAN trên switch |
| Chuyển traffic giữa các subnet / ra internet | Router (hoặc L3 switch cho inter-VLAN) |
| Routing throughput cao giữa nhiều VLAN | Multilayer (L3) switch |
| Kết nối tới môi trường truy nhập của ISP | Modem / ONT |
| Thêm Wi-Fi vào LAN có dây | Access point (+ WLC nếu nhiều AP) |
| Thực thi security policy giữa các zone | Firewall (NGFW để nhận diện app/user) |
| Trải tải qua nhiều server giống hệt nhau | Load balancer (L4 cho tốc độ thô, L7 cho định tuyến theo nội dung) |
| Đứng trước web server: TLS, cache, định tuyến | Reverse proxy |
| Kiểm soát/lọc truy cập internet của client | Forward proxy |
| Phát hiện hoặc chặn tấn công trong traffic | IDS (phát hiện) / IPS (chặn) |
| Chia sẻ file qua LAN | NAS |
| Cấp block storage nhanh cho server | SAN |
| Bất kỳ điều nào ở trên nhưng đàn hồi, tự động | Virtual / cloud appliance (NFV) |
Hướng dẫn thiết kế và vận hành
- Luôn ưu tiên switch hơn hub. Không có lý do hiện đại nào để đưa vào một collision domain dùng chung.
- Đẩy routing xuống nơi có lợi. Dùng L3 switch cho inter-VLAN routing ở lớp access/distribution; dành router cho WAN, NAT và các tính năng routing phong phú.
- Chọn đúng “cỡ” tầng. Đừng mua L7 inspection nơi chỉ cần forward L4 (tốn tiền/độ trễ), và đừng cố giải quyết vấn đề application ở Layer 3.
- Giảm thiểu kích thước broadcast domain. VLAN quá lớn nghĩa là broadcast domain lớn và blast radius về lỗi/bảo mật lớn; hãy segment bằng VLAN và route giữa chúng.
- Thiết kế cho redundancy. Default gateway sau HSRP/VRRP, load balancer chạy HA pair, uplink kép với STP/EtherChannel — xem ./09-redundancy-and-high-availability.md.
- Tách control plane và data plane khi có thể (SDN/controller) để có policy nhất quán, tự động hóa được.
- Cẩn trọng với home gateway converged trong môi trường doanh nghiệp. Tách router/switch/AP/firewall thành các thiết bị chuyên dụng sẽ mở rộng tốt hơn và troubleshoot sạch sẽ hơn.
- Đặt thiết bị bảo mật ở ranh giới. Firewall và IPS thuộc về rìa zone; IDS tap thuộc về nơi thấy được traffic quan trọng.
- Với hệ thống mới, cân nhắc virtual/cloud appliance trước — chúng tự động hóa và mở rộng tốt hơn, nhưng hãy kiểm chứng throughput so với nhu cầu hiệu năng.
- Ghi lại tầng và vai trò cho mọi thiết bị. Biết mỗi hộp hoạt động ở tầng nào giúp mọi phiên troubleshoot sau này nhanh hơn.
Tài liệu tham khảo
- Cisco — What Is a Network Switch vs. a Router?
- Cisco — What Is a Router?
- Cisco — What Is a WLAN Controller?
- Cloudflare — What is a load balancer? (L4 vs L7)
- Cloudflare — Forward proxy vs. reverse proxy
- Cloudflare — What is a firewall?
- Cloudflare — IDS vs. IPS
- Cisco — What Is Network Functions Virtualization (NFV)?
Part of the Network Engineer Roadmap knowledge base.
Overview
A network is only as good as the boxes that move packets between hosts. Every device on a network exists to solve a specific problem: extend a signal, isolate traffic, forward frames, route between networks, translate signaling, secure a perimeter, or distribute load. Understanding what problem each device solves — and at which layer of the OSI model it operates — is the single most useful mental model a network engineer can carry, because it lets you reason about behavior (collision domains, broadcast domains, latency, failure modes) without memorizing product datasheets.
This note walks the device taxonomy from the physical layer upward. We start with the “dumb” signal-repeating devices (repeater, hub), move to Layer 2 frame-switching devices (bridge, switch), then to Layer 3 routing devices (router, multilayer switch), and finally to the “smart” appliances that live at the edge of the network and above (modem, gateway, access point, firewall, load balancer, proxy, IDS/IPS, storage). We close with the modern shift toward virtual and cloud appliances (NFV) and a practical decision model for choosing the right device.
Deeper treatments of individual subjects live in sibling files, cross-linked throughout:
- OSI / TCP-IP layering: ./03-network-models-and-layers.md
- Switching (VLANs, STP, MAC learning): ./08-switching.md
- Routing (static, dynamic, protocols): ./07-routing.md
- Redundancy, HA, load balancing: ./09-redundancy-and-high-availability.md
- Network security, firewalls, IDS/IPS: ./11-network-security.md
- Wireless networking: ./10-wireless-networking.md
Fundamentals
Two ideas you need first: collision domains and broadcast domains
Almost every property of a Layer 1/Layer 2 device comes down to how it affects two “domains”:
- Collision domain — a set of devices whose frames can collide on a shared medium (relevant to half-duplex Ethernet using CSMA/CD). If two stations transmit at once, both frames are corrupted and must be retransmitted. Larger collision domains = more collisions = worse performance.
- Broadcast domain — a set of devices that will all receive a broadcast frame (destination MAC
FF:FF:FF:FF:FF:FF) or other Layer 2 flooded traffic (ARP, DHCP discover, unknown-unicast flooding). Larger broadcast domains = more broadcast noise and a larger fault/security blast radius.
A quick rule of thumb for the classic devices:
- A hub is one big collision domain and one big broadcast domain.
- A switch puts each port in its own collision domain (so collisions essentially disappear with full-duplex), but by default all ports remain in one broadcast domain (unless split by VLANs).
- A router terminates broadcast domains: each router interface is a boundary between broadcast domains. Routers do not forward broadcasts by default.
Hold onto that: switches break up collision domains; routers break up broadcast domains.
The OSI layer a device “operates at”
We say a device “operates at” the highest layer at which it makes forwarding decisions:
- Layer 1 (Physical) devices only regenerate/repeat electrical or optical signals. They have no concept of a frame or address.
- Layer 2 (Data Link) devices make decisions based on MAC addresses (Ethernet frames).
- Layer 3 (Network) devices make decisions based on IP addresses (packets).
- Layer 4–7 devices inspect TCP/UDP ports (L4) or full application content — HTTP headers, TLS SNI, URLs (L7).
The higher the layer, the more context the device has, the smarter its decisions can be, and (historically) the more it costs per unit of throughput.
Duplex, and why hubs died
- Half-duplex: a station can send or receive, not both at once. Shared media (hubs, old coax) are half-duplex, requiring CSMA/CD collision handling.
- Full-duplex: a station can send and receive simultaneously over a dedicated point-to-point link. A switched port to a single host is full-duplex, which eliminates collisions on that segment entirely.
Because switches give every host a private, full-duplex collision domain — and cost the same or less than hubs did — hubs are obsolete. You will not deploy a hub today; they survive only as a teaching tool and, occasionally, as a crude way to tap traffic for monitoring (a real hub copies every frame to every port).
Key Concepts
Master comparison table: device → OSI layer → function
| Device | OSI layer | Forwarding key | Collision domains | Broadcast domains | Primary function |
|---|---|---|---|---|---|
| Repeater | L1 (Physical) | none (signal) | 1 (extends it) | 1 (extends it) | Regenerate/amplify a signal to extend distance |
| Hub | L1 (Physical) | none (floods all ports) | 1 (all ports) | 1 (all ports) | Multiport repeater; shared-media connectivity (obsolete) |
| Bridge | L2 (Data Link) | MAC address | 1 per port/segment | 1 | Connect two segments, learn MACs, filter locally |
| Switch | L2 (Data Link) | MAC address | 1 per port | 1 (or 1 per VLAN) | Forward frames only to the correct port; microsegmentation |
| Multilayer / L3 switch | L2 + L3 | MAC + IP | 1 per port | 1 per VLAN, routes between them | Wire-speed switching and inter-VLAN routing |
| Router | L3 (Network) | IP address / longest-prefix match | 1 per port | 1 per interface (terminates them) | Route packets between different IP networks |
| Modem | L1 (mostly) | none (modulation) | n/a | n/a | Modulate/demodulate between digital and carrier signal |
| Wireless Access Point (AP) | L2 (bridges to wired) | MAC | shared RF (per radio) | 1 (bridges into wired VLAN) | Bridge Wi-Fi (802.11) clients onto the wired LAN |
| WLAN Controller (WLC) | L2–L7 (mgmt) | n/a (control plane) | n/a | n/a | Centrally manage/configure many APs |
| Firewall | L3–L7 | IP/port/app/state | n/a | segments zones | Enforce security policy between zones/networks |
| Load balancer | L4 or L7 | IP+port (L4) / HTTP content (L7) | n/a | n/a | Distribute connections/requests across a server pool |
| Reverse proxy | L7 | HTTP host/path/headers | n/a | n/a | Front-end servers, terminate TLS, cache, route |
| Forward proxy | L7 | client requests | n/a | n/a | Front-end clients going out to the internet |
| IDS/IPS sensor | L3–L7 | packet/flow signatures | n/a | n/a | Detect (IDS) or block (IPS) malicious traffic |
| NAS | L7 (file: NFS/SMB) | file requests | n/a | n/a | File-level shared storage over the LAN |
| SAN | L2/L3 (block: FC/iSCSI) | block requests | n/a | n/a | Block-level storage fabric for servers |
The rest of this section explains each family.
Layer 1 — Repeater and hub
A repeater takes a weakened, noisy signal and regenerates a clean copy, letting you exceed the maximum cable length of a medium (e.g., 100 m for copper Ethernet, or long fiber runs). It understands nothing about the data — it just cleans and forwards the signal.
A hub is a multiport repeater. A frame arriving on one port is blindly copied out of every other port. Consequences:
- All ports share one collision domain (half-duplex, CSMA/CD needed).
- All ports share one broadcast domain.
- No traffic isolation: every host sees every other host’s frames — a security and performance problem.
- Bandwidth is shared: a “100 Mbps hub” gives aggregate 100 Mbps split among active talkers.
This is why hubs were entirely replaced by switches. See ./08-switching.md for how switches improved on this.
Layer 2 — Bridge and switch
A bridge connects two (or a few) network segments and makes forwarding decisions using MAC addresses. It learns which MACs live on which segment by observing source addresses, then forwards a frame across the bridge only if the destination is on the other segment (filtering local traffic). Classic bridges were often two-port, software-based, and slow.
A switch is essentially a high-density, hardware-accelerated multiport bridge — the workhorse of the modern LAN. Core behaviors:
- MAC learning: the switch builds a MAC address table (CAM table) mapping
MAC → portby inspecting source MACs of incoming frames. - Forwarding / filtering: a unicast frame whose destination MAC is known is sent only to that one port. This is microsegmentation — each port is its own collision domain.
- Flooding: broadcasts, multicasts, and unknown unicasts are flooded to all ports in the VLAN.
- Full-duplex: each host-to-switch link runs full-duplex, so collisions vanish.
- VLANs: a switch can subdivide its ports into multiple broadcast domains (VLANs). Each VLAN is a separate broadcast domain, and routing is required to move traffic between them.
- Loop prevention: Spanning Tree Protocol (STP/RSTP) blocks redundant paths to prevent Layer 2 loops and broadcast storms.
Switch forwarding modes: store-and-forward (receive whole frame, check FCS, then forward — safest) vs cut-through (start forwarding after reading the destination MAC — lowest latency).
Deep dive: VLANs, trunking (802.1Q), STP, EtherChannel, and MAC tables in ./08-switching.md.
Layer 3 — Router and multilayer switch
A router connects different IP networks and forwards packets based on the destination IP address using a routing table and longest-prefix match. Key properties:
- Each interface sits in a different subnet and is a broadcast-domain boundary — routers do not forward broadcasts, which contains broadcast noise and shrinks fault/security blast radius.
- Routers perform functions switches don’t: NAT, DHCP relay, ACL-based filtering, QoS, and running dynamic routing protocols (OSPF, BGP, EIGRP).
- They connect LANs to WANs and to the internet; the router is typically what provides your default gateway (see below).
- Routing decisions are more CPU-intensive than switching, though modern routers offload to hardware.
A multilayer switch (Layer 3 switch) combines a switch’s wire-speed hardware forwarding with a router’s Layer 3 capability. It switches frames within a VLAN and routes packets between VLANs (inter-VLAN routing) at hardware speed. In a modern campus/data-center design, L3 switches usually handle east-west routing internally, while a dedicated router or firewall handles the edge/WAN. Rough distinction: a router shines with WAN interface diversity, rich routing features, and NAT; an L3 switch shines with dense high-throughput LAN routing between VLANs.
Deep dive on routing tables, static vs dynamic routing, and protocols: ./07-routing.md.
Default gateway
The default gateway is the IP address a host sends packets to when the destination is not on its own subnet. The host compares the destination IP against its own subnet mask; if the destination is local, it ARPs and sends directly; if it’s remote, it forwards the packet to the default gateway’s MAC and lets that device route onward.
- The default gateway is almost always an interface on a router (or an L3 switch, or a firewall) that sits on the host’s subnet.
- On home networks, the “router”/home gateway (e.g.,
192.168.1.1) is the default gateway. - For high availability, the gateway IP is often a virtual address shared by two routers via a First Hop Redundancy Protocol (HSRP/VRRP/GLBP), so failure of one router doesn’t strand the subnet — see ./09-redundancy-and-high-availability.md.
Modem and CPE / home gateway
A modem (modulator–demodulator) translates between the digital signals of your equipment and the analog/line-coded signal used by the carrier’s access medium — coax (DOCSIS cable), telephone copper (DSL), or fiber (an ONT for GPON, technically an optical network terminal but the same role). Modulation encodes bits onto the carrier for transmission; demodulation recovers bits on receipt. A pure modem operates mostly at Layer 1 (with some L2 for framing) and does not route or assign IPs by itself.
CPE (Customer Premises Equipment) is the umbrella term for the gear at the customer site provided or approved by the ISP: the modem/ONT, and often a combined home gateway (a.k.a. residential gateway or “wireless router”). A typical home gateway is a converged device that bundles several functions into one box:
- Modem or an interface to the ISP handoff
- Router (does NAT/PAT so many private hosts share one public IP)
- Multiport Ethernet switch
- Wireless access point
- DHCP server, DNS forwarder, basic firewall (stateful, plus port forwarding)
Understanding it as five devices in one enclosure explains its behavior and how to troubleshoot it. In business settings these functions are usually separate, purpose-built devices for performance, scale, and manageability.
Wireless access point (AP) and WLAN controller
A wireless access point bridges 802.11 (Wi-Fi) clients onto the wired LAN. It operates at Layer 2 — a frame from a Wi-Fi client is bridged into a wired VLAN. All clients on one radio share the RF medium (a form of shared/half-duplex medium with its own contention, CSMA/CA), which is why AP density and channel planning matter. An AP is not a router; in enterprise deployments the AP does only radio + bridging, while routing, DHCP, and policy live elsewhere.
A WLAN controller (WLC) centrally manages many APs — configuration, RF optimization (channel/power), roaming, security policy, and firmware — turning dozens or thousands of “thin/lightweight” APs into one coordinated system. Small deployments may instead use “autonomous” APs or cloud-managed APs (controller in the cloud).
Brief here by design — full treatment (standards, channels, security, roaming) in ./10-wireless-networking.md.
Firewall (as a device)
A firewall enforces a security policy between network zones (e.g., internet ↔ DMZ ↔ internal). Types, in increasing sophistication:
- Packet filter (stateless) — allow/deny by IP, protocol, and port; no memory of connections.
- Stateful firewall — tracks connection state (the TCP handshake, established flows), allowing return traffic automatically. The standard baseline.
- Next-generation firewall (NGFW) — adds application awareness (identify apps regardless of port), user identity, TLS inspection, and integrated IPS.
A firewall can be a dedicated hardware appliance, a feature on a router, or a virtual/cloud instance. It typically sits at zone boundaries and often is the default gateway for protected segments. Full treatment — zones, rule design, NAT, NGFW, deep packet inspection — in ./11-network-security.md.
Load balancer (L4 vs L7)
A load balancer distributes incoming traffic across a pool of backend servers to improve capacity, availability, and scalability. Two operating layers:
- Layer 4 load balancer — decisions based on IP address and TCP/UDP port. It forwards connections without understanding application content: fast, protocol-agnostic, lower overhead. Good for raw TCP/UDP throughput.
- Layer 7 load balancer — decisions based on application content: HTTP host/path, cookies, headers. Enables content-based routing (e.g.,
/api→ one pool,/images→ another), TLS termination, session persistence, and health checks by URL. More CPU, more capability.
Load balancers also do health checking (pull dead servers out of rotation) and are a cornerstone of high availability. Deep dive — algorithms (round-robin, least-connections), session persistence, HA pairing, and DSR — in ./09-redundancy-and-high-availability.md.
Reverse proxy and forward proxy
Both are intermediaries that terminate a connection and open a new one on the other side, but they face opposite directions:
- Forward proxy sits in front of clients going out. Clients send requests through it to reach the internet. Uses: content filtering, access control, caching, anonymizing/hiding internal client IPs, corporate egress control.
- Reverse proxy sits in front of servers. External clients think they’re talking to the server, but the proxy fronts one or many backends. Uses: TLS termination, caching, compression, request routing, hiding backend topology, and it frequently doubles as an L7 load balancer and WAF. Examples: NGINX, HAProxy, Envoy; a CDN edge is a globally distributed reverse-proxy/cache.
Mnemonic: a forward proxy protects/serves the clients; a reverse proxy protects/serves the servers.
Other appliances
- IDS / IPS sensors — an IDS (Intrusion Detection System) monitors traffic and alerts on suspicious activity; it is typically out-of-band, fed by a SPAN/mirror port or a network TAP, so it sees a copy of traffic. An IPS (Intrusion Prevention System) sits inline and can drop malicious traffic in real time. Detection uses signatures and/or anomaly/behavioral analysis. Often folded into an NGFW today. See ./11-network-security.md.
- NAS (Network Attached Storage) — a file-level storage appliance sharing folders over the LAN via NFS/SMB. Simple, uses the existing IP network, ideal for shared documents and backups.
- SAN (Storage Area Network) — a block-level storage fabric (Fibre Channel or iSCSI over IP) presenting raw disks (LUNs) to servers as if locally attached. High performance and low latency; used for databases and virtualization. Distinction: NAS = files, SAN = blocks.
- Controllers — in modern SDN and campus fabrics, a central controller manages the control plane (policy, topology, forwarding rules) while devices handle the data plane. WLCs (above) and SDN controllers are examples; this decouples “what the network should do” from the boxes that do it.
Virtual, cloud, and software appliances (NFV)
Historically each function above was a dedicated hardware box. Network Functions Virtualization (NFV) decouples network functions from proprietary hardware and runs them as software (virtual machines or containers) on standard x86 servers. So a “device” today is often a virtual appliance:
- Virtual routers, virtual firewalls, virtual load balancers, virtual switches (vSwitch), virtual APs.
- In the cloud, these appear as managed services: cloud load balancers (AWS ELB/ALB/NLB, GCP Cloud Load Balancing), cloud NAT gateways, virtual private gateways, security groups/network ACLs as distributed firewalls, and transit/virtual routers.
- Benefits: elastic scaling, faster provisioning, lower capex, easier automation (infrastructure-as-code), and placement flexibility.
- Trade-offs: performance depends on the host and drivers (though DPDK/SR-IOV help), and you must manage software lifecycle and licensing.
Related: SDN separates control and data planes; VNF/CNF are the virtualized/containerized network functions; service chaining stitches several VNFs into a traffic path. The mental model — device = OSI layer + function — still holds; the function is just software now.
Best Practices
A device-selection mental model
Match the problem to the layer, then to the device:
| The problem you have | The device that solves it |
|---|---|
| Signal won’t reach far enough | Repeater / fiber, or better cabling |
| Connect many hosts on one LAN, isolate collision domains | Switch (never a hub) |
| Segment one physical switch into logical networks | VLANs on a switch |
| Move traffic between subnets / to the internet | Router (or L3 switch for inter-VLAN) |
| High-throughput routing between many VLANs | Multilayer (L3) switch |
| Connect to the ISP’s access medium | Modem / ONT |
| Add Wi-Fi to a wired LAN | Access point (+ WLC if many APs) |
| Enforce security policy between zones | Firewall (NGFW for app/user awareness) |
| Spread load across many identical servers | Load balancer (L4 for raw speed, L7 for content routing) |
| Front-end web servers: TLS, cache, routing | Reverse proxy |
| Control/filter outbound client internet access | Forward proxy |
| Detect or block attacks in traffic | IDS (detect) / IPS (block) |
| Share files across the LAN | NAS |
| Present fast block storage to servers | SAN |
| Any of the above, but elastic and automated | Virtual / cloud appliance (NFV) |
Design and operational guidance
- Prefer switches over hubs, always. There is no modern reason to introduce a shared collision domain.
- Push routing down where it helps. Use L3 switches for inter-VLAN routing at the access/distribution layer; reserve routers for WAN, NAT, and rich routing features.
- Right-size the layer. Don’t buy L7 inspection where an L4 forward is enough (cost/latency), and don’t try to solve an application problem at Layer 3.
- Minimize broadcast domain size. Large VLANs mean large broadcast domains and larger failure/security blast radius; segment with VLANs and route between them.
- Design for redundancy. Default gateways behind HSRP/VRRP, load balancers in HA pairs, dual uplinks with STP/EtherChannel — see ./09-redundancy-and-high-availability.md.
- Separate control and data planes where possible (SDN/controllers) for consistent, automatable policy.
- Beware converged home gateways in business use. Splitting router/switch/AP/firewall into purpose-built devices scales better and troubleshoots more cleanly.
- Place security devices at boundaries. Firewalls and IPS belong at zone edges; IDS taps belong where they can see the traffic that matters.
- Consider virtual/cloud appliances first for new builds — they automate and scale better, but validate throughput against your performance needs.
- Document layer and role for every device. Knowing what layer each box operates at makes every future troubleshooting session faster.
References
- Cisco — What Is a Network Switch vs. a Router?
- Cisco — What Is a Router?
- Cisco — What Is a WLAN Controller?
- Cloudflare — What is a load balancer? (L4 vs L7)
- Cloudflare — Forward proxy vs. reverse proxy
- Cloudflare — What is a firewall?
- Cloudflare — IDS vs. IPS
- Cisco — What Is Network Functions Virtualization (NFV)?