Android ethernet configure IP using dhcp [closed]
Asked Answered
T

1

3

I have an android box with ethernet interface. There are no Java classes in android SDK to configure ethernet. As a last resort I am using shell commands to configure ethernet. Could any body please guide me which shell command do I use to configure ethernet? Sample commands will be highly appreciated.

Tack answered 11/4, 2013 at 11:32 Comment(0)
B
2

Android's got ifconfig, just like Linux. Unfortunately that just changes the interface configuration and doesn't, e.g., tell applications that the interface has come up, so they may not be aware that there's any internet access, so it may not help much. I'm afraid I can't help there.

For reference, you use ifconfig like this:

ifconfig <interface> up <ip address> mask <netmask> gw <gateway>

<interface> will probably be eth0, and the other fields are the appropriate IP addresses. You can see what interfaces are available by catting /proc/net/dev.

To be honest, you shouldn't need to do this --- Android (or at least modern Android, you didn't say which version you're using) has proper support for ethernet configuration via Settings -> Wireless and Networks. Is there any reason why this isn't working for you?

Bowler answered 11/4, 2013 at 11:45 Comment(1)
Thanks for your help. Yes, my android box do have ethernet settings in settings application but I have to develop a custom configuration utility. There are no APIs in android SDK to configure ethernet and that's causing lot of trouble. The command you provided well to assign static IP but I also want to enable/disable dhcp option. How can I do that?Tack

© 2022 - 2024 — McMap. All rights reserved.