Auf die Schnelle

Tags:
Date October 11, 2007

Dynamische IP in firewall verwenden:

#!/bin/bash
HOST=nichtaufdienervengehenbitte.de
FILE1=/root/ip
FILE2=/root/ipold
PORT=22
ping -c 1 $HOST | head -1 | awk {’print $3′} | sed ’s/(//’ | sed ’s/)//’ >  $FILE1
ip=`cat $FILE1`
ip2=`cat $FILE2`

if [ -f /root/ipold ]
then
/sbin/iptables -D INPUT -s $ip2 -m tcp -p tcp –dport $PORT -j ACCEPT
fi

/sbin/iptables -I INPUT -s $ip -m tcp -p tcp –dport $PORT -j ACCEPT
cp -a /root/ip /root/ipold

Ja, ja kann man besser machen und Ihr seid alle so geil blabla.



2 Responses to “Auf die Schnelle”

  1. root said:

    Also wenn schon dann einfach

    sed ’s/(\|)//’

    aber warum nicht gleich

    dig +short $HOST

    und dass mit FILE1 und FILE2 hast du auch nicht gerade lang durchgehalten, naja vielleicht das nächste mal, ich bin so geil so toll blabla

    <;-)

  2. kero said:

    Kommt, kommt, aber danke fuer dig+short kannte ich nicht

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>