Subversion Repositories ALCASAR

Rev

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

Rev 2980 Rev 2981
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 2980 2021-07-22 22:31:38Z rexy $
2
#  $Id: alcasar.sh 2981 2021-07-23 14:37:14Z rexy $
3
 
3
 
4
# ALCASAR is a Free and open source NAC (Network Access Controler) created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
4
# ALCASAR is a Free and open source NAC (Network Access Controler) created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
5
# ALCASAR is based on a stripped Mageia (LSB) with the following open source softwares Coovachilli, freeradius, mariaDB, lighttpd, php, netfilter, e2guardian, ntpd, openssl, dnsmasq, unbound, gammu, clamav, Ulog, fail2ban, vnstat, wkhtml2pdf, ipt_NETFLOW, NFsen and NFdump
5
# ALCASAR is based on a stripped Mageia (LSB) with the following open source softwares Coovachilli, freeradius, mariaDB, lighttpd, php, netfilter, e2guardian, ntpd, openssl, dnsmasq, unbound, gammu, clamav, Ulog, fail2ban, vnstat, wkhtml2pdf, ipt_NETFLOW, NFsen and NFdump
6
# contact : info@alcasar.net
6
# contact : info@alcasar.net
7
 
7
 
Line 230... Line 230...
230
########################################################
230
########################################################
231
testing_network()
231
testing_network()
232
{
232
{
233
# Detect external/internal interfaces
233
# Detect external/internal interfaces
234
	if [ -z "$EXTIF" ]; then
234
	if [ -z "$EXTIF" ]; then
235
		EXTIF=$(/usr/sbin/ip route list | awk '/^default / {print $5}')
235
		EXTIF=$(/usr/sbin/ip route list | awk '/ via / {print $5}' | uniq)
236
		if [ -z "$EXTIF" ]; then
236
		if [ -z "$EXTIF" ]; then
237
			if [ "$Lang" == 'fr' ]
237
			if [ "$Lang" == 'fr' ]
238
				then echo "Aucune passerelle par défaut configurée"
238
				then echo "Aucune passerelle par défaut configurée"
239
				else echo "No default gateway configured"
239
				else echo "No default gateway configured"
240
			fi
240
			fi
Line 332... Line 332...
332
	fi
332
	fi
333
	echo -n "."
333
	echo -n "."
334
# Test EXTIF config files
334
# Test EXTIF config files
335
	PUBLIC_IP_MASK=`/usr/sbin/ip addr show $EXTIF | grep '^\s*inet\s' | awk '{ print $2 }'`
335
	PUBLIC_IP_MASK=`/usr/sbin/ip addr show $EXTIF | grep '^\s*inet\s' | awk '{ print $2 }'`
336
	PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d'/' -f1`
336
	PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d'/' -f1`
337
	PUBLIC_GATEWAY=`/usr/sbin/ip route list | awk -v EXTIF="$EXTIF" '(/^default / && $5 == EXTIF) {print $3}'`
337
	PUBLIC_GATEWAY=`/usr/sbin/ip route list | awk -v EXTIF="$EXTIF" '(/ via / && $5 == EXTIF) {print $3}' | head -n 1`
338
	if [ "$(echo $PUBLIC_IP|wc -c)" -lt 7 ] || [ "$(echo $PUBLIC_GATEWAY|wc -c)" -lt 7 ]
338
	if [ "$(echo $PUBLIC_IP|wc -c)" -lt 7 ] || [ "$(echo $PUBLIC_GATEWAY|wc -c)" -lt 7 ]
339
	then
339
	then
340
		if [ $Lang == "fr" ]
340
		if [ $Lang == "fr" ]
341
		then
341
		then
342
			echo -e "\nÉchec"
342
			echo -e "\nÉchec"
Line 357... Line 357...
357
		echo "DNS2="
357
		echo "DNS2="
358
		echo "ONBOOT=yes"
358
		echo "ONBOOT=yes"
359
		exit 1
359
		exit 1
360
	fi
360
	fi
361
	echo -n "."
361
	echo -n "."
362
# Test if default GW is set on EXTIF (router or ISP provider equipment)
-
 
363
	if [ "$(/usr/sbin/ip route list|grep " $EXTIF "|grep -c '^default ')" -ne 1 ] ; then
-
 
364
		if [ $Lang == "fr" ]
-
 
365
		then
-
 
366
			echo -e "\nÉchec"
-
 
367
			echo "Vous n'avez pas configuré l'accès à Internet ou le câble réseau n'est pas sur la bonne carte."
-
 
368
			echo "Réglez ce problème puis relancez ce script."
-
 
369
		else
-
 
370
			echo -e "\nFailed"
-
 
371
			echo "You haven't configured Internet access or Internet link is on the wrong Ethernet card"
-
 
372
			echo "Resolv this problem, then restart this script."
-
 
373
		fi
-
 
374
		exit 1
-
 
375
	fi
-
 
376
	echo -n "."
-
 
377
# Test if default GW is alive
362
# Test if default GW is alive
378
	arp_reply=`/usr/sbin/arping -b -I$EXTIF -c1 -w2 $PUBLIC_GATEWAY|grep response|cut -d" " -f2`
363
	arp_reply=`/usr/sbin/arping -b -I$EXTIF -c1 -w2 $PUBLIC_GATEWAY|grep response|cut -d" " -f2`
379
	if [ "$(expr $arp_reply)" -eq 0 ]
364
	if [ "$(expr $arp_reply)" -eq 0 ]
380
		then
365
		then
381
		if [ $Lang == "fr" ]
366
		if [ $Lang == "fr" ]