Last active
September 19, 2016 17:48
-
-
Save tolitski/41513429999a15cc72eb66d97c8a3fcf to your computer and use it in GitHub Desktop.
Firewall to be stored in /etc/init.d as filename firewall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: iptables | |
# Required-Start: $remote_fs | |
# Required-Stop: $remote_fs | |
# Should-Start: $network $syslog | |
# Should-Stop: $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Firewall script | |
# Description: Start iptables-based firewall | |
### END INIT INFO | |
RETVAL=0 | |
do_start() { | |
/etc/firewall.sh | |
/etc/init.d/fail2ban restart | |
RETVAL=0 | |
} | |
do_stop() { | |
/etc/flush_iptables.sh | |
/etc/init.d/fail2ban restart | |
RETVAL=0 | |
} | |
case $1 in | |
start) | |
do_start | |
;; | |
stop) | |
do_stop | |
;; | |
restart) | |
do_stop | |
do_start | |
;; | |
status) | |
/sbin/iptables -L | |
RETVAL=0 | |
;; | |
*) | |
echo "Usage: firewall {start|stop|restart|status}" | |
RETVAL=1 | |
esac | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment