Skip to content

Instantly share code, notes, and snippets.

@kindejak
Created November 16, 2023 18:41
Show Gist options
  • Select an option

  • Save kindejak/139820ab59a88245a7c5b0449e970da8 to your computer and use it in GitHub Desktop.

Select an option

Save kindejak/139820ab59a88245a7c5b0449e970da8 to your computer and use it in GitHub Desktop.
#!/bin/bash
## save existing rules
sudo iptables-save > ~/iptables-rules
## modify rules, remove drop and reject lines
grep -v "DROP" iptables-rules > tmpfile && mv tmpfile iptables-rules-mod
grep -v "REJECT" iptables-rules-mod > tmpfile && mv tmpfile iptables-rules-mod
## apply the modifications
sudo iptables-restore < ~/iptables-rules-mod
## check
sudo iptables -L
## save the changes
sudo netfilter-persistent save
sudo systemctl restart iptables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment