Pare-feux
Views
Actions
Namespaces
Variants
Tools
Aperçu
Utiliser un pare-feu local est toujours une bonne pratique. Même si vous utiliser un pare-feu réseau, votre pare-feu local vous protège des menaces internes à votre réseau.
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.
Installer UFW
You can install the ufw
package using you favorite package manager or the command:
Once UFW is installed you need to start and enable it using the commands:
Ajout d'une règle
Pour afficher la configuration actuelle, vous pouvez utiliser la commande suivante : ufw status
. Voici à quoi cela ressemble dans une nouvelle installation :
$ sudo ufw status verbose
Status: active Logging: on (low) Default: deny (incoming), allow (outgoing), disabled (routed) New profiles: skip
Cela indique que le trafic entrant sera bloqué et que le trafic sortant sera autorisé. C'est un bon point de départ pour la plupart des systèmes de bureau. Cependant, il est souvent nécessaire d'autoriser une partie du trafic entrant. Pour ce faire, utilisez la commande suivante : ufw allow
.Par exemple, si nous voulons autoriser le trafic ssh entrant afin de pouvoir nous connecter à la machine à partir d'autres machines du réseau, nous pouvons utiliser la commande :
Si nous voulions également établir des connexions TCP vers un serveur Web local sur un port https 8443 (ce n'est pas le port standard pour https), nous pourrions utiliser la commande :
UFW and Applications
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:
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 ufw app info
. For example, to the configuration for ssh:
$ sudo ufw app info SSH
Profile: SSH Title: SSH server Description: SSH server Port: 22/tcp
Some additional preconfigured applications can be added by installing the package ufw-extras
with your favorite package manager or the command:
Removing Rules
Rules can be removed with the ufw delete
command. For example, to delete our 8443 rules we could use the command:
You can also delete them by number. This is easier if you have a numbered list which you can see with the command:
$ sudo ufw status numbered
Status: active To Action From -- ------ ---- [ 1] 22 ALLOW IN Anywhere [ 2] 22 (v6) ALLOW IN Anywhere (v6)
Now if we wanted to stop allowing ssh on ipv6 we could use the command:
GUFW
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.
If it is not installed already gufw can be installed from the repos:
It will now be available in the menu as Firewall Configuration or by running gufw
directly.
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 below. Here are some basics to get you started.
To enable loading rules on startup you can use the command:
This will load the rules from the file /etc/iptables/iptables.rules
.
To display the currently loaded rules:
To save the current rules to a file
To load the rules from a file
To allow ssh connections
See Also
- The Arch Wiki on UFW
- The UFW website
- The GUFW website
- The iptables man page
- The Arch Wiki on iptables
- The Debian Wiki on iptables