Advertisement
micsoftvn

Untitled

Feb 23rd, 2021
1,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement