-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathip.sh
More file actions
25 lines (21 loc) · 680 Bytes
/
ip.sh
File metadata and controls
25 lines (21 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
octet=`echo $1 | cut -d "." -f4`
range=`echo $1 | cut -d "." -f1,2,3`
check_range(){
if [ -z $1 ]; then
echo "No ip entered....exiting"
exit 0
fi
if [ $octet -le 61 ]; then
echo "GATEWAY="$range".62"
elif [[ $octet -ge 63 && $octet -le 125 ]]; then
echo "GATEWAY="$range".126"
elif [[ $octet -ge 127 && $octet -le 189 ]]; then
echo "GATEWAY="$range".190"
else
echo "GATEWAY="$range".254"
fi
}
echo "IPADDR=$1"
check_range $1
echo "NETMASK=255.255.255.192"