Manjaro Difference between revisions of "Firewalls/fa"

Difference between revisions of "Firewalls/fa"

From Manjaro
(Created page with "دیوارهای آتش")
 
Tags: Mobile web edit Mobile edit
 
(38 intermediate revisions by the same user not shown)
Line 2: Line 2:
__TOC__
__TOC__


=Overview=
=نمای کلّی=


Running a local firewall is almost always a good practice. Even when you are behind a network firewall, a local firewall protects you from threats on the inside of your network.
اجرای یک دیوارآتش محلی تقریباً همیشه یک تمرین خوب است. حتی زمانی که پشت دیوارآتش شبکه قرار دارید، یک دیوارآتش محلی از شما در برابر تهدیدات داخل شبکه محافظت می کند.


=UFW=  
=UFW=  


UFW stands for Uncomplicated FireWall, and is a program for managing a netfilter firewall. It provides a command line interface and aims to be uncomplicated and easy to use. UFW is far simpler than iptables and a good place to start unless you have very specialized needs.
UFW مخفف Uncomplicated FireWall است و برنامه ای برای مدیریت دیوار‌آتش و فیلتر شبکه است. این یک رابط خط‌فرمان فراهم می کند و هدف آن این است که بدون پیچیدگی و آسان برای استفاده باشد. UFW بسیار ساده‌تر از iptables است و مکان خوبی برای شروع است مگر اینکه نیازهای بسیار تخصصی داشته باشید.


==Installing UFW==
==نصب UFW=


You can install the {{ic|ufw}} package using you favorite package manager or the command:
می توانید بسته '''ufw''' را با استفاده از مدیر بسته مورد علاقه خود یا با دستور زیر نصب کنید:
{{UserCmd|command=pamac install ufw}}
{{UserCmd|command=pamac install ufw}}


Once UFW is installed you need to start and enable it using the commands:
پس از نصب UFW، باید آن را با استفاده از دستورات زیر شروع کرده و فعال کنید:
{{UserCmd|command=sudo systemctl enable ufw.service}}
{{UserCmd|command=sudo systemctl enable ufw.service}}
{{UserCmd|command=sudo ufw enable}}
{{UserCmd|command=sudo ufw enable}}


