This works:
sudo iptables -A OUTPUT -m owner --uid-owner {USERNAME} -j REJECT
to block internet for a specific user. But it's not permanent.
What's the easiest way to make this persistent after a reboot, with newer systems (with systemd
)?
Creating a specific .service
file is always tricky and takes some time to figure out: one-shot? stoppable? forking? etc. and many other options, so I was wondering what is the most natural way to persist a iptables
rule with new systems.
iptables-save >/etc/sysconfig/iptables
. But if you have firewalld service, you shouldn't use both and need to disable that and enableiptables-services
service. – binarysta Apr 25 '20 at 15:00iptables-persistent
, and you're done, no? – Vlastimil Burián Apr 25 '20 at 15:03iptables command
the rule will be disabled but in the next boot the rules will be read from the file, so you have all your rules. – binarysta Apr 25 '20 at 15:33