Subversion Repositories ALCASAR

Rev

Rev 3008 | Rev 3214 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3008 Rev 3190
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-watchdog.sh 3008 2022-05-06 17:22:52Z rexy $
2
# $Id: alcasar-watchdog.sh 3190 2024-04-07 22:35:03Z rexy $
3
 
3
 
4
# alcasar-watchdog.sh
4
# alcasar-watchdog.sh
5
# by Rexy
5
# by Rexy
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
# - Ce script prévient les usagers de l'indisponibilité de l'accès Internet
7
# - Ce script prévient les usagers de l'indisponibilité de l'accès Internet
Line 80... Line 80...
80
			systemctl restart network
80
			systemctl restart network
81
		else
81
		else
82
			if [ "$MULTIWAN" == "off" ] || [ "$MULTIWAN" == "Off" ]
82
			if [ "$MULTIWAN" == "off" ] || [ "$MULTIWAN" == "Off" ]
83
				then
83
				then
84
				IP_GW=`/sbin/ip route list|grep ^default|cut -d" " -f3`
84
				IP_GW=`/sbin/ip route list|grep ^default|cut -d" " -f3`
85
				arp_reply=`/usr/sbin/arping -I$EXTIF -c1 $IP_GW|grep response|cut -d" " -f2`
85
				arp_reply=`LANG=en_US.UTF-8 /usr/sbin/arping -I$EXTIF -c1 $IP_GW|grep response|cut -d" " -f2`
86
				if [ $arp_reply -eq "0" ]
86
				if [ $arp_reply -eq "0" ]
87
					then
87
					then
88
					LAN_DOWN="2"
88
					LAN_DOWN="2"
89
				fi
89
				fi
90
			fi
90
			fi
Line 162... Line 162...
162
				fi
162
				fi
163
			fi
163
			fi
164
			# IP usurpation test : process only equipment with an authenticated user
164
			# IP usurpation test : process only equipment with an authenticated user
165
			if [[ $(expr $active_session) -eq 1 ]]
165
			if [[ $(expr $active_session) -eq 1 ]]
166
			then
166
			then
167
				arp_reply=`/usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c1 -w4 $active_ip|grep -c "Unicast reply"`
167
				arp_reply=`LANG=en_US.UTF-8 /usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c1 -w4 $active_ip|grep -c "Unicast reply"`
168
				# disconnect users whose equipement is usurped. For example, if there are 2 same @MAC it will make 2 lines in output.
168
				# disconnect users whose equipement is usurped. For example, if there are 2 same @MAC it will make 2 lines in output.
169
				if [[ $(expr $arp_reply) -gt 1 ]]
169
				if [[ $(expr $arp_reply) -gt 1 ]]
170
					then 
170
					then 
171
					echo "[$(date +"%Y-%m-%d %H:%M:%S")] : alcasar-watchdog : $active_ip is usurped ($active_mac). Alcasar disconnect the user ($active_user)." >> /var/Save/security/watchdog.log
171
					echo "[$(date +"%Y-%m-%d %H:%M:%S")] : alcasar-watchdog : $active_ip is usurped ($active_mac). Alcasar disconnect the user ($active_user)." >> /var/Save/security/watchdog.log
172
					logger -t alcasar-watchdog "$active_ip is usurped ($active_mac). Alcasar disconnect the user ($active_user)."
172
					logger -t alcasar-watchdog "$active_ip is usurped ($active_mac). Alcasar disconnect the user ($active_user)."