|
@@ -0,0 +1,26 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+HOSTNAME=barmedjpro.ddns.net
|
|
3
|
+LOGFILE=/var/log/djalel_ip.log
|
|
4
|
+Current_IP=$(host $HOSTNAME | head -n1 | cut -f4 -d ' ')
|
|
5
|
+
|
|
6
|
+##ispconfig et ssh
|
|
7
|
+if [ ! -f $LOGFILE ]; then
|
|
8
|
+ /usr/sbin/ufw allow from $Current_IP to any port 222 proto tcp
|
|
9
|
+ /usr/sbin/ufw allow from $Current_IP to any port 8080 proto tcp
|
|
10
|
+ echo $Current_IP > $LOGFILE
|
|
11
|
+else
|
|
12
|
+
|
|
13
|
+ Old_IP=$(cat $LOGFILE)
|
|
14
|
+ if [ "$Current_IP" = "$Old_IP" ] ; then
|
|
15
|
+ echo IP address has not changed
|
|
16
|
+ else
|
|
17
|
+ /usr/sbin/ufw delete allow from $Old_IP to any port 222 proto tcp
|
|
18
|
+ /usr/sbin/ufw delete allow from $Old_IP to any port 8080 proto tcp
|
|
19
|
+
|
|
20
|
+ /usr/sbin/ufw allow from $Current_IP to any port 222 proto tcp
|
|
21
|
+ /usr/sbin/ufw allow from $Current_IP to any port 8080 proto tcp
|
|
22
|
+ echo $Current_IP > $LOGFILE
|
|
23
|
+ echo iptables have been updated
|
|
24
|
+ echo "L'ip Djalel à changé : ""$Current_IP" | mail -s "Ip Djalel à changé" srv-log@logipro.com
|
|
25
|
+ fi
|
|
26
|
+fi
|