Business Digital

شبكة Azure الافتراضية (vNet، peering، NSG، Bastion) — درس AZ-104 2026

6 دقائق للقراءة

بناء vNet Azure كامل: subnets، peering hub-and-spoke، NSG، Application Security Groups، Azure Bastion، VPN Gateway site-to-site و point-to-site، ExpressRoute مفاهيم، Azure Firewall أساسيّات.

للسياق: الدليل الرئيسي Azure AZ-104 · Tenant Azure مجّاني · نشر VM Azure.

المقدّمة

الـ vNet (Virtual Network) هو مكافئ VPC في AWS. المجال 4 Virtual Networking (15-20%) من AZ-104. هذا الدرس يُغطّي الأنماط الشبكيّة القياسيّة في Azure.

المتطلّبات

  • Tenant Azure + VM مُنشَأة سلفاً.
  • فهم TCP/IP، CIDR.
  • المستوى المتوسّط.
  • الوقت: ساعتان.

الخطوة 1 — إنشاء vNet و subnets

# vNet
az network vnet create \
  --resource-group lab-vnet \
  --name lab-vnet \
  --address-prefix 10.0.0.0/16 \
  --location francecentral

# Subnets
az network vnet subnet create -g lab-vnet --vnet-name lab-vnet --name web-subnet --address-prefix 10.0.1.0/24
az network vnet subnet create -g lab-vnet --vnet-name lab-vnet --name app-subnet --address-prefix 10.0.2.0/24
az network vnet subnet create -g lab-vnet --vnet-name lab-vnet --name db-subnet --address-prefix 10.0.3.0/24
az network vnet subnet create -g lab-vnet --vnet-name lab-vnet --name AzureBastionSubnet --address-prefix 10.0.10.0/26

ملاحظة: subnets محجوزة في Azure: AzureBastionSubnet، GatewaySubnet، AzureFirewallSubnet. أسماء دقيقة مطلوبة.

الخطوة 2 — vNet Peering

vNet peering يربط 2 vNets (نفس المنطقة أو cross-region). traffic خاصّ على Azure backbone، لا عبر الإنترنت.

# Hub vNet
az network vnet create -g lab-net --name hub-vnet --address-prefix 10.0.0.0/16

# Spoke vNets
az network vnet create -g lab-net --name spoke1-vnet --address-prefix 10.1.0.0/16
az network vnet create -g lab-net --name spoke2-vnet --address-prefix 10.2.0.0/16

# Peering ثنائي الاتّجاه hub ↔ spoke1
HUB_ID=$(az network vnet show -g lab-net -n hub-vnet --query id -o tsv)
SPOKE1_ID=$(az network vnet show -g lab-net -n spoke1-vnet --query id -o tsv)

az network vnet peering create \
  -g lab-net --vnet-name hub-vnet --name hub-to-spoke1 \
  --remote-vnet $SPOKE1_ID --allow-vnet-access --allow-forwarded-traffic

az network vnet peering create \
  -g lab-net --vnet-name spoke1-vnet --name spoke1-to-hub \
  --remote-vnet $HUB_ID --allow-vnet-access --allow-forwarded-traffic

⚠️ vNet peering ليس عابراً. Spoke1 ↔ Spoke2 يتطلّب: مرور عبر Hub مع routage يدويّ + User-Defined Routes (UDR)، أو Azure Virtual WAN.

الخطوة 3 — NSG مقابل Application Security Groups (ASG)

NSG (Network Security Group)
  - Allow/Deny rules حسب الأولويّة (100-4096)
  - مُرفَق بـ subnet أو NIC
  - Stateful (الاستجابة مسموحة)
  - Default rules (deny inbound، allow outbound، allow vnet-to-vnet)

ASG (Application Security Group)
  - مجموعة منطقيّة من NICs (مثلاً: ASG-WEB، ASG-DB)
  - مرجعيّ في NSG rules بدل IPs
  - أكثر قابليّة للصيانة من IPs ثابتة
# ASG
az network asg create -g lab-vnet --name asg-web
az network asg create -g lab-vnet --name asg-db

# إرفاق NIC بـ ASG
az network nic update -g lab-vnet --name web-nic --application-security-groups asg-web

# NSG rule يسمح ASG-WEB ← ASG-DB على port 5432
az network nsg rule create \
  --resource-group lab-vnet --nsg-name lab-nsg \
  --name AllowWebToDB --priority 100 --direction Inbound \
  --source-asgs asg-web --destination-asgs asg-db \
  --protocol Tcp --destination-port-ranges 5432 --access Allow

الخطوة 4 — Azure Bastion

راجع درس VM السابق. تذكير: يسمح بـ RDP/SSH عبر portal دون Public IP على الـ VMs الهدف.

الخطوة 5 — VPN Gateway

VPN site-to-site (S2S): يربط الـ vNet بشبكة on-prem.

# GatewaySubnet (اسم إلزاميّ)
az network vnet subnet create -g lab-vnet --vnet-name lab-vnet --name GatewaySubnet --address-prefix 10.0.255.0/27

# Public IP لـ gateway
az network public-ip create -g lab-vnet --name vpn-gw-pip --sku Basic

# VPN Gateway (~30 USD/شهر Basic)
az network vnet-gateway create \
  -g lab-vnet --name vpn-gw \
  --vnet lab-vnet --public-ip-addresses vpn-gw-pip \
  --gateway-type Vpn --vpn-type RouteBased --sku Basic

