Azure Networking Basics: VNets, Subnets & Regions

Microsoft Azure Networking (AZ-700 track) Azure portal — free tier (GUI + CLI)

مقصدObjectiveObjective

Azure regions، virtual networks، subnets اور address spaces کو سمجھنا — اور انہیں portal اور CLI میں بنانا۔Azure regions, virtual networks, subnets aur address spaces ko samajhna — aur unhe portal aur CLI mein banana.Understand Azure regions, virtual networks, subnets, and address spaces — and create them in the portal and CLI.

آسان مثالSimple AnalogySimple Analogy

VNet ایک گیٹڈ ہاؤسنگ سوسائٹی کی طرح ہے۔ سوسائٹی (VNet) کا ایک ایڈریس رینج (address space) ہوتا ہے، گلیاں (subnets) اسے تقسیم کرتی ہیں، اور گیٹ (gateway) اسے باہر کی دنیا سے جوڑتا ہے۔VNet ek gated housing society ki tarah hai. Society (VNet) ka ek address range (address space) hota hai, galiyan (subnets) use baant-ti hain, aur gate (gateway) use bahar ki duniya se jorta hai.A VNet is like a gated housing society. The society (VNet) has an address range (address space), streets (subnets) divide it, and the gate (gateway) connects it to the outside world.

سیٹ اپLab SetupLab Setup

آپ کو صرف Azure free-tier subscription چاہیے۔ ایک resource group (rg-netsec-lab) اور ایک location، مثلاً Southeast Asia، بنائیں۔Aap ko sirf Azure free-tier subscription chahiye. Ek resource group (rg-netsec-lab) aur ek location, masalan Southeast Asia, banayein.You only need an Azure free-tier subscription. Create one resource group (rg-netsec-lab) and one location, e.g. Southeast Asia.

اقداماتStepsSteps

Step 1

اپنے قریب کے ریجن، مثلاً Southeast Asia، میں rg-netsec-lab نام کا resource group بنائیں۔ اس کورس کی ہر چیز اس کے اندر رکھیں تاکہ کلین اپ آسان ہو۔Apne qareeb ke region, masalan Southeast Asia, mein rg-netsec-lab naam ka resource group banayein. Is course ki har cheez us ke andar rakhein taake cleanup asaan ho.Create a resource group named rg-netsec-lab in a region close to you, e.g. Southeast Asia. Everything in this course goes inside it for easy cleanup.

🖱️ Home > Create a resource > Virtual networkHome > Create a resource > Virtual networkHome > Create a resource > Virtual network

Step 2

وہی مرحلہ CLI سے کریں۔ az group create command resource group فوراً بنا دیتی ہے — portal کے نتیجے سے موازنہ کریں۔Wohi step CLI se karein. az group create command resource group foran bana deti hai — portal ke natije se compare karein.Do the same step from the CLI. The az group create command builds the resource group instantly — compare with the portal result.

az group create --name rg-netsec-lab --location southeastasia

🖱️ Home > Resource groups > CreateHome > Resource groups > CreateHome > Resource groups > Create

Step 3

vnet-core نام کا VNet بنائیں، address space 10.1.0.0/16 کے ساتھ۔ یہ address space پورے VNet کے لیے کل IP رینج ہے۔vnet-core naam ka VNet banayein, address space 10.1.0.0/16 ke saath. Yeh address space pure VNet ke liye kul IP range hai.Create a VNet named vnet-core with address space 10.1.0.0/16. This address space is the total IP range available to the whole VNet.

az network vnet create --resource-group rg-netsec-lab --name vnet-core --address-prefix 10.1.0.0/16 --subnet-name snet-web --subnet-prefix 10.1.1.0/24 --location southeastasia

🖱️ Home > Virtual networks > Create — address space 10.1.0.0/16 اور ایک subnet snet-web 10.1.1.0/24 سیٹ کریںHome > Virtual networks > Create — address space 10.1.0.0/16 aur ek subnet snet-web 10.1.1.0/24 set kareinHome > Virtual networks > Create — set address space 10.1.0.0/16 and one subnet snet-web 10.1.1.0/24

Step 4

دو اور subnets شامل کریں: snet-app (10.1.2.0/24) اور snet-db (10.1.3.0/24)۔ ہر subnet سوسائٹی کے اندر ایک گلی ہے — الگ broadcast domain، وہی VNet۔Do aur subnets add karein: snet-app (10.1.2.0/24) aur snet-db (10.1.3.0/24). Har subnet society ke andar ek gali hai — alag broadcast domain, wohi VNet.Add two more subnets: snet-app (10.1.2.0/24) and snet-db (10.1.3.0/24). Each subnet is a street inside the society — separate broadcast domain, same VNet.

az network vnet subnet create --resource-group rg-netsec-lab --vnet-name vnet-core --name snet-app --address-prefix 10.1.2.0/24

🖱️ Virtual networks > vnet-core > Subnets > + Subnet — snet-app 10.1.2.0/24 شامل کریںVirtual networks > vnet-core > Subnets > + Subnet — snet-app 10.1.2.0/24 add kareinVirtual networks > vnet-core > Subnets > + Subnet — add snet-app 10.1.2.0/24

Step 5

VNet اور اس کی subnets ویریفائی کریں۔ Subnets آپس میں اوورلیپ نہیں ہونی چاہئیں اور VNet address space میں فٹ ہونی چاہئیں۔VNet aur us ki subnets verify karein. Subnets aapas mein overlap nahi honi chahiyein aur VNet address space mein fit honi chahiyein.Verify the VNet and its subnets. Subnets must not overlap each other or the VNet address space must contain them.

