2

I cannot get any response from an Android device (Android 4.2) to command "ifconfig wlan0 dhcp status"

Command "ifconfig wlan0" returns the following:

wlan0: ip 192.168.0.14 mask 255.255.254.0 flags [up broadcast running multicast]

Does Android support "dhcp status"? If not, how can I find out through a command whether DHCP is enabled?

2 Answers 2

3

[How] can I find out through a command whether DHCP is enabled?

Provided that is setup in PC, execute:

adb shell dumpsys wifi 

In the output locate the string Configured networks. Following that would be the info on all the saved Wi-Fi networks in your device. For each network, inter alia you would see a line with the string IP assignment. Based on your configuration for that netowrk, it would either show STATIC or DHCP.

Note that you must have root access if you intend to run dumpsys wifi on a device through a command-line app since ordinary apps are usually not privileged to access a dump of WifiService.

Here's the relevant screenshot captured for Android 4.2.1:

IMG

The findings are valid for stock Android 6.0.1 as well.

Aforesaid information however doesn't query whether the router itself is capable of running a DHCP server.

6
  • Thanks a lot for the response. It is strange that I get a totally different response on my Android 4.2 device. It is not remotely close to yours. It starts with: WatchdogStatus: State: android.net.wifi.WifiWatchdogStateMachine$WatchdogDisabledState@425a2e30mWifiInfo: [null]. It has 30+ rec lines such as rec[0]: time=04-02 05:54:34.939 state=DefaultState orgState=DriverUnloadedState what=69632(0x11000)
    – Hong
    Commented Apr 2, 2016 at 10:37
  • I don't know the reason. Is that all you get to see as output? I double checked again on Android 4.2.1 and 6.0.1 and results do not deviate from my answer. Which Android device are you using?
    – Firelord
    Commented Apr 2, 2016 at 13:51
  • It is a product using a custom ROM. I will check with regular Android device and report back later today. Thank you for all the effort.
    – Hong
    Commented Apr 2, 2016 at 14:26
  • I tried it on my Moto G 2015 on Lollipop 6.0 and got an error... EDIT: Nevermind, I missed the part about root and I am not rooted at the moment.
    – acejavelin
    Commented Apr 2, 2016 at 14:33
  • 1
    Sorry, but neither of my devices has support for Ethernet, so that was all the help I could offer.
    – Firelord
    Commented Apr 3, 2016 at 2:28
2

The Android version of ifconfig is very limited compared to it's full-blown Linux version. And most commands I tried like dhcpstatus do not work.

4
  • Thank you for your prompt response. Is there an alternative to check the DHCP status?
    – Hong
    Commented Apr 1, 2016 at 18:12
  • I haven't found a command line alternative, only apps. Sorry.
    – acejavelin
    Commented Apr 1, 2016 at 18:15
  • 1
    @Hong you can always "move your acceptance" to another answer, if a better one comes up :) And you can also check other posts with ifconfig and DHCP, which might provide additional details.
    – Izzy
    Commented Apr 1, 2016 at 19:21
  • 2
    @Izzy Thank you for the reminder. I thought people are less likely to try to answer a question that has an accepted answer. Let me wait for a few more hours.
    – Hong
    Commented Apr 1, 2016 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .