Computer >> Hướng Dẫn Máy Tính >  >> Kết Nối Mạng >> An Ninh Mạng

Cách thay đổi Network Profile (Public/Private) và Firewall Profile trên Windows 10/11

Network Profile (Hồ sơ mạng) là gì?

Network Profile (Network Location) quyết định **mức độ tin cậy** của kết nối mạng và **quy tắc Firewall** áp dụng. Windows có 2 profile chính:

  • Private (Riêng tư / Nhà / Công ty): Mạng tin cậy. **Cho phép** chia sẻ file/print, Network Discovery, Remote Desktop. Firewall profile: **Private**.
  • Public (Công cộng / Cà phê / Sân bay): Mạng không tin cậy. **Chặn** chia sẻ, Discovery, Remote Desktop. Firewall profile: **Public** (nghiêm ngặt hơn).

Lưu ý: "Domain" profile tự động áp dụng khi máy join Domain Active Directory.

Cách đổi Network Profile trên Windows 10 / 11 (GUI)

Cách 1: Settings App (Khuyên dùng - Windows 10 20H2+ / 11)

  1. Win + I → **Network & Internet**.
  2. Wi-Fi: Chọn **Manage known networks** → Chọn mạng đang kết nối → **Properties** → Chọn **Private** hoặc **Public**.
    Ethernet: Chọn **Ethernet** → Chọn mạng đang kết nối → Chọn **Private** hoặc **Public**.

Cách 2: Taskbar Quick Action (Nhanh)

  1. Click biểu tượng **Wi-Fi / Ethernet** góc phải Taskbar.
  2. Click **Properties (Thuộc tính)** dưới tên mạng đang kết nối.
  3. Chọn **Private** hoặc **Public**.

Cách 3: PowerShell (Dành cho Admin/Script/Automation)

# Xem profile hiện tại
Get-NetConnectionProfile

# Đổi sang Private (InterfaceAlias là tên card mạng, ví dụ: "Wi-Fi", "Ethernet")
Set-NetConnectionProfile -InterfaceAlias "Wi-Fi" -NetworkCategory Private

# Đổi sang Public
Set-NetConnectionProfile -InterfaceAlias "Ethernet" -NetworkCategory Public

Cách 4: Registry (Advanced - GPO/Script triển khai hàng loạt)

  1. Win + R → regedit.
  2. Đường dẫn: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\.
  3. Mỗi subkey là một mạng (Profile). Xem **ProfileName** để nhận diện.
  4. Sửa giá trị **Category**: 0 = Public, 1 = Private, 2 = Domain.
  5. Khởi động lại **Network Location Awareness (NLA)** service hoặc reboot.

Firewall Profile là gì? Mối quan hệ với Network Profile

Windows Firewall có 3 profile độc lập: **Domain, Private, Public**. Mỗi profile có **Rule Set riêng biệt** (Inbound/Outbound).

  • Network Profile **Private** → Firewall áp dụng rule **Private Profile**.
  • Network Profile **Public** → Firewall áp dụng rule **Public Profile**.
  • Network Profile **Domain** → Firewall áp dụng rule **Domain Profile**.

Ví dụ: Rule "Allow File Sharing" chỉ bật trong Private Profile. Khi bạn đổi Network Profile sang Public → Rule này tắt → Không chia sẻ file được.

Cách xem & đổi Firewall Profile (Kiểm tra profile đang active)

  1. Mở **Windows Defender Firewall with Advanced Security** (Win+R → wf.msc).
  2. Nhìn cột bên trái: **Overview** → **Active Profile: Private / Public / Domain**.
  3. Để tùy chỉnh rule cho từng profile: Click **Inbound Rules / Outbound Rules** → Filter by **Profile** (tab Scope/Advanced).

Cách bật/tắt Firewall cho từng Profile

  1. Control Panel → **System and Security** → **Windows Defender Firewall** → **Turn Windows Defender Firewall on or off**.
  2. Chọn **Turn on** cho **Domain networks, Private networks, Public networks** (Khuyến nghị: **BẬT TẤT CẢ 3**).
  3. Hoặc PowerShell: Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled True.

Tại sao Network Profile tự thay đổi Public ↔ Private?

  • Sync Settings (Windows Backup): Thiết bị khác cùng tài khoản Microsoft sync setting → Ghi đè profile. Fix: Settings → Accounts → Windows Backup → Tắt "Remember my preferences" / "Other settings".
  • Driver/Card mạng mới: Windows nhận dạng là mạng mới → Mặc định Public.
  • Router đổi MAC / IP Gateway / SSID: Windows coi là mạng mới.
  • GPO / Intune Policy: Admin buộc profile.

Best Practice

  • **Mạng Nhà / Văn phòng (LAN tin cậy):** Đặt **Private**. Bật File/Printer Sharing, Network Discovery.
  • **Wi-Fi công cộng / Hotspot điện thoại / Không tin cậy:** Đặt **Public**. Tắt Sharing, Discovery.
  • **Server / DC:** Luôn **Domain Profile** (nếu join AD). Không join AD → **Private** (với firewall rule chặt chẽ).
  • **Không bao giờ tắt Firewall.** Tùy chỉnh rule thay vì tắt.
  • Dùng **PowerShell / Intune / GPO** để chuẩn hóa profile cho hàng trăm máy.

Kết luận

Hiểu và quản trị **Network Profile** là cơ bản nhưng cực kỳ quan trọng để cân bằng giữa **tiện lợi (chia sẻ, remote)** và **an ninh (chặn truy cập lạ)**. Hãy chủ động đặt **Private cho mạng tin cậy, Public cho mạng lạ**, và luôn **giữ Firewall BẬT** với rule Least Privilege.