Bonjour. Je ne vois pas comment faire un postrouting avec firewalld. Désolé je suis débutant. Je pose la question ici car les raspi utilisent iptables, et ne connaissent pas firewalld. Je crois qu'il n'y a que fedora pour bien connaître ce système.
Configuration du routeur raspi maison:
Internet vient sur eth0
eth1 et wlan0 représente le LAN
J'ai trouvé un très bel article:
https://www.linuxtricks.fr/wiki/firewalld-le-pare-feu-facile-sous-linux
J'ai presque trouvé à la fin mais ça ne doit pas être tout à fait ça.
En commande à passer en iptables j'ai
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.50.0/24 -j MASQUERADE
sudo iptables-save | sudo tee /etc/iptables/rules.v4
Comme on le voit ici:
https://unix.stackexchange.com/questions/539828/how-to-use-postrouting-snat-with-firewalld
#!/bin/bash
# Assuming that your Linux box has two NICs; eth0 attached to WAN and eth1 attached to LAN
# eth0 = outside
# eth1 = inside
# [LAN]----> eth1[GATEWAY]eth0 ---->WAN
# Run the following commands on LINUX box that will act as a firewall or NAT gateway
firewall-cmd --query-interface=eth0
firewall-cmd --query-interface=eth1
firewall-cmd --get-active-zone
firewall-cmd --add-interface=eth0 --zone=external
firewall-cmd --add-interface=eth1 --zone=internal
firewall-cmd --zone=external --add-masquerade --permanent
firewall-cmd --reload
firewall-cmd --zone=external --query-masquerade
# ip_forward is activated automatically if masquerading is enabled.
# To verify:
cat /proc/sys/net/ipv4/ip_forward
# set masquerading to internal zone
firewall-cmd --zone=internal --add-masquerade --permanent
firewall-cmd --reload
firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -o eth0 -j MASQUERADE
firewall-cmd --direct --add-rule ipv4 filter FORWARD 0 -i eth0 -o eth1 -j ACCEPT
firewall-cmd --direct --add-rule ipv4 filter FORWARD 0 -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
firewall-cmd --reload
Normalement ça devrait être Ça mais je ne suis pas sur de mon coup. Et comment ajouter wlan0 ?
Quand je fais:
root@serveur-maison:~# firewall-cmd --add-interface=eth0 --zone=external
Error: COMMAND_FAILED: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.8.2 (nf_tables): Chain 'INPUT_ZONES' does not exist
Donc là, il faudrait invalider iptables.