I\'m trying to get the default gateway, using the destination 0.0.0.0
0.0.0.0
I used this command: netstat -rn | grep 0.0.0.0
netstat -rn | grep 0.0.0.0
And it return
This is how I do it:
#!/bin/sh GATEWAY_DEFAULT=$(ip route list | sed -n -e "s/^default.*[[:space:]]\([[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+\).*/\1/p") echo ${GATEWAY_DEFAULT}