ITCS 310 · Network Security · Week 15
IPSec: Securing the Network Layer
بروتوكول IPSec: تأمين طبقة الشبكة
IPSec Need & Overview AH & ESP Protocols Transport vs Tunnel ملزمة ثنائية اللغة
ACADEZI.COM
College of Information Technology
Detailed Teaching Guide · دليل تدريس مفصّل
الحاجة إلى IPSec والدوافع The Need for IPSec & Motivation §1
توجد حاجة ملحة لتأمين حركة المرور الحساسة (مثل بيانات الشركات والبنوك) التي تُنقل عبر الإنترنت العام غير الآمن. نحتاج إلى إنشاء "حماية منطقية" (Logical Protection) على مستوى طبقة الشبكة.
There is a need to secure sensitive traffic (e.g., company and bank data) transmitted over the public insecure Internet. We need to create a logical protection over the network layer.
المشكلة السابقة (بدون حماية طبقة الشبكة): في معمارية الشبكات التقليدية، كانت وحدات بيانات طبقة الشبكة (PDUs) تُرسل بصيغة نصية واضحة (In the clear). مما يسهل:
  • فحص محتوى البيانات بسهولة (Easy to inspect).
  • تزوير عنوان المصدر أو الوجهة (Easy to forge source/destination address).
  • تعديل المحتوى (Easy to modify content).
  • إعادة إرسال البيانات الخبيثة (Easy to replay data).
What We Used to Have: In most architectures, network layer PDUs are transmitted in the clear. Making it easy to inspect data, forge addresses, modify content, and replay data.
تأمين الطبقات المختلفة (Securing Protocols per Layer) Security Across OSI Layers §2
الطبقة OSI Layer بروتوكولات الأمان Security Protocols نطاق الحماية Protection Scope
Application Layerطبقة التطبيق PGP, Kerberos, SSH حماية تطبيقات محددة (مثل تسجيل الدخول الآمن، نقل الملفات عبر SSH) ولا تصلح لحركة الشبكة العامة.Protects specific apps. Not designed for general network traffic.
Transport Layerطبقة النقل TLS (Transport Layer Security) يجب تعديل أو إعداد كل تطبيق بشكل فردي لاستخدامه (مثل HTTPS).Must modify or configure each application to use it.
Network Layerطبقة الشبكة IP Security (IPSec) يحمي جميع حركات IP (بغض النظر عن التطبيق) ولا توجد حاجة لتعديل التطبيقات بشكل فردي.Protects all IP traffic regardless of application. No app modification needed.
Data Link Layerطبقة ربط البيانات Hardware encryption Link-level encryption
خصائص طبقة الشبكة: توفر خدمة غير متصلة (Connectionless)، وتقوم بالتوجيه (Routing) لتحديد مسار الحزمة، وتُعرّف آلية العنونة (Addressing) التي يجب أن تلتزم بها الأجهزة.
Network Layer Features: Provides connectionless service, routing (determines path), and defines the addressing mechanism.
نظرة عامة على IPSec والخدمات الأمنية IPSec Overview & Security Services §3
يعمل بروتوكول IPSec على طبقة الشبكة ويوفر مجموعة من الخدمات عبر IPv4 و IPv6. يمكن استخدامه للاتصالات المحلية (داخل نفس الشبكة) أو عن بُعد (الوصول عبر الإنترنت، مثل VPN).
IPSec works on the network layer providing services over IPv4 and IPv6. Can be used locally (inside network) or remotely (internet access, VPN).
Confidentiality (السرية)
يستخدم خوارزميات التشفير (Encryption) لمنع المهاجمين من قراءة محتويات الحزمة.
Uses encryption algorithms to prevent cybercriminals from reading packet contents.
Integrity (النزاهة)
يستخدم خوارزميات التجزئة (Hashing) لضمان عدم تغيير الحزم أثناء انتقالها.
Uses hashing algorithms to ensure packets have not been altered between source and destination.
Origin Authentication (المصادقة)
يستخدم بروتوكول IKE (Internet Key Exchange) لمصادقة المصدر والوجهة.
Uses the Internet Key Exchange (IKE) protocol to authenticate source and destination.
Diffie-Hellman (تبادل المفاتيح)
يُستخدم لتأمين عملية تبادل المفاتيح التشفيرية بأمان.
Used to secure the key exchange process.
بنية IPSec (IP Security Architecture) IPSec Architecture Components §4
تتكون معمارية IPSec من عدة عناصر أساسية لضمان تأمين وحفظ حالات الاتصال بين الأطراف.
The IPSec architecture consists of several key components to ensure and maintain secure connection states.
  • Security Association (SA): تربط خدمات الأمان والمفاتيح بحركة المرور المراد حمايتها. تُعرّف SA بـ SPI (Security Parameter Index) وهو مؤشر يُستخدم لاسترداد معلمات الـ SA من قاعدة البيانات (SAD).
    Associates security services and keys with traffic. Identified by Security Parameter Index (SPI) to retrieve parameters from SAD.
  • Simplex vs Duplex: اتصال الـ SA هو اتصال أحادي الاتجاه (Simplex). للاتصال الآمن ثنائي الاتجاه (Bidirectional)، نحتاج إلى إنشاء جهازي SAs (واحد من A إلى B، والآخر من B إلى A).
    SA is a simplex connection. We need to establish two SAs for secure bidirectional communication.
  • Security Policy Database (SPD): تُعرّف ما هي الحركة التي يجب حمايتها، وكيف تتم حمايتها، ومع من تتم مشاركة هذه الحماية. تُقرر الإجراء المناسب لكل حزمة.
    Defines what traffic to protect, how to protect it, and with whom. Determines the action for each packet.
Discard Action
إسقاط (Discard)
لا تدع الحزمة تدخل أو تخرج.
Do not let the packet in or out.
Bypass Action
تجاوز (Bypass)
لا تُطبق ولا تتوقع خدمات أمنية (تمرير عادي).
Do not apply or expect security services.
Protect Action
حماية (Protect)
قم بتطبيق أو توقع تطبيق خدمات الأمان على الحزم.
Apply/expect security services on packets.
البروتوكولات الرئيسية: AH و ESP IPSec: Two Main Protocols (AH & ESP) §5
قد يستخدم IPSec إما بروتوكول AH أو بروتوكول ESP، ولكن ليس كلاهما عادةً (إذا تم تطبيق كلاهما، يُتطلب إنشاء 2 SAs). يعتمد الأمان المقدم من كلاهما على خوارزميات التشفير المطبقة عليهما. وكلاهما يعملان في وضعي (Transport و Tunnel).
IPSec may use either AH or ESP, but not both usually (if both are applied, two SAs are needed). Security depends on cryptographic algorithms applied. Both operate in Transport and Tunnel modes.
Authentication Header (AH)
رأس المصادقة (AH)
• إثبات أصل البيانات (Origin Auth).
• نزاهة البيانات (Data Integrity).
• حماية ضد إعادة الإرسال (Anti-replay).
• لا يوفر السرية (NO Confidentiality).
Provides proof of data origin, connectionless data integrity, and anti-replay. Does NOT provide confidentiality.
Encapsulating Security Payload (ESP)
تغليف الحمولة الأمنية (ESP)
• يوفر السرية (Confidentiality - Encryption).
• إثبات الأصل والنزاهة، وAnti-replay.
• مصادقة (ولكن ليست بقوة AH لأن رؤوس IP تحت ESP غير محمية).
• سرية تدفق حركة المرور بشكل محدود.
Provides confidentiality, proof of origin, integrity, anti-replay, and limited traffic flow confidentiality. Auth is not as strong as AH for IP headers.
أوضاع التشغيل: Transport مقابل Tunnel IPSec Modes of Operation §6
يمكن استخدام كلا البروتوكولين (AH و ESP) في وضعين مختلفين للتشغيل لتحديد نطاق التشفير والحماية:
Both protocols (AH & ESP) can be used in two different operation modes to define the scope of protection:
الوضع Mode الاستخدام Usage نطاق الحماية Protection Scope التفاصيل التقنية Technical Details
Transport Modeوضع النقل من مضيف إلى مضيف (Host-to-Host)Host-to-Host يحمي بروتوكولات الطبقات العليا (مثل TCP/UDP) ويضمن الاتصال من طرف لآخر.Protects upper layer protocols & ensures end-to-end communication. يتم إدراج رأس IPSec بين رأس IP ورأس بروتوكول الطبقة العليا.IPSec header inserted between IP header and upper-layer header.
Tunnel Modeوضع النفق من بوابة إلى بوابة أو مضيف إلى بوابة (Net-to-Net, Host-to-Net)Host-to-Network, Network-to-Network يحمي مخطط بيانات IP بالكامل (Entire IP datagram).Protects the entire IP datagram. يتم تغليف حزمة IP بالكامل داخل مخطط بيانات IP جديد (رأس IP جديد).Entire IP packet encapsulated in another IP datagram with a New IP header.
تفاصيل رأس المصادقة (AH Details) Authentication Header (AH) Details §7
المصادقة تُحسب باستخدام خوارزميات مثل MD5 أو SHA-1 مع مفتاح سري (Secret Key). المرسل يحسب بيانات المصادقة والمستقبل يتحقق منها. يقع رأس AH خلف رأس IP الخاص بالحزمة الأصلية، ويحتوي على رقم تسلسلي لمنع هجمات إعادة الإرسال.
Authentication is computed using algorithms like MD5, SHA-1 and a cryptographic secret key. Sender computes it, recipient verifies. Located behind the IP header. Holds an optional sequence number to prevent replay attacks.
IP Header
(Original)
AH Header
Next Hdr | Length | SPI | Seq Num | HMAC
Payload Data
(TCP/UDP + App Data)
Authenticated Area: IP Header + AH Header + Payload
تفاصيل تغليف الحمولة الأمنية (ESP Details) Encapsulating Security Payload (ESP) Details §8
يقوم ESP بتشفير البيانات ومصادقتها لكل حزمة بيانات. يحتوي على "رأس" (Header) غير مشفر (يحتوي SPI و Seq)، و"ذيل" (Trailer) مشفر جزئياً (يحتوي Padding و HMAC).
ESP does Data Encryption and Data Authentication. Contains a Not Encrypted Header (SPI, Seq) and a Partially Encrypted Trailer (Padding, HMAC).
IP Header
(Not Encrypted)
ESP Header
SPI | Seq Num
Payload + Padding
(Encrypted Data)
ESP Trailer
HMAC Auth
Encrypted: Payload + Padding | Authenticated: ESP Header + Payload + ESP Trailer
معالجة حزمة ESP: عند استلام الحزمة يتم: 1) التحقق من رقم التسلسل، 2) التحقق من النزاهة (Integrity)، 3) فك التشفير (Decrypt).
ESP Packet Processing: 1. Verify sequence number, 2. Verify integrity, 3. Decrypt.
ملخص المحاضرة — النقاط الرئيسية للمراجعة Chapter Summary – Key Takeaways for Review §9
  • الدافع (Motivation): حماية البيانات المنقولة عبر الإنترنت بتوفير طبقة حماية منطقية على مستوى الشبكة (Network Layer). Secure traffic over the internet logically at the network layer.
  • TLS مقابل IPSec: TLS يحمي تطبيقات معينة ويتطلب تعديلها، بينما IPSec يحمي جميع حركات IP دون الحاجة لتعديل التطبيقات. IPSec protects all IP traffic, no app modifications needed.
  • معمارية الأمان (Architecture): تعتمد على قاعدة سياسات الأمان (SPD) لتحديد ماذا وكيف نحمي، وقاعدة ارتباطات الأمان (SAD) لتخزين المعلمات بناءً على مؤشر SPI. Relies on SPD for policies and SAD for storing parameters identified by SPI.
  • بروتوكول AH: يوفر مصادقة الأصل، النزاهة، وحماية Replay. لا يوفر تشفير/سرية. AH provides auth, integrity, anti-replay, but NO confidentiality.
  • بروتوكول ESP: يوفر سرية (تشفير)، مصادقة، وحماية Replay. يحتوي على رأس وذيل لمعالجة الحزمة. ESP provides confidentiality, auth, anti-replay. Has header & trailer.
  • Transport Mode: يحمي بروتوكولات الطبقات العليا (للاتصال من مضيف إلى مضيف) عن طريق وضع رأس IPSec بعد رأس IP الأصلي. Protects upper layer protocols (Host-to-Host).
  • Tunnel Mode: يحمي كامل مخطط IP عن طريق تغليفه بـ IP جديد، ويستخدم للاتصال بين البوابات (VPN). Protects entire IP datagram, used for gateways (VPN).