Get default gateway address from shell command
Is it possible to get the default gateway address using a shell command? I tried "ifconfig" and "ip route show", but those commands don't provide that information.
Tagged:
0
Comments
If you don't mind parsing it from a larger chunk, you could do
dumpsys ethernet
:Parsing the response is perfectly fine. Thanks a lot!
If execute "dumpsys ethernet | grep 'LinkProperties:'" command in the shell myself I get the desired output. However, if I try to execute it in a process I launch from my app I get this:
'Permission Denial: can't dump EthernetService from pid=2836, uid=10057'
If I try "su -c "dumpsys ethernet | grep 'LinkProperties:'"" I get an empty response.
Is there another command I could use which doesn't require elevated permissions?
Its interesting that "su" doesn't get the permission to do so. Maybe you can add
<uses-permission android:name="android.permission.DUMP" />
to your application?