السلام عليكم
كلنا نعلم مدى اهمية ال Firewalls في تأمين النظام والشبكات
وتتراوح اعدادت ال Firewall بين الاعدادت البسيطة والمعقدة حسب حجم الشبكة والخدمات بها او حسب الخدمات بالنظام
ولهذا يلجأ الكثير من مدراء الانظمة الى الى عمل السكربتات لتسهيل الامر عليهم
اعرض عليكم هذا السكربت .. قمت بكتابته منذ فترة لتسهيل اعدادات الفايروول للشبكة بدلا من كتابة القوانين من الصفر كل مرة
وقمت بتطوير السكربت بحيث يمكن للاخرين استخدامه ايضا
واضفت بعض انواع الحمايات على مستوى الكيرنل وعلى مستوى الفايروول مثل:
تجاهل باكيتس ال ICMP
حماية من ال syn flood وهو احد هجمات حجب الخدمة
منع خاصية ال ICMP Redirect
حماية من ال ICMP Broadcasting
حماية من ال ICMP Dead Error Messages
حماية من ال IP spoofing او التزوير
تقليل تأثير هجمات حجب الخدمة عن طريق تقليل قيم ال timeouts
تجهال عمليات ال scan عن طريق nmap وعدم الرد عليها
جميع الحمايات بالاعلى تيم تفعيلها او الغائها من ملف الاعدادت
عموما لاستخدام السكربت قم بتنزيله من المرفقات ثم:
[HTML]# tar xvfz netspider_firewall-1.2.0.tar.gz
# cd netspider-firewall/
# ls
firewall.conf GPL-license.txt install.sh start-firewall stop-firewall
# sh install.sh
Copying files
.
.
.
Do you want the firewall start when system start? [yes/no]
yes
Install Complete
[/HTML]
اذا لا تريد السكربت يعمل عند بداية التشغيل اجب بالنفي
بعد ذلك قم بفتح ملف الاعدادت:
او
والاعدادت بسيطة وحرصت ان اشرحها في الملف
ولكن احب اوضح بعض الاعدادت المهمة التي يمكن ان تحتاج الى توضيح اكثر
هذه القيمة تحدد الوضع الافتراضي للفايروول اما ان يمنع الفايروول الاتصال بجميع البورتات معدا البورتات التي تقوم انت بالسماح لها بالاتصال
والوضع الاخر وهو ان يقوم الفايروول في الوضع الافتراضي بالسماح لجميع البورتات بالاتصال بعدا البورتات والخدمات التي تقوم انت بمنعها
طبعا الوضع الاول اكثر امانا وينصح به وهو الوضع الافتراضي
هذه القيمة قم بتفعليها بغيير 0 الى ١ اذا كان الجهاز راوتر او يقوم بتشغيل خدمة ال NAT
لتفعيل ال NAT غير ال 0 الى 1
وغير قيمة EXTERNAL_IF الى كرت الشبكة الخارجي الخاص بالانترنت سواء كان كرت شبكة او مودم .. فقط اكتب اسمه
وفي INTERNAL_IF ضع اسم كارت الشبكة الداخلي الخاص بال LAN
اذا كنت تقدم خدمة ال Proxy فقم بتفعيل ال SUPPORT_PROXY
حيث سيقوم بعمل اعدادت الفايروول الخاصة بالبروكسي كما سيقوم بتقديم بعض الحمايات له مثل
الحماية من المستخدمين اللذين يخدعونك ويقومو بأستخدام بروكسي اخر .. والنتيجة ان اتصالهم لن يقبل وسيتم عمل Drop له
ايضا الحماية من المستخدمين اللذين يقوموم بالاتصال بالانترنت مباشرة دون استخدام بروكسي .. حيث سيتم تحويل اتصالهم للبروكسي تلقائيا
بعد ذلك قم بعمل اعدادت ال Firewall Rules حسب الخدمات عندك
وفي النهاية قم بتشغيل الفايروول عن طريق الامر start-firewall
NetSpider IPTABLES Firewall v1.2.0
Email: [email protected]
---------------------------------------------------------------
Loading IPTABLES modules:
Loading ip_tables [ Required ]
Loading ipt_limit [ log limits ]
Loading ipt_state [ packet state checking (SYN, SYN-ACK, ACK ]
Loading ip_conntrack [ connection tracking ]
Loading ip_conntrack_ftp [ allow active FTP ]
Loading ipt_multiport [ packet specifing on multiple ports ]
Loading iptable_filter [ filter table ]
Loading ipt_mac [ Allows specifying MAC address ]
Loading iptable_mangle [ support mangle table ]
Loading iptable_mangle [ support type of service checking ]
The modules loaded
Flushing all rules in IPtables [ OK ]
Setting default secure policies. [ OK ]
Enabling SYN-flood protection. [ OK ]
Disableing the acception of ICMP-redirect messages. [ OK ]
Enabling smurf protection [ OK ]
Enable ICMP Dead Error Messages protection [ OK ]
Disable IP forwarding [ OK ]
Enable Logging Spoofed, Source Routed, Redirect Packets [ OK ]
Enable IP spoofing protection [ OK ]
Enabling reduction of the DoS ability. [ OK ]
Setting The Default TTL [ OK ]
Accepting packets from the local loopback device. [ OK ]
Drop Invalid packets [ OK ]
Allowing the whole world to send ICMP-requests(ping). [ OK ]
Drop of scan enabled. [ OK ]
Enabling mangling TOS. [ OK ]
** All firewall rules applied ** [ OK ]
[/HTML]
اذا لم تظهر رسائل اخطاء فكل شيء على ما يرام
لمشاهدة الاعدادت الحالية:
لايقاف الفايروول نفذ:
السكربت يقوم بعمل نسخة من ال rules او القوانين في الملف /etc/firewall.save
يمكنك تشغيل هذه القوانين على اي جهاز اخر لا يتوفر عليه السكربت عن طريق الامر:
ملاحظة: يرجى عدم تحميل نسخة السكربت الموجوده على www.packetstormsecurity.org
لان بها بعض الاخطاء وقمت بتعديلها في هذه النسخة .. حملوها من المرفقات
لاي استفسار تفضلو
والسلام عليكم
كلنا نعلم مدى اهمية ال Firewalls في تأمين النظام والشبكات
وتتراوح اعدادت ال Firewall بين الاعدادت البسيطة والمعقدة حسب حجم الشبكة والخدمات بها او حسب الخدمات بالنظام
ولهذا يلجأ الكثير من مدراء الانظمة الى الى عمل السكربتات لتسهيل الامر عليهم
اعرض عليكم هذا السكربت .. قمت بكتابته منذ فترة لتسهيل اعدادات الفايروول للشبكة بدلا من كتابة القوانين من الصفر كل مرة
وقمت بتطوير السكربت بحيث يمكن للاخرين استخدامه ايضا
واضفت بعض انواع الحمايات على مستوى الكيرنل وعلى مستوى الفايروول مثل:
تجاهل باكيتس ال ICMP
حماية من ال syn flood وهو احد هجمات حجب الخدمة
منع خاصية ال ICMP Redirect
حماية من ال ICMP Broadcasting
حماية من ال ICMP Dead Error Messages
حماية من ال IP spoofing او التزوير
تقليل تأثير هجمات حجب الخدمة عن طريق تقليل قيم ال timeouts
تجهال عمليات ال scan عن طريق nmap وعدم الرد عليها
جميع الحمايات بالاعلى تيم تفعيلها او الغائها من ملف الاعدادت
عموما لاستخدام السكربت قم بتنزيله من المرفقات ثم:
[HTML]# tar xvfz netspider_firewall-1.2.0.tar.gz
# cd netspider-firewall/
# ls
firewall.conf GPL-license.txt install.sh start-firewall stop-firewall
# sh install.sh
Copying files
.
.
.
Do you want the firewall start when system start? [yes/no]
yes
Install Complete
[/HTML]
اذا لا تريد السكربت يعمل عند بداية التشغيل اجب بالنفي
بعد ذلك قم بفتح ملف الاعدادت:
كود:
#gedit /etc/firewall.conf
كود:
# vi /etc/firewall.conf
كود:
#!/bin/bash # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # Copyright 2004-2005 by Net-Spider # Email : [email protected] # ------------------------------------------------------------------- VERSION="1.2.0" modprobe="/sbin/modprobe -v" # IPtables Firewall binary file default path IPTABLES=/sbin/iptables # Default standard policy for iptables which could be "drop" # or "accept" (drop = very secure). DEFAULT_POLICY=drop # Block ICMP echo-requests such as ping, to enable it put "1", to disable "0" IGNORE_ICMP=0 # Enable/Disable world to send ICMP packets # If IGNORE_ICMP=1, it will Allow all world to send ICMP packets OPEN_ICMP=1 # good protetion from syn flood with Linux kernel, set it to "1" to enable. SYN_FLOOD_PROTECTION=1 # Enable/Disable ICMP Redirect acceptance. DISABLE_ICMP_REDIRECT=1 # ICMP Broadcasting protection SMURF_PROTECTION=1 # Enable/Disabl ICMP Dead Error Messages protection ERROR_PRO=1 # Enable/Disabl IP forwarding, enable it by putting "1" value, only if # you use NAT or your system work as a router IP_FORWARD=0 # Enable/Disable IP spoofing protection SPOOF_PROTECT=1 # Enable/Disable Log Spoofed, Source Routed, Redirect Packets LOG_PACKET=1 # Enable/Disabl Reduce DoS ability by reducing timeouts. REDUCE_DOS=1 # Log of ICMP flooding ICMP_FLOOD_LOG=1 # Drop Nmap Scan packets DROP_SCAN=1 # Log Nmap Scan SCAN_LOG=0 # Enable this if you want TOS mangling (RFC) MANGLE_TOS=1 # Current log-level ("info": default kernel syslog level) LOGLEVEL="info" # The Default interface interface="eth0" # Other trusted interface TRUSTED_IF="" # NAT configuration (MASQUERADE) SUPPORT_NAT=0 EXTERNAL_IF="eth0" # External Interface device ( eth0, ppp0 .... ) INTERNAL_IF="eth1" # Internal Interface device # Proxy configuration SUPPORT_PROXY=0 # make sure that nobody will try to cheat and use a proxy server other than yours. # We must also make sure that nobody will try to cheat and connect to the internet directly LAN_ID="192.168.1.1/24" # The Network Adress PRX_INT_IP="192.168.1.1" # IP Adress of Proxy internal interface LAN_IF="eth1" # Internal network interface PRX_PORT="8080" # The port which the proxy server listen to # Set to "1" if your system work as IRC server IRC=0 ######################################################### # # # Firewall Rules # # # ######################################################### # Enable = 1, Disable = 0 SSH=1 FTP=1 HTTP=1 HTTPS=1 SMTP=1 SMTPS=1 POP3=1 POP3s=1 IMAP=1 IMAPs=1 DNS=1 MYSQL=1 CPANEL=1 DIJICHAT=0 WEBMIN=0 TELNET=0 TFTP=0 SNMP=0 SMB=0 NFS=0 RPC=0 LDAP=0 LDAPS=0 NNTP=0 NNTPS=0 NTP=0 DHCP=0 printer=0 XWindows=0 XFontServer=0
ولكن احب اوضح بعض الاعدادت المهمة التي يمكن ان تحتاج الى توضيح اكثر
كود PHP:
DEFAULT_POLICY=drop
والوضع الاخر وهو ان يقوم الفايروول في الوضع الافتراضي بالسماح لجميع البورتات بالاتصال بعدا البورتات والخدمات التي تقوم انت بمنعها
طبعا الوضع الاول اكثر امانا وينصح به وهو الوضع الافتراضي
كود PHP:
IP_FORWARD=0
كود PHP:
# NAT configuration (MASQUERADE)
SUPPORT_NAT=0
EXTERNAL_IF="eth0" # External Interface device ( eth0, ppp0 .... )
INTERNAL_IF="eth1" # Internal Interface device
وغير قيمة EXTERNAL_IF الى كرت الشبكة الخارجي الخاص بالانترنت سواء كان كرت شبكة او مودم .. فقط اكتب اسمه
وفي INTERNAL_IF ضع اسم كارت الشبكة الداخلي الخاص بال LAN
كود PHP:
SUPPORT_PROXY=0
# make sure that nobody will try to cheat and use a proxy server other than yours.
# We must also make sure that nobody will try to cheat and connect to the internet directly
LAN_ID="192.168.1.1/24" # The Network Adress
PRX_INT_IP="192.168.1.1" # IP Adress of Proxy internal interface
LAN_IF="eth1" # Internal network interface
PRX_PORT="8080" # The port which the proxy server listen to
حيث سيقوم بعمل اعدادت الفايروول الخاصة بالبروكسي كما سيقوم بتقديم بعض الحمايات له مثل
الحماية من المستخدمين اللذين يخدعونك ويقومو بأستخدام بروكسي اخر .. والنتيجة ان اتصالهم لن يقبل وسيتم عمل Drop له
ايضا الحماية من المستخدمين اللذين يقوموم بالاتصال بالانترنت مباشرة دون استخدام بروكسي .. حيث سيتم تحويل اتصالهم للبروكسي تلقائيا
بعد ذلك قم بعمل اعدادت ال Firewall Rules حسب الخدمات عندك
وفي النهاية قم بتشغيل الفايروول عن طريق الامر start-firewall
كود:
# start-firewall
Email: [email protected]
---------------------------------------------------------------
Loading IPTABLES modules:
Loading ip_tables [ Required ]
Loading ipt_limit [ log limits ]
Loading ipt_state [ packet state checking (SYN, SYN-ACK, ACK ]
Loading ip_conntrack [ connection tracking ]
Loading ip_conntrack_ftp [ allow active FTP ]
Loading ipt_multiport [ packet specifing on multiple ports ]
Loading iptable_filter [ filter table ]
Loading ipt_mac [ Allows specifying MAC address ]
Loading iptable_mangle [ support mangle table ]
Loading iptable_mangle [ support type of service checking ]
The modules loaded
Flushing all rules in IPtables [ OK ]
Setting default secure policies. [ OK ]
Enabling SYN-flood protection. [ OK ]
Disableing the acception of ICMP-redirect messages. [ OK ]
Enabling smurf protection [ OK ]
Enable ICMP Dead Error Messages protection [ OK ]
Disable IP forwarding [ OK ]
Enable Logging Spoofed, Source Routed, Redirect Packets [ OK ]
Enable IP spoofing protection [ OK ]
Enabling reduction of the DoS ability. [ OK ]
Setting The Default TTL [ OK ]
Accepting packets from the local loopback device. [ OK ]
Drop Invalid packets [ OK ]
Allowing the whole world to send ICMP-requests(ping). [ OK ]
Drop of scan enabled. [ OK ]
Enabling mangling TOS. [ OK ]
** All firewall rules applied ** [ OK ]
[/HTML]
اذا لم تظهر رسائل اخطاء فكل شيء على ما يرام
لمشاهدة الاعدادت الحالية:
كود:
# iptables -L
لايقاف الفايروول نفذ:
كود:
# stop-firewall Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: nat mangle filter [ OK ] Unloading iptables modules: [ OK ]
السكربت يقوم بعمل نسخة من ال rules او القوانين في الملف /etc/firewall.save
يمكنك تشغيل هذه القوانين على اي جهاز اخر لا يتوفر عليه السكربت عن طريق الامر:
كود:
# iptables-restore < /etc/firewall.save
لان بها بعض الاخطاء وقمت بتعديلها في هذه النسخة .. حملوها من المرفقات
لاي استفسار تفضلو
والسلام عليكم
تعليق