#!/bin/bash
#allow a dyndns name
HOSTNAME=MIN DYNDNS ADRESS
LOGFILE=loggfil-for-ip.log
Current_IP=$(host $HOSTNAME | cut -f4 -d' ')
if [ $LOGFILE = "" ] ; then
iptables -I INPUT -i eth0 -s $Current_IP -j ACCEPT
echo $Current_IP > $LOGFILE
else
Old_IP=$(cat $LOGFILE)
if [ "$Current_IP" = "$Old_IP" ] ; then
echo IP address has not changed
else
iptables -D INPUT -i eth0 -s $Old_IP -j ACCEPT
iptables -I INPUT -p tcp -s $Current_IP --dport 21145 -i eth0 -j ACCEPT
iptables -I INPUT -p tcp -s $Current_IP --dport 80 -i eth0 -j ACCEPT
sudo iptables-save > /etc/iptables.rules
echo $Current_IP > $LOGFILE
echo iptables have been updated
fi
fi
Du måste vara medlem för att kunna kommentera