# Local Network Gateway (يُمثّل الـ on-prem)
az network local-gateway create \
  -g lab-vnet --name onprem-lgw \
  --gateway-ip-address 203.0.113.5 --local-address-prefixes 192.168.0.0/16

# Connection
az network vpn-connection create \
  -g lab-vnet --name s2s-connection \
  --vnet-gateway1 vpn-gw --local-gateway2 onprem-lgw \
  --shared-key "PreSharedKeyVPN2026"

⚠️ VPN Gateway في lab = ~30 USD/شهر. احذف بعد الاستعمال.

VPN point-to-site (P2S): مستخدمون عن بُعد يتّصلون عبر client OpenVPN أو Azure VPN client.

الخطوة 6 — ExpressRoute (مفاهيم)

ExpressRoute = اتّصال خاصّ مُخصَّص Azure (بدون إنترنت). latence مستقرّ، débit مضمون، أمن أقصى.

ExpressRoute Direct       : 10/100 Gbps، منفذ فيزيائيّ مُخصَّص
ExpressRoute              : عبر شريك (Equinix، Orange، إلخ) 50 Mbps - 10 Gbps
التكلفة                   : 50-2000 USD/شهر حسب débit + رسوم provider
حالة الاستعمال            : شركات كبرى، hybrid cloud إنتاج

في الاختبار: ExpressRoute > VPN لـ latence/débit/موثوقيّة. VPN لـ ميزانيّة محدودة.

الخطوة 7 — Azure Firewall مقابل NSG

NSG               : مستوى IP/port/protocol (L3-L4)، stateful، مجّاني
Azure Firewall    : firewall as a service مع FQDN، threat intel، IDPS، SNAT، DNAT
                    Policy-based، multi-vNet
                    ~750 USD/شهر Standard، أكثر لـ Premium
                    Azure Firewall Basic بـ ~300 USD/شهر (small/medium)

نمط hub-and-spoke: Azure Firewall في hub vNet، كلّ traffic من spokes يُمرَّر عبر firewall (UDR).

الخطوة 8 — Private Endpoints

Service link خاصّ نحو PaaS Azure (Storage، SQL DB، Key Vault) دون كشف على الإنترنت العامّ.

# Private Endpoint لـ Storage
az network private-endpoint create \
  -g lab-vnet --name storage-pe \
  --vnet-name lab-vnet --subnet web-subnet \
  --private-connection-resource-id $(az storage account show -g lab-vnet -n labstorageacct --query id -o tsv) \
  --group-id blob --connection-name storage-conn

الـ storage account يصبح متاحاً عبر IP خاصّ في الـ vNet، لا عبر endpoint عامّ. موصى به للامتثال.

الخطوة 9 — DNS خاصّ Azure

# Zone DNS خاصّة
az network private-dns zone create -g lab-vnet --name lab.local

# ربط zone بـ vNet
az network private-dns link vnet create \
  -g lab-vnet --zone-name lab.local --name lab-link \
  --virtual-network lab-vnet --registration-enabled true

VMs الـ vNet تُسجّل تلقائياً أسماءها في zone DNS الخاصّة. تحلّ أسماء داخليّة دون DNS عامّ.

الخطوة 10 — Cleanup

az group delete --name lab-vnet --yes --no-wait
az group delete --name lab-net --yes --no-wait

الأخطاء المتكرّرة

الخطأ الحلّ
اسم Subnet AzureBastionSubnet مرفوض الاسم الدقيق إلزاميّ، لا «BastionSubnet»
Peering لا يُوجِّه spoke-spoke غير عابر، يلزم UDR أو Virtual WAN
VPN Gateway فاتورة مفاجئة ~30 USD/شهر Basic، احذف بعد الـ lab
NSG rule لا تعمل تحقّق من priority + direction + source/destination
Private Endpoint DNS resolution ne marche pas إنشاء Private DNS zone مرتبطة بالـ vNet

تكيّفات إقليميّة

Banques: hub-and-spoke avec Azure Firewall Premium + Private Endpoints + ExpressRoute لـ on-prem. ميزانيّة 3000-5000 USD/شهر.

Startups: vNet بسيط 2-3 subnets + NSG. التكلفة شبه صفر (vNet مجّاني، NSG مجّاني).

ESN: قوالب Bicep hub-and-spoke معياريّة لكلّ عميل جديد.

أسئلة شائعة

vNet عبر مناطق؟ Cross-region peering ممكن، latence حسب المسافة.

كم vNet لكلّ subscription؟ 1000 افتراضياً، قابل للزيادة.

NSG على subnet أم NIC؟ كلاهما إن لزم، القواعد تُقَيَّم على الاثنين.

للتعمّق


الكلمات المفتاحيّة: Azure vNet، Peering hub-and-spoke، NSG، ASG، Azure Bastion، VPN Gateway S2S P2S، ExpressRoute، Azure Firewall، Private Endpoints، Private DNS.


تعميق

Banque ivoirienne: hub-and-spoke avec Azure Firewall Premium + ExpressRoute نحو datacenter Plateau Abidjan. توفير 30% مقابل MPLS classique.

E-commerce panafricain: vNet peering global eu-west + af-south + Front Door pour serve LATAM/Afrique.

Fintech: Private Endpoints على Azure SQL + Key Vault + Storage = surface attaque réduite à zéro Internet.

أدوات تكميليّة

Network Watcher، Azure Monitor Network Insights، Microsoft Sentinel للـ network analytics، Azure Firewall Manager، Azure Virtual WAN لـ multi-site complexe.

مقالات ذات صلة

مشاركة