firewall/zones/adherent.nft

49 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2018-10-14 16:49:38 +00:00
#! /sbin/nft -f
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
table inet firewall {
2019-03-30 13:36:03 +00:00
chain to_adherent {
2019-02-09 09:23:05 +00:00
accept
2018-10-14 16:49:38 +00:00
}
2019-03-30 13:36:03 +00:00
chain from_adherent {
2018-10-14 16:49:38 +00:00
}
}
2019-01-07 22:48:42 +00:00
2019-02-09 09:23:05 +00:00
table ip nat {
2019-01-08 23:21:24 +00:00
# On nate les users derrière les IPs 193.48.225.11 à 193.48.225.140 en
2019-01-07 22:48:42 +00:00
# attribuant les plages de ports 11135-65535 par tranche de 1700 ports.
# On a donc 32 Ips de 10.69.0.0/20 derrière chaque Ip.
2019-02-09 09:23:05 +00:00
# exemple: 10.69.0.1-10.69.0.31 : 193.48.225.11
# On peut aussi ajouter dynamiquement des éléments :
# nft add element nat adherent_nat_address {10.69.0.1-10.69.0.31 : 193.48.225.11}
2019-01-07 22:48:42 +00:00
map adherent_nat_address {
type ipv4_addr: ipv4_addr
2019-03-12 21:06:21 +00:00
flags interval
2019-01-07 22:48:42 +00:00
}
2019-03-26 21:02:43 +00:00
chain adherent_nat {
# Le script crée 32 sets et y répartit les adresses privées, puis
# crée 2*32 lignes correspondantes de la forme de celles qui suivent
# en matchant sur les sets précédents...
# ip saddr @adherent_nat_grp1 ip protocol tcp snat ip saddr map @adherent_nat_address : 11135-12834
# ip saddr @adherent_nat_grp1 ip protocol udp snat ip saddr map @adherent_nat_address : 11135-12834
2019-01-07 22:48:42 +00:00
}
}