#!/bin/bash # brezular v0.1 function show_choices { echo -e "\n*** Script configures iptables to allow ***" echo -e "*** established connection on eth0 and ppp0 interfaces ***" echo -e "*** input connection from wlan0 interface to anywhere ***\n" echo -e "a) Enable firewall" echo -e "b) Disable firewall" echo -e "q) Quit script\n" } function set_filter { /usr/local/sbin/iptables -F INPUT if [ "$1" == "enable" ]; then /usr/local/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT /usr/local/sbin/iptables -A INPUT -i wlan0 -j ACCEPT /usr/local/sbin/iptables -P INPUT DROP elif [ "$1" == "disable" ]; then /usr/local/sbin/iptables -P INPUT ACCEPT fi /usr/local/sbin/iptables-save > /usr/local/etc/iptables/iptables.rules } uid="$UID" [ "$uid" != 0 ] && echo -e "\nRun '$0' as root, exiting" && exit 1 while true; do show_choices read val case $val in a) set_filter enable /usr/bin/filetool.sh -b 1>/dev/null echo -e "\n*** Firewall successfully enabled ***" ;; b) set_filter disable /usr/bin/filetool.sh -b 1>/dev/null echo -e "\n*** Firewall successfully disabled ***" ;; q) exit 0 ;; *) echo -e "\n*** Please, enter valid option ***" ;; esac done