Powered By Blogger

Sunday, 19 April 2015

configure iptables on startup Ubuntu Server

1. vim /etc/network/if-pre-up.d/iptablesload

#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0

save and exit

2. vim /etc/network/if-post-down.d/iptablessave

#!/bin/sh
iptables-save -c > /etc/iptables.rules
if [ -f /etc/iptables.downrules ]; then
   iptables-restore < /etc/iptables.downrules
fi
exit 0

save and exit

3. chmod +x /etc/network/if-post-down.d/iptablessave
4. chmod +x /etc/network/if-pre-up.d/iptablesload

No comments:

Post a Comment