2

In a normal linux environment we can do

gateway=`netstat -rn | grep ^0\.0\.0\.0 | awk '{print $2}'`

or

gateway=$(netstat -rn | grep ^0\.0\.0\.0 | awk '{print $2}')

but since Android's busybox/magisk doesn't support netstat -rn, what other commands can we use to get the gateway or router ip?

1

It is as simple as getprop net.dns1

2
  • 1
    This is only true when your gateway / router is also the DNS server. On home networks this will work but this will fail on more complex networks with dedicated DNS servers. – GiantTree May 28 '17 at 17:30
  • @GiantTree how to get it on a more complex network system – Aero Windwalker Jun 2 '17 at 2:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.