{{warning|Don't enable both iptables.service and ufw.service}}
{{warning|هم iptables.service و هم ufw.service را با هم فعال نکنید. ابتدا iptables.service غیرفعال و سپس ufw.service را فعال کنید.}}


==Adding Rules==
==اضافه کردن قوانین==


To view the current configuration you can use the command {{ic|ufw status}}. Here is what it looks like in a new install:
اضافه کردن قوانین
 
برای مشاهده پیکربندی فعلی می‌توانید از دستور <code>ufw status</code> استفاده کنید. در اینجا در نصب جدید این‌گونه به نظر می‌رسد:


{{UserCmdOutput|command=sudo ufw status verbose|result=
{{UserCmdOutput|command=sudo ufw status verbose|result=
Line 32: Line 34:
}}
}}


This indicates that it will block all incoming traffic and allow all outgoing traffic. This is a good starting point for most desktop systems. However, often we will want to allow some incoming traffic. This can be done with the command {{ic|ufw allow}}. For example, if we want to allow incoming ssh traffic so we can connect to the machine from other machines on the network we could use the command:
این نشان می دهد که تمام ترافیک ورودی را مسدود می کند و به همه ترافیک‌های خروجی اجازه می‌دهد. این نقطه شروع خوبی برای اکثر سامانه های میزکار است. با این حال، اغلب ما می خواهیم به برخی از ترافیک های ورودی اجازه دهیم. این را می توان با دستور <code>ufw allow</code> انجام داد. به عنوان مثال، اگر بخواهیم به ترافیک ssh ورودی اجازه دهیم تا بتوانیم از سایر دستگاه های موجود در شبکه به دستگاه متصل شویم، می توانیم از دستور زیر استفاده کنیم:
{{UserCmd|command=sudo ufw allow ssh}}
{{UserCmd|command=sudo ufw allow ssh}}


If we wanted to also tcp connections to a local webserver on a non-standard https port, 8443. We could use the command:
اگر بخواهیم اتصالات tcp را به یک وب‌سرور محلی روی درگاه غیر استاندارد https، یعنی درگاه 8443 نیز انجام دهیم. می توانیم از این دستور استفاده کنیم:
{{UserCmd|command=sudo ufw allow in 8443/tcp}}
{{UserCmd|command=sudo ufw allow in 8443/tcp}}


{{tip|When you don't specify "in" or "out", "in" is assumed}}
{{tip|وقتی ''in'' یا ''out'' را مشخص نمی کنید، ''in'' در نظر گرفته می شود}}


==UFW and Applications==
==UFW و برنامه‌های کاربردی==


You may notice a difference in the above two commands. When we built the rules for ssh we used the name and for https we used the port number, 8443. This is because UFW has a small database of applications it knows the ports for. You can see the list with the command:
ممکن است تفاوتی را در دو دستور بالا مشاهده کنید. هنگامی که قوانین را برای ssh ساختیم، از نام و برای https از شماره درگاه(پورت)، یعنی 8443، استفاده کردیم. این به این دلیل است که UFW پایگاه داده کوچکی از برنامه‌ها دارد که درگاه‌ها را می‌شناسد. با دستور زیر می توانید این فهرست را مشاهده کنید:
{{UserCmd|command=sudo ufw app list}}
{{UserCmd|command=sudo ufw app list}}


For applications on the list you can add them by name. If you want to review the configuration for one of the applications, you can use the command {{ic|ufw app info}}. For example, to the configuration for ssh:
برای برنامه های موجود در فهرست می توانید آنها را با نام اضافه کنید. اگر می‌خواهید پیکربندی یکی از برنامه‌ها را مرور کنید، می‌توانید از دستور <code>ufw app info</code> استفاده کنید. به عنوان مثال، برای مرور پیکربندی ssh دستور زیر را وارد کنید:


{{UserCmdOutput|command=sudo ufw app info SSH|result=
{{UserCmdOutput|command=sudo ufw app info SSH|result=
<pre>Profile: SSH
<pre>Profile: SSH
Title: SSH server
Title: SSH server
Line 57: Line 59:
}}
}}


{{tip|When using ufw app the commands are case sensitive but when adding rules they are not}}
{{tip|هنگام استفاده از برنامه ufw، دستورات به حروف بزرگ و کوچک حساس هستند، اما هنگام اضافه کردن قوانین، به آنها حساس نیستند}}


Some additional preconfigured applications can be added by installing the package {{ic|ufw-extras}} with your favorite package manager or the command:
با نصب بسته '''ufw-extras''' با مدیر بسته مورد علاقه خود یا دستور زیر، می‌توان برخی از برنامه‌های از پیش پیکربندی‌شده اضافی را اضافه کرد:
{{UserCmd|command=pamac install ufw-extras}}
{{UserCmd|command=pamac install ufw-extras}}


==Removing Rules==
==حذف قوانین==


Rules can be removed with the {{ic|ufw delete}} command. For example, to delete our 8443 rules we could use the command:
قوانین را می توان با دستور <code>ufw delete</code> حذف کرد. به عنوان مثال، برای حذف قوانین 8443 ما می توانیم از دستور استفاده کنیم:
{{UserCmd|command=sudo ufw delete allow 8443/tcp}}
{{UserCmd|command=sudo ufw delete allow 8443/tcp}}


You can also delete them by number. This is easier if you have a numbered list which you can see with the command:
شما همچنین می توانید آنها را با شماره حذف کنید. اگر یک لیست شماره دار داشته باشید که می توانید با دستور زیر مشاهده کنید، این کار آسان تر است:


{{UserCmdOutput|command=sudo ufw status numbered|result=
{{UserCmdOutput|command=sudo ufw status numbered|result=
Line 77: Line 79:
</pre>}}
</pre>}}


Now if we wanted to stop allowing ssh on ipv6 we could use the command:
حال اگر بخواهیم اجازه دادن به ssh را در ipv6 متوقف کنیم، می توانیم از دستور زیر استفاده کنیم:
{{UserCmd|command=sudo ufw delete 2}}
{{UserCmd|command=sudo ufw delete 2}}


==GUFW==
==GUFW==
[[File:gufw.jpg|thumb|left|240px]]
[[File:gufw.jpg|thumb|left|240px]]


Prefer to use GUI applications and still want to manage your firewall? No problem.  GUFW is a GTK front-end for UFW that aims to make managing a Linux firewall as accessible and easy as possible. It features pre-sets for common ports and p2p applications.
ترجیح می دهید از برنامه های رابط کاربری گرافیکی استفاده کنید و همچنان می خواهید دیوارآتش خود را مدیریت کنید؟ مشکلی نیست GUFW یک برنامه گرافیکی GTK برای UFW است که قصد دارد مدیریت دیوارآتش لینوکس را تا حد امکان در دسترس و آسان کند. دارای پیش‌تنظیمی برای درگاه‌های رایج و برنامه‌های p2p است.


If it is not installed already gufw can be installed from the repos:
اگر قبلاً نصب نشده باشد gufw را می توان از مخازن نصب کرد:
{{UserCmd|command=pamac install gufw}}
{{UserCmd|command=pamac install gufw}}


It will now be available in the menu as '''Firewall Configuration''' or by running {{ic|gufw}} directly.
اکنون در منو به‌عنوان پیکربندی دیوارآتش (Firewall Configuration) یا با اجرای مستقیم '''gufw''' در دسترس خواهد بود.
<div style="clear: both"></div>
<div style="clear: both"></div>


=iptables=
=iptables=


iptables is included as part of the Linux kernel. iptables is significantly more complicated than using a tool like UFW. As a result, a full tutorial on iptables is beyond the scope of this wiki. Using iptables on Manjaro should be the same for every distribution of Linux so there is plenty of available documentation. Some of this is linked [[Firewalls#See_Also|below]]. Here are some basics to get you started.
iptables به عنوان بخشی از کِرنِل لینوکس گنجانده شده است. iptables بسیار پیچیده‌تر از استفاده از ابزاری مانند UFW است. در نتیجه، آموزش کامل iptables خارج از محدوده این ویکی است. استفاده از iptables در مانجارو باید با هر توزیع لینوکس دیگر یکسان باشد، بنابراین اسناد موجود زیادی وجود دارد. برخی از این موارد در بخش جستار های وابسته‌ی این صفحه پیوند داده شده است. در اینجا برخی از اصول اولیه برای شروع شما وجود دارد.


To enable loading rules on startup you can use the command:
برای فعال کردن قوانین بارگیری در راه اندازی می توانید از دستور زیر استفاده کنید:
{{UserCmd|command=sudo systemctl enable iptables.service}}
{{UserCmd|command=sudo systemctl enable iptables.service}}


This will load the rules from the file {{ic|/etc/iptables/iptables.rules}}.
با این کار قوانین از پرونده '''etc/iptables/iptables.rules/''' بارگیری می شود.


To display the currently loaded rules:
برای نمایش قوانین بارگذاری شده فعلی دستور زیر را وارد کنید:
{{UserCmd|command=sudo iptables -L}}
{{UserCmd|command=sudo iptables -L}}


To save the current rules to a file
برای ذخیره قوانین فعلی در یک پرونده:
{{UserCmd|command=sudo sh -c "iptables-save > /etc/iptables/iptables.rules"}}
{{UserCmd|command=sudo sh -c "iptables-save > /etc/iptables/iptables.rules"}}


To load the rules from a file
برای بارگذاری قوانین از یک پرونده:
{{UserCmd|command=sudo sh -c "iptables-restore > /etc/iptables/iptables.rules"}}
{{UserCmd|command=sudo sh -c "iptables-restore > /etc/iptables/iptables.rules"}}


To allow ssh connections
برای اجازه دادن به اتصالات ssh:
{{UserCmd|command=sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT}}
{{UserCmd|command=sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT}}
{{UserCmd|command=sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT}}
{{UserCmd|command=sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT}}


=See Also=
=جستار های وابسته=
* The Arch Wiki on [https://wiki.archlinux.org/index.php/Ufw UFW]
* [https://wiki.archlinux.org/index.php/Ufw UFW در ویکی آرچ]
* The [https://help.ubuntu.com/community/UFW UFW website]
* [https://help.ubuntu.com/community/UFW وب‌سایت UFW]
* The [http://gufw.org/ GUFW website]
* [https://gufw.org وب‌سایت GUFW]
* The [https://linux.die.net/man/8/iptables iptables man page]
* [https://linux.die.net/man/8/iptables صفحه راهنمای iptables]
* The Arch Wiki on [https://wiki.archlinux.org/index.php/iptables iptables]
* [https://wiki.archlinux.org/index.php/iptables iptables در ویکی آرچ]
* The Debian Wiki on [https://wiki.debian.org/iptables iptables]
* [https://wiki.debian.org/iptables iptables در ویکی دبیان]


[[Category:Contents Page{{#translation:}}]]
[[Category:Contents Page{{#translation:}}]]
[[Category:Security{{#translation:}}]]
[[Category:Security{{#translation:}}]]

Latest revision as of 13:14, 15 April 2022

Other languages:
English • ‎Türkçe • ‎русский • ‎فارسی • ‎中文(中国大陆)‎

نمای کلّی

اجرای یک دیوارآتش محلی تقریباً همیشه یک تمرین خوب است. حتی زمانی که پشت دیوارآتش شبکه قرار دارید، یک دیوارآتش محلی از شما در برابر تهدیدات داخل شبکه محافظت می کند.

UFW

UFW مخفف Uncomplicated FireWall است و برنامه ای برای مدیریت دیوار‌آتش و فیلتر شبکه است. این یک رابط خط‌فرمان فراهم می کند و هدف آن این است که بدون پیچیدگی و آسان برای استفاده باشد. UFW بسیار ساده‌تر از iptables است و مکان خوبی برای شروع است مگر اینکه نیازهای بسیار تخصصی داشته باشید.

=نصب UFW

می توانید بسته ufw را با استفاده از مدیر بسته مورد علاقه خود یا با دستور زیر نصب کنید:

user $ pamac install ufw COPY TO CLIPBOARD


پس از نصب UFW، باید آن را با استفاده از دستورات زیر شروع کرده و فعال کنید:

user $ sudo systemctl enable ufw.service COPY TO CLIPBOARD


user $ sudo ufw enable COPY TO CLIPBOARD



Warning
هم iptables.service و هم ufw.service را با هم فعال نکنید. ابتدا iptables.service غیرفعال و سپس ufw.service را فعال کنید.

اضافه کردن قوانین

اضافه کردن قوانین

برای مشاهده پیکربندی فعلی می‌توانید از دستور ufw status استفاده کنید. در اینجا در نصب جدید این‌گونه به نظر می‌رسد:


$ sudo ufw status verbose

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip


این نشان می دهد که تمام ترافیک ورودی را مسدود می کند و به همه ترافیک‌های خروجی اجازه می‌دهد. این نقطه شروع خوبی برای اکثر سامانه های میزکار است. با این حال، اغلب ما می خواهیم به برخی از ترافیک های ورودی اجازه دهیم. این را می توان با دستور ufw allow انجام داد. به عنوان مثال، اگر بخواهیم به ترافیک ssh ورودی اجازه دهیم تا بتوانیم از سایر دستگاه های موجود در شبکه به دستگاه متصل شویم، می توانیم از دستور زیر استفاده کنیم:

user $ sudo ufw allow ssh COPY TO CLIPBOARD


اگر بخواهیم اتصالات tcp را به یک وب‌سرور محلی روی درگاه غیر استاندارد https، یعنی درگاه 8443 نیز انجام دهیم. می توانیم از این دستور استفاده کنیم:

user $ sudo ufw allow in 8443/tcp COPY TO CLIPBOARD




Tip
وقتی in یا out را مشخص نمی کنید، in در نظر گرفته می شود

UFW و برنامه‌های کاربردی

ممکن است تفاوتی را در دو دستور بالا مشاهده کنید. هنگامی که قوانین را برای ssh ساختیم، از نام و برای https از شماره درگاه(پورت)، یعنی 8443، استفاده کردیم. این به این دلیل است که UFW پایگاه داده کوچکی از برنامه‌ها دارد که درگاه‌ها را می‌شناسد. با دستور زیر می توانید این فهرست را مشاهده کنید:

user $ sudo ufw app list COPY TO CLIPBOARD


برای برنامه های موجود در فهرست می توانید آنها را با نام اضافه کنید. اگر می‌خواهید پیکربندی یکی از برنامه‌ها را مرور کنید، می‌توانید از دستور ufw app info استفاده کنید. به عنوان مثال، برای مرور پیکربندی ssh دستور زیر را وارد کنید:


$ sudo ufw app info SSH

Profile: SSH
Title: SSH server
Description: SSH server
 
 
Port:
  22/tcp



Tip
هنگام استفاده از برنامه ufw، دستورات به حروف بزرگ و کوچک حساس هستند، اما هنگام اضافه کردن قوانین، به آنها حساس نیستند

با نصب بسته ufw-extras با مدیر بسته مورد علاقه خود یا دستور زیر، می‌توان برخی از برنامه‌های از پیش پیکربندی‌شده اضافی را اضافه کرد:

user $ pamac install ufw-extras COPY TO CLIPBOARD


حذف قوانین

قوانین را می توان با دستور ufw delete حذف کرد. به عنوان مثال، برای حذف قوانین 8443 ما می توانیم از دستور استفاده کنیم:

user $ sudo ufw delete allow 8443/tcp COPY TO CLIPBOARD


شما همچنین می توانید آنها را با شماره حذف کنید. اگر یک لیست شماره دار داشته باشید که می توانید با دستور زیر مشاهده کنید، این کار آسان تر است:


$ sudo ufw status numbered

Status: active
To                         Action      From
     --                         ------      ----
[ 1] 22                         ALLOW IN    Anywhere
[ 2] 22 (v6)                    ALLOW IN    Anywhere (v6)


حال اگر بخواهیم اجازه دادن به ssh را در ipv6 متوقف کنیم، می توانیم از دستور زیر استفاده کنیم:

user $ sudo ufw delete 2 COPY TO CLIPBOARD


GUFW

Gufw.jpg

ترجیح می دهید از برنامه های رابط کاربری گرافیکی استفاده کنید و همچنان می خواهید دیوارآتش خود را مدیریت کنید؟ مشکلی نیست GUFW یک برنامه گرافیکی GTK برای UFW است که قصد دارد مدیریت دیوارآتش لینوکس را تا حد امکان در دسترس و آسان کند. دارای پیش‌تنظیمی برای درگاه‌های رایج و برنامه‌های p2p است.

اگر قبلاً نصب نشده باشد gufw را می توان از مخازن نصب کرد:

user $ pamac install gufw COPY TO CLIPBOARD


اکنون در منو به‌عنوان پیکربندی دیوارآتش (Firewall Configuration) یا با اجرای مستقیم gufw در دسترس خواهد بود.

iptables

iptables به عنوان بخشی از کِرنِل لینوکس گنجانده شده است. iptables بسیار پیچیده‌تر از استفاده از ابزاری مانند UFW است. در نتیجه، آموزش کامل iptables خارج از محدوده این ویکی است. استفاده از iptables در مانجارو باید با هر توزیع لینوکس دیگر یکسان باشد، بنابراین اسناد موجود زیادی وجود دارد. برخی از این موارد در بخش جستار های وابسته‌ی این صفحه پیوند داده شده است. در اینجا برخی از اصول اولیه برای شروع شما وجود دارد.

برای فعال کردن قوانین بارگیری در راه اندازی می توانید از دستور زیر استفاده کنید:

user $ sudo systemctl enable iptables.service COPY TO CLIPBOARD


با این کار قوانین از پرونده etc/iptables/iptables.rules/ بارگیری می شود.

برای نمایش قوانین بارگذاری شده فعلی دستور زیر را وارد کنید:

user $ sudo iptables -L COPY TO CLIPBOARD


برای ذخیره قوانین فعلی در یک پرونده:

user $ sudo sh -c "iptables-save > /etc/iptables/iptables.rules" /etc/iptables/iptables.rules" " aria-disabled="false">COPY TO CLIPBOARD


برای بارگذاری قوانین از یک پرونده:

user $ sudo sh -c "iptables-restore > /etc/iptables/iptables.rules" /etc/iptables/iptables.rules" " aria-disabled="false">COPY TO CLIPBOARD


برای اجازه دادن به اتصالات ssh:

user $ sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT COPY TO CLIPBOARD


user $ sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT COPY TO CLIPBOARD


جستار های وابسته

Cookies help us deliver our services. By using our services, you agree to our use of cookies.