az network vnet list --resource-group rg-netsec-lab --output table

🖱️ Home > Virtual networks — تصدیق کریں کہ vnet-core لسٹ میں نظر آ رہا ہےHome > Virtual networks — tasdeeq karein ke vnet-core list mein nazar aa raha haiHome > Virtual networks — verify vnet-core appears in the list

Step 6

VNet میں دوسرا address space 10.2.0.0/16 شامل کریں، پھر اس سے نئی subnet snet-infra (10.2.1.0/24) بنائیں۔ ایک VNet متعدد address spaces رکھ سکتا ہے۔VNet mein doosra address space 10.2.0.0/16 add karein, phir us se nayi subnet snet-infra (10.2.1.0/24) banayein. Ek VNet multiple address spaces rakh sakta hai.Add a second address space 10.2.0.0/16 to the VNet, then carve a new subnet snet-infra (10.2.1.0/24) from it. A VNet can hold multiple address spaces.

🖱️ Virtual networks > vnet-core > Address space — دوسری رینج 10.2.0.0/16 شامل کریںVirtual networks > vnet-core > Address space — doosri range 10.2.0.0/16 add kareinVirtual networks > vnet-core > Address space — add a second range 10.2.0.0/16

Step 7

VNet سیٹنگز کھولیں اور اس کا ریجن نوٹ کریں۔ ایک VNet صرف ایک ریجن میں رہتا ہے اور دو ریجنز میں پھیل نہیں سکتا — ریجنز کے درمیان peering VNets کو جوڑتی ہے۔VNet settings kholein aur us ka region note karein. Ek VNet sirf ek region mein rehta hai aur do regions mein phail nahi sakta — regions ke darmiyan peering VNets ko jorti hai.Open the VNet settings and note its region. A VNet lives in exactly one region and cannot span two regions — peering connects VNets across regions.

🖱️ Virtual networks > vnet-core > Settings — Location/Region فیلڈ نوٹ کریںVirtual networks > vnet-core > Settings — Location/Region field note kareinVirtual networks > vnet-core > Settings — note the Location/Region field

تصدیقVerifyVerify

آپ کو vnet-core نظر آتا ہے address spaces 10.1.0.0/16 اور 10.2.0.0/16 کے ساتھ، اور subnets snet-web، snet-app، snet-db، snet-infra — سب ایک ہی ریجن میں۔Aap ko vnet-core nazar aata hai address spaces 10.1.0.0/16 aur 10.2.0.0/16 ke saath, aur subnets snet-web, snet-app, snet-db, snet-infra — sab ek hi region mein.You see vnet-core with address spaces 10.1.0.0/16 and 10.2.0.0/16, and subnets snet-web, snet-app, snet-db, snet-infra — all inside one region.

خرابی دور کرناTroubleshootingTroubleshooting

⚠️ Subnet error: "Address prefix is overlapping with another subnet"Subnet error: "Address prefix is overlapping with another subnet"Subnet error: "Address prefix is overlapping with another subnet"

✅ ایسا بلاک چنیں جو موجودہ subnets سے ٹکرائے نہیں، مثلاً جب 10.1.1.0/24–10.1.3.0/24 استعمال میں ہیں تو 10.1.4.0/24۔Aisa block chunein jo maujooda subnets se takraye nahi, masalan jab 10.1.1.0/24–10.1.3.0/24 istemal mein hain to 10.1.4.0/24.Pick a block that does not collide with existing subnets, e.g. 10.1.4.0/24 when 10.1.1.0/24–10.1.3.0/24 are used.

انٹرویو سوالاتInterview Q&AInterview Q&A

❓ VNet میں address space کیا ہوتا ہے؟VNet mein address space kya hota hai?What is an address space in a VNet?

VNet کا مکمل IP رینج (مثلاً 10.0.0.0/16) — 10.0.0.0/16 کا مطلب پہلے 16 بٹس نیٹ ورک ہیں، اور Azure ہر subnet میں 5 IPs ریزرو کرتا ہے (network، default gateway، DNS mapping، future use)۔VNet ka mukammal IP range (masalan 10.0.0.0/16) — 10.0.0.0/16 ka matlab pehle 16 bits network hain, aur Azure har subnet mein 5 IPs reserve karta hai (network, default gateway, DNS mapping, future use).The VNet's overall IP range (e.g. 10.0.0.0/16) — 10.0.0.0/16 means the first 16 bits are the network, and Azure reserves 5 IPs per subnet (network, default gateway, DNS mapping, future use).

❓ Address space کا subnets سے کیا تعلق ہے؟Address space ka subnets se kya talluq hai?How does an address space relate to subnets?

Address space وہ نیٹ ورک حصہ ہے جو تمام subnets میں مشترک ہوتا ہے، جیسے ایک سوسائٹی کے اندر گلیاں۔ ایک VNet میں متعدد address spaces ہو سکتے ہیں؛ ہر subnet ان میں سے ایک بلاک لیتی ہے۔Address space woh network part hai jo sab subnets mein mushtarik hota hai, jaise ek society ke andar galiyan. Ek VNet mein multiple address spaces ho sakte hain; har subnet un mein se ek block leti hai.The address space is the network part shared by all subnets, like streets inside one society. A VNet can have multiple address spaces; each subnet takes one block from them.