micsoftvn

Untitled

Feb 23rd, 2021
749
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Drop your iptables.rules into /etc/iptables.rules
  2. Create service template like so:
  3.  
  4. sudo nano /etc/systemd/system/restore-iptables-rules.service
  5. Copy-paste this:
  6.  
  7. [Unit]
  8. Description = Apply iptables rules
  9.  
  10. [Service]
  11. Type=oneshot
  12. ExecStart=/bin/sh -c 'iptables-restore < /etc/iptables.rules'
  13.  
  14. [Install]
  15. WantedBy=network-pre.target
  16. Enable service like so:
  17.  
  18. sudo systemctl enable restore-iptables-rules.service
  19. Reboot and check that the rules have been applied:
  20.  
  21. sudo iptables -L
RAW Paste Data