ما هو هجوم فيضان DNS؟
فيضان DNS هو نوع من هجمات حجب الخدمة الموزعة (DDoS) يرسل عدداً هائلاً من استعلامات DNS إلى خوادم الأسماء أو المحللات بهدف استنفاد مواردها ومنع حركة المرور المشروعة. قد يأتي الفيضان من مصدر مباشر، أو يستغل محللات مفتوحة لتضخيم الحركة نحو الضحية.
أثر هجمات فيضان DNS
عندما تتعرض خوادم DNS للضغط الزائد:
Normal operation:
User → DNS query → DNS server → Response → Website loads
During DNS flood:
User → DNS query → DNS server (overwhelmed, no response)
→ Website doesn't load (even though web server is fine)
الآثار:
- تصبح المواقع غير قابلة للوصول، حتى إذا كانت خوادم الويب عاملة
- يفشل تسليم البريد الإلكتروني عند تعذر البحث عن سجلات MX
- تصبح واجهات API والخدمات التي تعتمد على DNS غير متاحة
- تتضرر بنية DNS المشتركة بصورة جانبية
أنواع هجمات فيضان DNS
فيضان استعلامات DNS المباشر
يرسل المهاجم استعلامات DNS مشروعة بأعداد كبيرة:
Botnet → Millions of DNS queries → Target DNS server
Query examples:
example.com A
www.example.com A
random1.example.com A
random2.example.com A
...millions more...
السمات:
- استعلامات DNS صالحة يصعب تصفيتها
- غالباً ما تستهدف نطاقات فرعية عشوائية لتجاوز التخزين المؤقت
- تستخدم شبكة روبوتات لتوزيع الهجوم
هجوم تضخيم DNS
يستغل محللات DNS العودية لتضخيم حركة الهجوم:
1. Attacker sends small query to open resolver
2. Spoofs source IP as victim's IP
3. Resolver sends large response to victim
4. Attacker amplifies bandwidth 28-54x
مثال:
Attacker sends: 60-byte query for TXT record (ANY query)
Resolver sends: 3000-byte response to victim
Amplification: 50x
فيضان NXDOMAIN
يطلب سجلات لنطاقات غير موجودة لتجاوز التخزين المؤقت:
Query: random-12345.example.com (doesn't exist)
Server must check authoritative zone every time
Cannot be cached (NXDOMAIN responses often have low TTL)
Consumes more server resources than cached responses
هجوم النطاق الوهمي
يستعلم عن نطاقات مشروعة لا تستجيب:
Attacker: Queries resolver for slow/non-responsive domains
Resolver: Waits for timeout, consumes resources
Result: Resolver resource exhaustion
هجوم النطاق الفرعي العشوائي
يستعلم عن نطاقات فرعية عشوائية لتجنب إصابات الذاكرة المؤقتة:
Query: abc123random.example.com
Query: xyz789random.example.com
Query: def456random.example.com
Each is unique → cache miss → authoritative query
Overwhelms authoritative nameservers
مسارات الهجوم وتقنياته
هجمات تقودها شبكة روبوتات
Compromised devices:
- IoT devices (cameras, routers)
- Infected computers
- Hacked servers
Distributed attack:
10,000 bots × 100 queries/sec = 1 million queries/sec
هجمات الانعكاس
Attacker spoofs victim's IP
Sends queries to many open resolvers
Resolvers respond to victim with large answers
Victim receives amplified traffic
فيضانات طبقة التطبيق
Legitimate-looking queries
Difficult to distinguish from real traffic
May target specific resource-intensive query types
تبدو هذه الاستعلامات مشروعة، ويصعب تمييزها عن الحركة الحقيقية، وقد تستهدف أنواعاً محددة من الاستعلامات التي تستهلك موارد كثيرة.
اكتشاف هجمات فيضان DNS
حجم استعلامات غير معتاد
Normal baseline: 10,000 queries/second
During attack: 500,000+ queries/second
راقب:
# Check query rate (BIND)
rndc status | grep "queries resulted"
# Analyze query logs
tail -f /var/log/named/queries.log | wc -l
ارتفاع معدل NXDOMAIN
Normal: 5-10% NXDOMAIN responses
Attack: 50-90% NXDOMAIN responses (random subdomain flood)
توزيع عناوين IP المصدر
Legitimate: Diverse source IPs, geographic spread
Attack: Concentrated sources, unusual geographic patterns
أنماط الاستعلام
Legitimate: Repetitive queries (common domains cached)
Attack: Unique queries (random strings, no cache benefit)
تدهور زمن الاستجابة
Normal: < 50ms response time
Under attack: > 1000ms or timeouts
التخفيف من هجمات فيضان DNS
دفاعات مستوى البنية التحتية
#### Anycast DNS
وزّع الحركة عبر مواقع جغرافية متعددة:
Single IP address (e.g., 1.2.3.4) announced from multiple locations
Attack traffic automatically routed to nearest server
Load distributed across global network
Harder to overwhelm all locations simultaneously
الفوائد:
- توزيع الحمل تلقائياً.
- مرونة جغرافية.
- امتصاص جزء من حركة الهجوم.
#### بنية DNS ذات سعة فائضة
Capacity: 10x normal peak traffic
Reserves: Handle sudden spikes
Auto-scaling: Add capacity during attacks
#### تقييد المعدل
# BIND rate limiting (response-rate limiting)
rate-limit {
responses-per-second 10;
window 5;
slip 2;
};
يحد هذا الإعداد الردود من المصدر نفسه للمساعدة في منع هجمات التضخيم.
#### تصفية الاستعلامات
# Block ANY queries (common in amplification)
# Block excessively long queries
# Block known-malicious patterns
مثال BIND:
# Block ANY queries
match-query {
type ANY;
action drop;
};
دفاعات مستوى مزود DNS
#### DNSSEC
لا يمنع DNSSEC الفيضانات مباشرة، لكنه:
- يمنع تسميم الذاكرة المؤقتة أثناء الهجوم.
- يحافظ على سلامة البيانات في ظروف الهجوم.
#### إعداد الخادم الأساسي المخفي
Master server (hidden): 10.0.0.1 (not publicly known)
Slave servers (public): ns1.example.com, ns2.example.com
Attackers target slaves
Master remains operational
Can quickly update slaves if needed
#### جدار DNS الناري أو IDS
Analyze queries in real-time
Block suspicious patterns
Whitelist known-good clients
Blacklist attack sources
وسائل حماية مستوى التطبيق
#### تحديد معدل الاستجابة (RRL)
Limit identical responses to same client
Prevents amplification attacks
Slip mode: Occasionally allow queries through (to not break legitimate recursive resolvers)
إعداد BIND:
options {
rate-limit {
responses-per-second 5;
referrals-per-second 5;
nodata-per-second 5;
nxdomains-per-second 5;
errors-per-second 5;
window 5;
};
};
#### تحسين الذاكرة المؤقتة
Increase cache size to absorb repeated queries
Longer TTLs where appropriate (trade-off with agility)
Prefetch popular records
#### تصفية الاستعلامات
# Drop queries for non-existent zones
# Block queries from known-bad sources
# Rate-limit per-source queries
دفاعات مستوى الشبكة
#### حجب BGP
Route attack traffic to null0
Sacrifice availability to preserve infrastructure
Last resort when attack overwhelms capacity
#### تصفية مزود الإنترنت upstream
Coordinate with ISP to filter attack traffic
Source IP validation (prevent spoofing)
Traffic scrubbing centers
#### خدمات التخفيف من DDoS
Cloudflare, Akamai, AWS Shield
Absorb attack traffic before reaching your servers
Global capacity to withstand large attacks
أفضل ممارسات مرونة DNS
استخدم مزودي DNS متعددين
Primary provider: Cloudflare
Secondary provider: AWS Route 53
If one is attacked/down, other continues serving
Different infrastructure reduces single point of failure
طبّق DNSSEC
Protects against DNS spoofing/cache poisoning
Maintains integrity during attacks
Build trust even under attack conditions
راقب أداء DNS
Real-time query rates
Response times
NXDOMAIN percentages
Geographic distribution of queries
Error rates
أدوات المراقبة التي تساعد على قياس أداء DNS: Grafana وPrometheus وDatadog وAWS CloudWatch.
اختبر السعة بانتظام
Load testing: Can infrastructure handle 10x traffic?
Failover testing: Do secondary providers activate correctly?
Attack simulation: Test mitigation strategies
عطّل التكرار على الخوادم الموثوقة
# BIND
recursion no;
لا ينبغي لخوادم الأسماء الموثوقة أن تعمل أيضاً كمحللات تكرارية.
قيّد نقل المناطق
# BIND
allow-transfer { 10.0.0.2; 10.0.0.3; }; # Only specific slaves
امنع المهاجمين من تفريغ المنطقة بأكملها.
أبقِ البرامج محدثة
Regularly update DNS server software
Patch known vulnerabilities
Subscribe to security advisories
الاستجابة لهجوم فيضان DNS نشط
الإجراءات الفورية
1. تحقق من وقوع الهجوم
# Check query rate
rndc status
# Check load
top
2. فعّل تقييد المعدل
# BIND: Enable RRL if not already active
rndc addzone rate-limit
3. اتصل بمزود تخفيف DDoS
- فعّل خدمات التنظيف.
- أعد توجيه الحركة عبر شبكة التخفيف.
4. حلل أنماط الهجوم
# Top query types
grep "query" /var/log/named/queries.log | awk '{print $6}' | sort | uniq -c | sort -rn | head -20
# Top queried domains
grep "query" /var/log/named/queries.log | awk '{print $7}' | sort | uniq -c | sort -rn | head -20
5. احظر مصادر الهجوم الواضحة
# Identify top source IPs
grep "query" /var/log/named/queries.log | awk '{print $5}' | cut -d# -f1 | sort | uniq -c | sort -rn | head -50
# Block at firewall
iptables -A INPUT -s ATTACKER_IP -j DROP
الإجراءات متوسطة الأجل
1. وسّع البنية التحتية
- أضف سعة إلى خوادم الأسماء.
- وزّعها عبر Anycast إن لم تكن موزعة.
2. طبّق تصفية إضافية
- احظر أنماط الاستعلام الخاصة بالهجوم.
- اسمح للمصادر الموثوقة المعروفة.
3. نسّق مع المزودين
- مزود الإنترنت أو الاستضافة.
- مزود DNS.
- خدمة تخفيف DDoS.
4. وثّق الهجوم
- التقاط الحزم.
- السجلات.
- رسوم الحركة.
- تحليل ما بعد الحادث والأغراض القانونية.
تحليل ما بعد الهجوم
1. راجع فعالية إجراءات التخفيف.
2. حدد نقاط ضعف البنية التحتية.
3. حدّث إجراءات الاستجابة للحوادث.
4. ادرس التحسينات طويلة الأجل، مثل DNS متعدد المزودين وسعة أكبر.
الجوانب القانونية والإبلاغ
أبلغ السلطات
- FBI IC3 في الولايات المتحدة: ic3.gov
- وحدات الجرائم الإلكترونية المحلية.
- أقسام إساءة الاستخدام لدى مزودي الإنترنت.
جمع الأدلة
# Packet captures
tcpdump -i eth0 -w dns-attack.pcap port 53
# Full query logs
tar -czf attack-logs-$(date +%Y%m%d).tar.gz /var/log/named/
# Traffic graphs/screenshots
# System resource usage
تمثل هجمات فيضان DNS تهديداً خطيراً للخدمات المتصلة بالإنترنت، لكن يمكن تقليل أثرها بالبنية المناسبة والمراقبة واستراتيجيات التخفيف.