[email protected] webmail now available. Want one? Go here.
Windows getting boring or just want to try something Open Source for your next Desktop Environment?! Go Zorin OS.
Paste
Pasted as Bash by registered user Sam ( 7 months ago )
#!/bin/bash
HOSTNAME=.freeddns.com
LOGFILE=/var/log/sam_firewall.log
touch /var/log/sam_firewall.log
chmod 740 /var/log/sam_firewall.log
chown root:adm /var/log/sam_firewall.log
Current_IP=$(host $HOSTNAME | cut -f4 -d' ')
if [[ $(iptables --list | grep $Current_IP) = "" ]]; then
if [[ $LOGFILE = "" ]] ; then
iptables -I INPUT -i eth0 -s $Current_IP -j ACCEPT
else
Old_IP=$(cat $LOGFILE)
if [[ $Old_IP != $Current_IP ]] ; then
if [[ $(iptables --list | grep $Old_IP) = "" ]] ; then
echo ''
else
iptables -D INPUT -i eth0 -s $Old_IP -j ACCEPT
fi
fi
iptables -I INPUT -i eth0 -s $Current_IP -j ACCEPT
fi
fi
echo $Current_IP > $LOGFILE
Revise this Paste