|
@@ -146,7 +146,7 @@
|
|
</li>
|
|
</li>
|
|
<li class="toctree-l4"><a class="reference internal" href="#les-services">Les services</a>
|
|
<li class="toctree-l4"><a class="reference internal" href="#les-services">Les services</a>
|
|
</li>
|
|
</li>
|
|
- <li class="toctree-l4"><a class="reference internal" href="#etat-des-lieux">Etat des lieux</a>
|
|
|
|
|
|
+ <li class="toctree-l4"><a class="reference internal" href="#etat-des-lieux">État des lieux</a>
|
|
</li>
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
</li>
|
|
</li>
|
|
@@ -203,15 +203,15 @@
|
|
<div role="main">
|
|
<div role="main">
|
|
<div class="section">
|
|
<div class="section">
|
|
|
|
|
|
- <h1 id="le-pare-feux">Le pare-feux</h1>
|
|
|
|
-<p>Il nous faut installer un pare-feux sur notre raspi pour éviter les intrusions.</p>
|
|
|
|
|
|
+ <h1 id="le-pare-feu">Le pare-feu</h1>
|
|
|
|
+<p>Il nous faut installer un pare-feu sur notre raspi pour éviter les intrusions.</p>
|
|
<p>Nous allons limiter les machines susceptibles de se connecter à celles de notre réseau local, et également limiter les ports accessibles sur notre réseau.</p>
|
|
<p>Nous allons limiter les machines susceptibles de se connecter à celles de notre réseau local, et également limiter les ports accessibles sur notre réseau.</p>
|
|
<p>Nous allons utiliser IPtables et Firewalld.</p>
|
|
<p>Nous allons utiliser IPtables et Firewalld.</p>
|
|
<p>J'aurai préféré utiliser <strong>nftables</strong> qui est le successeur de <strong>iptables</strong>, mais j'ai eu quelques soucis à l'utilisation. Peut-être est-ce pour ça que la distribution RaspiOS a configuré <strong>firewalld</strong> avec <strong>IPtables</strong>...</p>
|
|
<p>J'aurai préféré utiliser <strong>nftables</strong> qui est le successeur de <strong>iptables</strong>, mais j'ai eu quelques soucis à l'utilisation. Peut-être est-ce pour ça que la distribution RaspiOS a configuré <strong>firewalld</strong> avec <strong>IPtables</strong>...</p>
|
|
<h2 id="installation-de-iptables">Installation de IPtables</h2>
|
|
<h2 id="installation-de-iptables">Installation de IPtables</h2>
|
|
-<p>IPtables est installé par défaut: rien à faire ici.</p>
|
|
|
|
|
|
+<p>IPtables est installé par défaut : rien à faire ici.</p>
|
|
<h2 id="test">Test</h2>
|
|
<h2 id="test">Test</h2>
|
|
-<p>Si on tape: </p>
|
|
|
|
|
|
+<p>Si on tape : </p>
|
|
<pre><code>pi@raspberrypi:~ $ sudo iptables -L
|
|
<pre><code>pi@raspberrypi:~ $ sudo iptables -L
|
|
Chain INPUT (policy ACCEPT)
|
|
Chain INPUT (policy ACCEPT)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
@@ -220,11 +220,11 @@ Chain FORWARD (policy ACCEPT)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain OUTPUT (policy ACCEPT)
|
|
Chain OUTPUT (policy ACCEPT)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
pi@raspberrypi:~ $
|
|
pi@raspberrypi:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
<p>On voit que c'est iptables qui a été chosi par RaspiOS.</p>
|
|
<p>On voit que c'est iptables qui a été chosi par RaspiOS.</p>
|
|
-<p>D'abord, il faut comprendre comment fonctionne Firewalld. Je me suis basé sur les sites suivants:</p>
|
|
|
|
|
|
+<p>D'abord, il faut comprendre comment fonctionne Firewalld. Je me suis basé sur les sites suivant :</p>
|
|
<ul>
|
|
<ul>
|
|
<li><a href="https://lwn.net/Articles/484506/">lw.net</a></li>
|
|
<li><a href="https://lwn.net/Articles/484506/">lw.net</a></li>
|
|
<li><a href="https://www.certdepot.net/rhel7-get-started-firewalld/">How to get started with Firewalld</a></li>
|
|
<li><a href="https://www.certdepot.net/rhel7-get-started-firewalld/">How to get started with Firewalld</a></li>
|
|
@@ -236,12 +236,12 @@ pi@raspberrypi:~ $
|
|
</ul>
|
|
</ul>
|
|
<p>La documentation de Fedora est la plus compréhensible.</p>
|
|
<p>La documentation de Fedora est la plus compréhensible.</p>
|
|
<h3 id="la-notion-de-zones">La notion de zones</h3>
|
|
<h3 id="la-notion-de-zones">La notion de zones</h3>
|
|
-<p>Firewalld défnit 9 zones qui sont en fait des règles de pare-feux par défaut. Une zone va par exemple bloquer toute entrée sauf SSH, une autre permettre l'accès en HTTP et HTTPS. Ces zones correspondent à des utilisations types, comme un serveur dans une DMZ, ou un serveur <strong>chez soi</strong>, un serveur public etc.</p>
|
|
|
|
|
|
+<p>Firewalld définit 9 zones qui sont en fait des règles de pare-feux par défaut. Une zone va par exemple bloquer toute entrée sauf SSH, une autre permettre l'accès en HTTP et HTTPS. Ces zones correspondent à des utilisations types, comme un serveur dans une DMZ, ou un serveur <strong>chez soi</strong>, un serveur public, etc.</p>
|
|
<p>On peut imaginer une zone <strong>émail</strong> qui ne laisserait passer que les ports spécifiques à l'émail et DNS bien sûr.</p>
|
|
<p>On peut imaginer une zone <strong>émail</strong> qui ne laisserait passer que les ports spécifiques à l'émail et DNS bien sûr.</p>
|
|
<p>Il est possible de créer des zones personnelles.</p>
|
|
<p>Il est possible de créer des zones personnelles.</p>
|
|
<p>Un certain nombre de zones sont prédéfinies. Voyons leur contenu.</p>
|
|
<p>Un certain nombre de zones sont prédéfinies. Voyons leur contenu.</p>
|
|
<h3 id="les-differentes-zones">Les différentes zones</h3>
|
|
<h3 id="les-differentes-zones">Les différentes zones</h3>
|
|
-<p>Les différentes zones sont:</p>
|
|
|
|
|
|
+<p>Les différentes zones sont :</p>
|
|
<ul>
|
|
<ul>
|
|
<li>trusted: non modifiable</li>
|
|
<li>trusted: non modifiable</li>
|
|
<li>home: modifiable</li>
|
|
<li>home: modifiable</li>
|
|
@@ -253,25 +253,25 @@ pi@raspberrypi:~ $
|
|
<li>block: non modifiable</li>
|
|
<li>block: non modifiable</li>
|
|
<li>drop: non modifiable</li>
|
|
<li>drop: non modifiable</li>
|
|
</ul>
|
|
</ul>
|
|
-<p>Une très bonne présentation des zones est ici: <a href="https://www.it-connect.fr/centos-7-utilisation-et-configuration-de-firewalld/">it connect</a></p>
|
|
|
|
|
|
+<p>Une très bonne présentation des zones est ici : <a href="https://www.it-connect.fr/centos-7-utilisation-et-configuration-de-firewalld/">it connect</a></p>
|
|
<h3 id="les-fichiers-de-configuration">Les fichiers de configuration</h3>
|
|
<h3 id="les-fichiers-de-configuration">Les fichiers de configuration</h3>
|
|
-<p>Ils ont situés à 2 endroits:</p>
|
|
|
|
|
|
+<p>Ils sont situés à 2 endroits :</p>
|
|
<ul>
|
|
<ul>
|
|
<li>/usr/lib/firewalld/ : il ne faut pas toucher au contenu de ce répertoire</li>
|
|
<li>/usr/lib/firewalld/ : il ne faut pas toucher au contenu de ce répertoire</li>
|
|
-<li>/etc/firewalld/: c'est là que nous mettrons notre configuration, en copiant les fichiers de /usr/lib/firewalld si besoin est.</li>
|
|
|
|
|
|
+<li>/etc/firewalld/ : c'est là que nous mettrons notre configuration, en copiant les fichiers de /usr/lib/firewalld si besoin est.</li>
|
|
</ul>
|
|
</ul>
|
|
-<p>Dans le répertoire /etc/firewalld, le fichier firewalld.conf permet de configurer la zone par défaut, ainsi que le backtend (iptables, nftables et autre).</p>
|
|
|
|
-<p>La zone par défaut est <strong>public</strong>: pas de confiance, mais possibilité d'ajuster au cas par cas les règles. Le seul accès auorisé est l'accès <strong>ssh</strong> et <strong>dhcp</strong>.</p>
|
|
|
|
|
|
+<p>Dans le répertoire /etc/firewalld, le fichier firewalld.conf permet de configurer la zone par défaut, ainsi que le backend (iptables, nftables et autre).</p>
|
|
|
|
+<p>La zone par défaut est <strong>public</strong> : pas de confiance, mais possibilité d'ajuster au cas par cas les règles. Le seul accès autorisé est l'accès <strong>ssh</strong> et <strong>dhcp</strong>.</p>
|
|
<h3 id="quelques-commandes">Quelques commandes</h3>
|
|
<h3 id="quelques-commandes">Quelques commandes</h3>
|
|
<ul>
|
|
<ul>
|
|
<li>Démarrer Firewalld:<strong>$ sudo systemctl start firewalld</strong></li>
|
|
<li>Démarrer Firewalld:<strong>$ sudo systemctl start firewalld</strong></li>
|
|
<li>Stopper Fireawalld:<strong>$ sudo systemctl stop firewalld</strong></li>
|
|
<li>Stopper Fireawalld:<strong>$ sudo systemctl stop firewalld</strong></li>
|
|
<li>Tester le fonctionnement de Firewalld:<strong>$ sudo firewall-cmd --state</strong></li>
|
|
<li>Tester le fonctionnement de Firewalld:<strong>$ sudo firewall-cmd --state</strong></li>
|
|
-<li>Connaître les zones prédéfinies: <strong>$ sudo firewall-cmd --get-zones</strong></li>
|
|
|
|
-<li>Connaître la zone par défaut:<strong>$ sudo firewall-cmd --get-default-zone</strong></li>
|
|
|
|
-<li>Connaître la zone active:<strong>$ sudo firewall-cmd --get-active-zones</strong></li>
|
|
|
|
|
|
+<li>Connaître les zones prédéfinies : <strong>$ sudo firewall-cmd --get-zones</strong></li>
|
|
|
|
+<li>Connaître la zone par défaut :<strong>$ sudo firewall-cmd --get-default-zone</strong></li>
|
|
|
|
+<li>Connaître la zone active :<strong>$ sudo firewall-cmd --get-active-zones</strong></li>
|
|
</ul>
|
|
</ul>
|
|
-<p>Exemples:</p>
|
|
|
|
|
|
+<p>Exemples :</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --state
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --state
|
|
running
|
|
running
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
@@ -281,17 +281,17 @@ pi@piras:~ $
|
|
public
|
|
public
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>La zone par défaut est: public</p>
|
|
|
|
|
|
+<p>La zone par défaut est : public</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --get-zones
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --get-zones
|
|
block dmz drop external home internal public trusted work
|
|
block dmz drop external home internal public trusted work
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>Les zones prédéfinies sont: <strong>block dmz drop external home internal public trusted work</strong></p>
|
|
|
|
-<p>Quelle est la zone active: aucune!</p>
|
|
|
|
|
|
+<p>Les zones prédéfinies sont : <strong>block dmz drop external home internal public trusted work</strong></p>
|
|
|
|
+<p>Quelle est la zone active : aucune !</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --get-active-zones
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --get-active-zones
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>Nous pouvons vérifier la zone en fonctionnement et l'interface réseau qui y est attachée:</p>
|
|
|
|
|
|
+<p>Nous pouvons vérifier la zone en fonctionnement et l'interface réseau qui y est attachée :</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --list-all
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --list-all
|
|
public
|
|
public
|
|
target: default
|
|
target: default
|
|
@@ -309,12 +309,12 @@ rich rules:
|
|
|
|
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>Aucune interface n'est attachée. Les seuls services autorisé sont: dhcp et ssh.</p>
|
|
|
|
|
|
+<p>Aucune interface n'est attachée. Les seuls services autorisé sont : dhcp et ssh.</p>
|
|
<h3 id="premiere-etape-de-configuration">Première étape de configuration</h3>
|
|
<h3 id="premiere-etape-de-configuration">Première étape de configuration</h3>
|
|
<p>Nous allons utiliser les commandes en ligne de commande pour configurer Firewalld, mais il existe une GUI pour le faire graphiquement. Référez-vous aux liens que j'ai indiqués au-dessus.</p>
|
|
<p>Nous allons utiliser les commandes en ligne de commande pour configurer Firewalld, mais il existe une GUI pour le faire graphiquement. Référez-vous aux liens que j'ai indiqués au-dessus.</p>
|
|
<ul>
|
|
<ul>
|
|
<li>
|
|
<li>
|
|
-<p>Définition de la zone par défaut: (public)</p>
|
|
|
|
|
|
+<p>Définition de la zone par défaut : (public)</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --set-default-zone=public
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --set-default-zone=public
|
|
Warning: ZONE_ALREADY_SET: public
|
|
Warning: ZONE_ALREADY_SET: public
|
|
success
|
|
success
|
|
@@ -322,15 +322,15 @@ pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
</li>
|
|
</li>
|
|
<li>
|
|
<li>
|
|
-<p>Attribution de l'interface réseau à cette zone:</p>
|
|
|
|
|
|
+<p>Attribution de l'interface réseau à cette zone :</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --zone=public --change-interface=eth0
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --zone=public --change-interface=eth0
|
|
success
|
|
success
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>Attention, ce changement n'est pas permanent! (voir ci-dessous)</p>
|
|
|
|
|
|
+<p>Attention, ce changement n'est pas permanent ! (voir ci-dessous)</p>
|
|
</li>
|
|
</li>
|
|
<li>
|
|
<li>
|
|
-<p>Test:</p>
|
|
|
|
|
|
+<p>Test :</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --list-all
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --list-all
|
|
public (active)
|
|
public (active)
|
|
target: default
|
|
target: default
|
|
@@ -353,85 +353,93 @@ pi@piras:~ $
|
|
<p>Nous voyons que l'interface <strong>eth0</strong> a bien été attribuée à la zone <strong>public</strong>.</p>
|
|
<p>Nous voyons que l'interface <strong>eth0</strong> a bien été attribuée à la zone <strong>public</strong>.</p>
|
|
<h3 id="les-services">Les services</h3>
|
|
<h3 id="les-services">Les services</h3>
|
|
<p>Il est possible de configurer les services accessibles (ou pas) attribués à la zone active.</p>
|
|
<p>Il est possible de configurer les services accessibles (ou pas) attribués à la zone active.</p>
|
|
-<p>Pour connaître les différents services disponibles, tapez la commande suivante:</p>
|
|
|
|
|
|
+<p>Pour connaître les différents services disponibles, tapez la commande suivante :</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --get-services
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --get-services
|
|
-RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine cockpit condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server finger freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master git gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kerberos kibana klogin kpasswd kprop kshell ldap ldaps libvirt libvirt-tls lightning-network llmnr managesieve matrix mdns minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius redis rpc-bind rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server
|
|
|
|
|
|
+RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph
|
|
|
|
+ceph-mon cfengine cockpit condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client
|
|
|
|
+etcd-server finger freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master git gre high-availability http https imap imaps
|
|
|
|
+ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kerberos kibana klogin kpasswd kprop kshell ldap ldaps libvirt libvirt-tls lightning-network
|
|
|
|
+llmnr managesieve matrix mdns minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp nut openvpn
|
|
|
|
+ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio
|
|
|
|
+puppetmaster quassel radius redis rpc-bind rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps
|
|
|
|
+snmp snmptrap spideroak-lansync squid ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tftp tftp-client
|
|
|
|
+tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local
|
|
|
|
+xmpp-server zabbix-agent zabbix-server
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
<p>Chaque détail des services est détaillé dans un fichier xml dans /usr/lib/firewalld.</p>
|
|
<p>Chaque détail des services est détaillé dans un fichier xml dans /usr/lib/firewalld.</p>
|
|
-<p>Voyons quels services sont acuellement activés sur notre raspi:</p>
|
|
|
|
|
|
+<p>Voyons quels services sont actuellement activés sur notre raspi :</p>
|
|
<pre><code>pi@piras:~ $ ss -t -u -l -a
|
|
<pre><code>pi@piras:~ $ ss -t -u -l -a
|
|
-Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
|
|
|
|
-udp UNCONN 0 0 0.0.0.0:55853 0.0.0.0:*
|
|
|
|
-udp UNCONN 0 0 127.0.0.1:domain 0.0.0.0:*
|
|
|
|
-udp UNCONN 0 0 0.0.0.0:bootpc 0.0.0.0:*
|
|
|
|
-udp UNCONN 0 0 0.0.0.0:mdns 0.0.0.0:*
|
|
|
|
-udp UNCONN 0 0 [::1]:domain *:*
|
|
|
|
-udp UNCONN 0 0 *:59578 *:*
|
|
|
|
-udp UNCONN 0 0 *:mdns *:*
|
|
|
|
-tcp LISTEN 0 511 127.0.0.1:domain-s 0.0.0.0:*
|
|
|
|
-tcp LISTEN 0 511 127.0.0.1:domain 0.0.0.0:*
|
|
|
|
-tcp LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:*
|
|
|
|
-tcp ESTAB 0 0 192.168.111.170:ssh 192.168.111.150:59092
|
|
|
|
-tcp LISTEN 0 511 [::1]:domain-s [::]:*
|
|
|
|
-tcp LISTEN 0 511 [::1]:domain [::]:*
|
|
|
|
-tcp LISTEN 0 128 [::]:ssh [::]:*
|
|
|
|
|
|
+Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
|
|
|
|
+udp UNCONN 0 0 0.0.0.0:55853 0.0.0.0:*
|
|
|
|
+udp UNCONN 0 0 127.0.0.1:domain 0.0.0.0:*
|
|
|
|
+udp UNCONN 0 0 0.0.0.0:bootpc 0.0.0.0:*
|
|
|
|
+udp UNCONN 0 0 0.0.0.0:mdns 0.0.0.0:*
|
|
|
|
+udp UNCONN 0 0 [::1]:domain *:*
|
|
|
|
+udp UNCONN 0 0 *:59578 *:*
|
|
|
|
+udp UNCONN 0 0 *:mdns *:*
|
|
|
|
+tcp LISTEN 0 511 127.0.0.1:domain-s 0.0.0.0:*
|
|
|
|
+tcp LISTEN 0 511 127.0.0.1:domain 0.0.0.0:*
|
|
|
|
+tcp LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:*
|
|
|
|
+tcp ESTAB 0 0 192.168.111.170:ssh 192.168.111.150:59092
|
|
|
|
+tcp LISTEN 0 511 [::1]:domain-s [::]:*
|
|
|
|
+tcp LISTEN 0 511 [::1]:domain [::]:*
|
|
|
|
+tcp LISTEN 0 128 [::]:ssh [::]:*
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>Nous voyons notre connexion <strong>ssh</strong> établie entre mon desktop en ip 192.168.111.150 et piras 192.168.111.170.</p>
|
|
|
|
|
|
+<p>Nous voyons notre connexion <strong>ssh</strong> établie entre ma machine de travail en ip 192.168.111.150 et piras 192.168.111.170.</p>
|
|
<p>Notre raspi écoute également le port 22 sur toutes les interfaces présentes.</p>
|
|
<p>Notre raspi écoute également le port 22 sur toutes les interfaces présentes.</p>
|
|
-<p>Liste des ports en écoute (TCP):</p>
|
|
|
|
|
|
+<p>Liste des ports en écoute (TCP) :</p>
|
|
<pre><code>pi@piras:~ $ ss -ltn
|
|
<pre><code>pi@piras:~ $ ss -ltn
|
|
-State Recv-Q Send-Q Local Address:Port Peer Address:Port
|
|
|
|
-LISTEN 0 511 127.0.0.1:853 0.0.0.0:*
|
|
|
|
-LISTEN 0 511 127.0.0.1:53 0.0.0.0:*
|
|
|
|
-LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
|
|
|
|
-LISTEN 0 511 [::1]:853 [::]:*
|
|
|
|
-LISTEN 0 511 [::1]:53 [::]:*
|
|
|
|
-LISTEN 0 128 [::]:22 [::]:*
|
|
|
|
|
|
+State Recv-Q Send-Q Local Address:Port Peer Address:Port
|
|
|
|
+LISTEN 0 511 127.0.0.1:853 0.0.0.0:*
|
|
|
|
+LISTEN 0 511 127.0.0.1:53 0.0.0.0:*
|
|
|
|
+LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
|
|
|
|
+LISTEN 0 511 [::1]:853 [::]:*
|
|
|
|
+LISTEN 0 511 [::1]:53 [::]:*
|
|
|
|
+LISTEN 0 128 [::]:22 [::]:*
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>les ports 22 (ssh) , 53 (dns) , 853 (dns) sont à l'écoute en IPV4 et IPV6.</p>
|
|
|
|
-<p>Liste des ports en écoute (UDP):</p>
|
|
|
|
|
|
+<p>Les ports 22 (ssh), 53 (dns), 853 (dns) sont à l'écoute en IPV4 et IPV6.</p>
|
|
|
|
+<p>Liste des ports en écoute (UDP) :</p>
|
|
<pre><code>pi@piras:~ $ ss -lun
|
|
<pre><code>pi@piras:~ $ ss -lun
|
|
-State Recv-Q Send-Q Local Address:Port Peer Address:Port
|
|
|
|
-UNCONN 0 0 0.0.0.0:55853 0.0.0.0:*
|
|
|
|
-UNCONN 0 0 127.0.0.1:53 0.0.0.0:*
|
|
|
|
-UNCONN 0 0 0.0.0.0:68 0.0.0.0:*
|
|
|
|
-UNCONN 0 0 0.0.0.0:5353 0.0.0.0:*
|
|
|
|
-UNCONN 0 0 [::1]:53 *:*
|
|
|
|
-UNCONN 0 0 *:59578 *:*
|
|
|
|
-UNCONN 0 0 *:5353 *:*
|
|
|
|
|
|
+State Recv-Q Send-Q Local Address:Port Peer Address:Port
|
|
|
|
+UNCONN 0 0 127.0.0.1:53 0.0.0.0:*
|
|
|
|
+UNCONN 0 0 0.0.0.0:68 0.0.0.0:*
|
|
|
|
+UNCONN 0 0 0.0.0.0:5353 0.0.0.0:*
|
|
|
|
+UNCONN 0 0 [::1]:53 *:*
|
|
|
|
+UNCONN 0 0 *:59578 *:*
|
|
|
|
+UNCONN 0 0 *:5353 *:*
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<h3 id="etat-des-lieux">Etat des lieux</h3>
|
|
|
|
|
|
+<h3 id="etat-des-lieux">État des lieux</h3>
|
|
<p>Vérifions le fonctionnement de Firewalld. Souvenez-vous qu'il était configuré pour fonctionner avec Iptables.</p>
|
|
<p>Vérifions le fonctionnement de Firewalld. Souvenez-vous qu'il était configuré pour fonctionner avec Iptables.</p>
|
|
-<p>Vérifions les règles établies:</p>
|
|
|
|
|
|
+<p>Vérifions les règles établies :</p>
|
|
<pre><code>pi@piras:~ $ sudo iptables -L
|
|
<pre><code>pi@piras:~ $ sudo iptables -L
|
|
Chain INPUT (policy ACCEPT)
|
|
Chain INPUT (policy ACCEPT)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
|
|
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
|
|
-ACCEPT all -- anywhere anywhere
|
|
|
|
-INPUT_direct all -- anywhere anywhere
|
|
|
|
-INPUT_ZONES_SOURCE all -- anywhere anywhere
|
|
|
|
-INPUT_ZONES all -- anywhere anywhere
|
|
|
|
|
|
+ACCEPT all -- anywhere anywhere
|
|
|
|
+INPUT_direct all -- anywhere anywhere
|
|
|
|
+INPUT_ZONES_SOURCE all -- anywhere anywhere
|
|
|
|
+INPUT_ZONES all -- anywhere anywhere
|
|
DROP all -- anywhere anywhere ctstate INVALID
|
|
DROP all -- anywhere anywhere ctstate INVALID
|
|
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
|
|
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
|
|
|
|
|
|
Chain FORWARD (policy ACCEPT)
|
|
Chain FORWARD (policy ACCEPT)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
|
|
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
|
|
-ACCEPT all -- anywhere anywhere
|
|
|
|
-FORWARD_direct all -- anywhere anywhere
|
|
|
|
-FORWARD_IN_ZONES_SOURCE all -- anywhere anywhere
|
|
|
|
-FORWARD_IN_ZONES all -- anywhere anywhere
|
|
|
|
-FORWARD_OUT_ZONES_SOURCE all -- anywhere anywhere
|
|
|
|
-FORWARD_OUT_ZONES all -- anywhere anywhere
|
|
|
|
|
|
+ACCEPT all -- anywhere anywhere
|
|
|
|
+FORWARD_direct all -- anywhere anywhere
|
|
|
|
+FORWARD_IN_ZONES_SOURCE all -- anywhere anywhere
|
|
|
|
+FORWARD_IN_ZONES all -- anywhere anywhere
|
|
|
|
+FORWARD_OUT_ZONES_SOURCE all -- anywhere anywhere
|
|
|
|
+FORWARD_OUT_ZONES all -- anywhere anywhere
|
|
DROP all -- anywhere anywhere ctstate INVALID
|
|
DROP all -- anywhere anywhere ctstate INVALID
|
|
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
|
|
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
|
|
|
|
|
|
Chain OUTPUT (policy ACCEPT)
|
|
Chain OUTPUT (policy ACCEPT)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
OUTPUT_direct all -- anywhere anywhere
|
|
OUTPUT_direct all -- anywhere anywhere
|
|
|
|
|
|
Chain INPUT_direct (1 references)
|
|
Chain INPUT_direct (1 references)
|
|
@@ -441,7 +449,7 @@ Chain INPUT_ZONES_SOURCE (1 references)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain INPUT_ZONES (1 references)
|
|
Chain INPUT_ZONES (1 references)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
IN_public all -- anywhere anywhere [goto]
|
|
IN_public all -- anywhere anywhere [goto]
|
|
IN_public all -- anywhere anywhere [goto]
|
|
IN_public all -- anywhere anywhere [goto]
|
|
|
|
|
|
@@ -452,7 +460,7 @@ Chain FORWARD_IN_ZONES_SOURCE (1 references)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain FORWARD_IN_ZONES (1 references)
|
|
Chain FORWARD_IN_ZONES (1 references)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
FWDI_public all -- anywhere anywhere [goto]
|
|
FWDI_public all -- anywhere anywhere [goto]
|
|
FWDI_public all -- anywhere anywhere [goto]
|
|
FWDI_public all -- anywhere anywhere [goto]
|
|
|
|
|
|
@@ -460,7 +468,7 @@ Chain FORWARD_OUT_ZONES_SOURCE (1 references)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain FORWARD_OUT_ZONES (1 references)
|
|
Chain FORWARD_OUT_ZONES (1 references)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
FWDO_public all -- anywhere anywhere [goto]
|
|
FWDO_public all -- anywhere anywhere [goto]
|
|
FWDO_public all -- anywhere anywhere [goto]
|
|
FWDO_public all -- anywhere anywhere [goto]
|
|
|
|
|
|
@@ -468,10 +476,10 @@ Chain OUTPUT_direct (1 references)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain IN_public (2 references)
|
|
Chain IN_public (2 references)
|
|
-target prot opt source destination
|
|
|
|
-IN_public_log all -- anywhere anywhere
|
|
|
|
-IN_public_deny all -- anywhere anywhere
|
|
|
|
-IN_public_allow all -- anywhere anywhere
|
|
|
|
|
|
+target prot opt source destination
|
|
|
|
+IN_public_log all -- anywhere anywhere
|
|
|
|
+IN_public_deny all -- anywhere anywhere
|
|
|
|
+IN_public_allow all -- anywhere anywhere
|
|
ACCEPT icmp -- anywhere anywhere
|
|
ACCEPT icmp -- anywhere anywhere
|
|
|
|
|
|
Chain IN_public_log (1 references)
|
|
Chain IN_public_log (1 references)
|
|
@@ -481,14 +489,14 @@ Chain IN_public_deny (1 references)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain IN_public_allow (1 references)
|
|
Chain IN_public_allow (1 references)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh ctstate NEW,UNTRACKED
|
|
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh ctstate NEW,UNTRACKED
|
|
|
|
|
|
Chain FWDI_public (2 references)
|
|
Chain FWDI_public (2 references)
|
|
-target prot opt source destination
|
|
|
|
-FWDI_public_log all -- anywhere anywhere
|
|
|
|
-FWDI_public_deny all -- anywhere anywhere
|
|
|
|
-FWDI_public_allow all -- anywhere anywhere
|
|
|
|
|
|
+target prot opt source destination
|
|
|
|
+FWDI_public_log all -- anywhere anywhere
|
|
|
|
+FWDI_public_deny all -- anywhere anywhere
|
|
|
|
+FWDI_public_allow all -- anywhere anywhere
|
|
ACCEPT icmp -- anywhere anywhere
|
|
ACCEPT icmp -- anywhere anywhere
|
|
|
|
|
|
Chain FWDI_public_log (1 references)
|
|
Chain FWDI_public_log (1 references)
|
|
@@ -501,9 +509,9 @@ Chain FWDI_public_allow (1 references)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain FWDO_public (2 references)
|
|
Chain FWDO_public (2 references)
|
|
-target prot opt source destination
|
|
|
|
-FWDO_public_log all -- anywhere anywhere
|
|
|
|
-FWDO_public_deny all -- anywhere anywhere
|
|
|
|
|
|
+target prot opt source destination
|
|
|
|
+FWDO_public_log all -- anywhere anywhere
|
|
|
|
+FWDO_public_deny all -- anywhere anywhere
|
|
FWDO_public_allow all -- anywhere anywhere
|
|
FWDO_public_allow all -- anywhere anywhere
|
|
|
|
|
|
Chain FWDO_public_log (1 references)
|
|
Chain FWDO_public_log (1 references)
|
|
@@ -513,16 +521,16 @@ Chain FWDO_public_deny (1 references)
|
|
target prot opt source destination
|
|
target prot opt source destination
|
|
|
|
|
|
Chain FWDO_public_allow (1 references)
|
|
Chain FWDO_public_allow (1 references)
|
|
-target prot opt source destination
|
|
|
|
|
|
+target prot opt source destination
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
<p>Les règles Iptables ont bien été configurées par Firewalld.</p>
|
|
<p>Les règles Iptables ont bien été configurées par Firewalld.</p>
|
|
-<p>Après reboot, nous voyons que rien n'a été conservé!</p>
|
|
|
|
|
|
+<p>Après reboot, nous voyons que rien n'a été conservé !</p>
|
|
<p>Il va falloir investiguer ...</p>
|
|
<p>Il va falloir investiguer ...</p>
|
|
-<p>Bien: voilà la procédure à suivre:</p>
|
|
|
|
|
|
+<p>Bien : voilà la procédure à suivre :</p>
|
|
<p>sudo firewall-cmd <strong>--permanent</strong> --zone=public --change-interface=eth0</p>
|
|
<p>sudo firewall-cmd <strong>--permanent</strong> --zone=public --change-interface=eth0</p>
|
|
<p>Permet de changer de façon <strong>permanente</strong> l'interface associée à la zone <strong>public</strong>.</p>
|
|
<p>Permet de changer de façon <strong>permanente</strong> l'interface associée à la zone <strong>public</strong>.</p>
|
|
-<pre><code>Test:
|
|
|
|
|
|
+<pre><code>Test :
|
|
pi@piras:~ $ sudo firewall-cmd --permanent --zone=public --change-interface=eth0
|
|
pi@piras:~ $ sudo firewall-cmd --permanent --zone=public --change-interface=eth0
|
|
success
|
|
success
|
|
|
|
|
|
@@ -556,8 +564,8 @@ rich rules:
|
|
|
|
|
|
pi@piras:~ $
|
|
pi@piras:~ $
|
|
</code></pre>
|
|
</code></pre>
|
|
-<p>Test après reboot</p>
|
|
|
|
-<p>Cette fois-ci, ça marche! (Yes!)</p>
|
|
|
|
|
|
+<p>Test après redémarrage :</p>
|
|
|
|
+<p>Cette fois-ci, ça marche ! (Yes !)</p>
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --list-all
|
|
<pre><code>pi@piras:~ $ sudo firewall-cmd --list-all
|
|
public (active)
|
|
public (active)
|
|
target: default
|
|
target: default
|