Browse Source

Auto loading rules

Vova Tkach 6 years ago
parent
commit
b756afdf1d
1 changed files with 11 additions and 0 deletions
  1. 11 0
      iptables-write

+ 11 - 0
iptables-write

@@ -1,4 +1,15 @@
 #!/bin/sh
 
+# Save current rules to file
 iptables-save > /etc/iptables.up.rules
 cat /etc/iptables.up.rules
+
+# Add auto load at server startup
+ifprefile="/etc/network/if-pre-up.d/iptables-load"
+if [ ! -f "$ifprefile" ]; then
+	touch $ifprefile
+	echo "#!/bin/sh" > $ifprefile
+	echo "" > $ifprefile
+	echo "/sbin/iptables-restore < /etc/iptables.up.rules" > $ifprefile
+	chmod 0744 $ifprefile
+fi