script knows your LAN Ip range
This commit is contained in:
parent
3b5ebbe665
commit
e18448d1d5
31
script.sh
31
script.sh
@ -8,36 +8,47 @@ printf "Do you want to set up firewall rules by iptables? [Y/n]: "
|
|||||||
read ansFirewallSetup
|
read ansFirewallSetup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [[ "$ansFirewallSetup" =~ ("N"|"n") ]]; then
|
if [[ "$ansFirewallSetup" =~ ("N"|"n") ]]; then
|
||||||
|
|
||||||
printf "+ Thanks, working on next bit\n"
|
printf "+ Thanks, working on next bit\n"
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
printf "Do you want to block non-LAN ssh connections? [Y/n/ip range]: "
|
printf "Do you want to block non-LAN ssh connections? [Y/n/castom]: "
|
||||||
read sshBlockRange
|
read sshBlockRange
|
||||||
|
|
||||||
|
|
||||||
if [[ $sshBlockRange =~ ("n"|"N") ]]; then
|
if [[ $sshBlockRange =~ ("n"|"N") ]]; then
|
||||||
|
|
||||||
#$sshBlockRange = ""
|
printf "+ OK, working on next bit\n"
|
||||||
printf 'N\n'
|
ipList=""
|
||||||
|
|
||||||
elif [[ $sshBlockRange =~ ("y"|"Y") || -z $sshBlockRange ]]; then
|
elif [[ $sshBlockRange =~ ("y"|"Y") || -z $sshBlockRange ]]; then
|
||||||
|
|
||||||
### Have to found how to locate LAN
|
#Pipes all informations about ip interfaces
|
||||||
#$sshBlockRange = "y"
|
ipList=$(ip -o -4 a show scope global)
|
||||||
printf 'Y\n'
|
|
||||||
|
#Founds data in pattern
|
||||||
|
ipList=$(echo $ipList | grep -Eo "([0-9]*\.){3}[0-9]*/[0-9]*")
|
||||||
|
|
||||||
|
#substitues space for coma
|
||||||
|
ipList=$(echo $ipList | tr " " ",")
|
||||||
|
|
||||||
|
printf "+ Accepting SSH connections only on these ip's: $ipList\n"
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
printf "\nHope you know what you are doing, I am not checking these :]"
|
printf "\nHope you know what you are doing, I am not checking these :]"
|
||||||
printf "\nyou typed $sshBlockRange"
|
|
||||||
sleep 2
|
printf "\nSubmit your IP range to acces SSH in format 192.168.1.1/24
|
||||||
printf "\nDont worry you will have time to chack if it is looking righ later.\n"
|
\nYour IP range: "
|
||||||
|
read ipList
|
||||||
|
printf "\n+ Allowing SSH on this range: $ipList \n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
|
||||||
# Just to be shure
|
# Just to be shure
|
||||||
printf "\n+ Starting to upgrade base system\n\n"
|
printf "\n+ Starting to upgrade base system\n\n"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user