2019-03-12 21:06:21 +00:00
|
|
|
#! /usr/sbin/nft -I /usr/local/firewall -f
|
2018-10-14 16:49:38 +00:00
|
|
|
|
2019-12-20 18:18:10 +00:00
|
|
|
# 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 3 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.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# Copyright © 2018-2019 Hugo Levy-Falk <hugo@klafyvel.me>
|
|
|
|
|
2018-10-14 16:49:38 +00:00
|
|
|
# Remise à zéro des règles du pare-feu
|
|
|
|
flush ruleset
|
|
|
|
|
|
|
|
# Inclusion des dépendances
|
|
|
|
include "archi.nft"
|
2019-02-09 09:23:05 +00:00
|
|
|
include "global_policy.nft"
|
2018-10-14 16:49:38 +00:00
|
|
|
include "checkmac.nft"
|
2019-02-09 09:23:05 +00:00
|
|
|
include "zones/adherent.nft"
|
|
|
|
include "zones/aloes.nft"
|
|
|
|
include "zones/federez.nft"
|
|
|
|
include "zones/supelec.nft"
|
|
|
|
include "zones/admin.nft"
|
|
|
|
include "zones/dmz.nft"
|
|
|
|
include "zones/prerezotage.nft"
|
2019-01-08 23:21:24 +00:00
|
|
|
include "nat.nft"
|
2020-01-18 13:23:41 +00:00
|
|
|
include "roulette.nft"
|
2018-10-14 16:49:38 +00:00
|
|
|
|
|
|
|
# Table principale
|
|
|
|
table inet firewall {
|
|
|
|
|
|
|
|
chain dispatch {
|
|
|
|
# Définition de la chaîne. On s'occupe du forward.
|
|
|
|
type filter hook forward priority 0;
|
|
|
|
|
|
|
|
# Politique par défaut : tout jeter.
|
2019-04-29 22:12:26 +00:00
|
|
|
policy accept
|
2018-10-14 16:49:38 +00:00
|
|
|
|
2020-01-18 13:23:41 +00:00
|
|
|
# La roulette pour les n1as
|
|
|
|
jump roulette
|
|
|
|
|
2020-01-20 10:26:04 +00:00
|
|
|
# Applique la politique globale
|
|
|
|
jump global
|
|
|
|
|
2019-03-12 21:06:21 +00:00
|
|
|
# Passage par le checkmac pour les concernés
|
2019-12-20 18:01:35 +00:00
|
|
|
# jump checkmac
|
2019-01-09 12:15:20 +00:00
|
|
|
|
2018-10-14 16:49:38 +00:00
|
|
|
# Filtre sur les interfaces entrantes, ne pas accepter
|
|
|
|
# directement dans la chaine, mais retourner.
|
|
|
|
# Par convention pour le routage, on vérifie dans la chaîne to_ que
|
|
|
|
# le passage d'un vlan à l'autre est autorisé.
|
|
|
|
#
|
|
|
|
# On utilise des jumps pour revenir ici une fois la chaîne évaluée.
|
|
|
|
meta iif vmap {
|
2019-03-30 13:36:03 +00:00
|
|
|
$if_adherent : jump from_adherent,
|
2019-01-08 23:21:24 +00:00
|
|
|
$if_admin : jump from_admin,
|
|
|
|
$if_federez : jump from_federez,
|
|
|
|
$if_supelec : jump from_supelec,
|
|
|
|
$if_aloes : jump from_aloes,
|
|
|
|
$if_prerezotage : jump from_prerezotage,
|
|
|
|
$if_dmz: jump from_dmz
|
2018-10-14 16:49:38 +00:00
|
|
|
}
|
2019-12-03 15:29:33 +00:00
|
|
|
|
2018-10-14 16:49:38 +00:00
|
|
|
# Filtre sur les interfaces sortantes, ne pas retourner : drop ou
|
|
|
|
# accept
|
|
|
|
# On utilise des goto pour ne pas revenir ici une fois la chaîne
|
|
|
|
# évaluée.
|
|
|
|
meta oif vmap {
|
2019-03-30 13:36:03 +00:00
|
|
|
$if_adherent : goto to_adherent,
|
2019-01-08 23:21:24 +00:00
|
|
|
$if_admin : goto to_admin,
|
|
|
|
$if_federez : goto to_federez,
|
|
|
|
$if_supelec : goto to_supelec,
|
|
|
|
$if_aloes : goto to_aloes,
|
|
|
|
$if_prerezotage : goto to_prerezotage,
|
|
|
|
$if_dmz: goto to_dmz
|
2018-10-14 16:49:38 +00:00
|
|
|
}
|
2019-12-03 15:29:33 +00:00
|
|
|
|
2018-10-14 16:49:38 +00:00
|
|
|
# Un compteur qui doit être à 0 si on a bien fait notre travail.
|
|
|
|
counter
|
|
|
|
}
|
|
|
|
|
|
|
|
chain input {
|
|
|
|
type filter hook input priority 0;
|
2019-02-09 09:23:05 +00:00
|
|
|
policy accept;
|
2019-08-19 19:57:49 +00:00
|
|
|
tcp dport {http, https } drop
|
2018-10-14 16:49:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chain output {
|
|
|
|
type filter hook output priority 0;
|
|
|
|
policy accept;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|