implement new getgwip func
This commit is contained in:
@@ -129,10 +129,16 @@ function getIps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getGwIp {
|
function getGwIp {
|
||||||
gwip=$(netstat -nr | grep 46.227.224 | awk '{ print $2 }')
|
ROUTE=$(route -n get 46.227.224.0 2>/dev/null | awk '/interface: / {print $2}')
|
||||||
if [[ ${gwip} == '0.0.0.0' ]]; then
|
if [ -n "$ROUTE" ]; then
|
||||||
error 'Cannot identify the gateway IP - please contact your IT-Helpdesk'
|
ifconfig "$ROUTE" |grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'
|
||||||
cleanup 1
|
else
|
||||||
|
for i in $(ifconfig -s | awk '{print $1}' | awk '{if(NR>1)print}')
|
||||||
|
do
|
||||||
|
if [[ $i != *"vboxnet"* ]]; then
|
||||||
|
ifconfig "$i" |grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,8 +149,7 @@ function setRoute {
|
|||||||
if command -v ip &> /dev/null; then
|
if command -v ip &> /dev/null; then
|
||||||
sudo ip route add ${ip_route} dev ppp0
|
sudo ip route add ${ip_route} dev ppp0
|
||||||
elif command -v netstat &> /dev/null; then
|
elif command -v netstat &> /dev/null; then
|
||||||
getGwIp
|
sudo route add ${ip_route} $(getGwIp)
|
||||||
sudo route add ${ip_route} ${gwip}
|
|
||||||
else
|
else
|
||||||
error 'Please install iproute2 or net-tools'
|
error 'Please install iproute2 or net-tools'
|
||||||
cleanup 1
|
cleanup 1
|
||||||
|
|||||||
Reference in New Issue
Block a user