3

ifconfig eth0 dhcp start or ifconfig eth0 dhcp drop does not seem to work for Android. Is there a way to enable/disable DHCP for eth0 via shell commands?

6
  • Do you've the tool named netcfg? Commented Apr 3, 2016 at 16:27
  • @Firelord command netcfg works. How can I use it to enable/disable DHCP? Commented Apr 3, 2016 at 16:36
  • Try with netcfg eth0 dhcp. See headlessandroid.blogspot.in/2012/06/…. Don't know how to disable DHCP. Commented Apr 3, 2016 at 16:40
  • 1
    @Firelord I have just tried that. It did not return anything. Commented Apr 3, 2016 at 16:56
  • How to make Ethernet work on Android over OTG? Commented Jun 7, 2020 at 21:02

2 Answers 2

1

try this code in android 5.1

ifconfig eth0 up dhcpcd eth0 

OR (static)

ifconfig eth0 192.168.70.65 netmask 255.255.255.0 up 

and now

ndc network create 100 ndc network interface add 100 eth0 ndc network route add 100 eth0 192.168.70.0/24 (gateway) ndc network route add 100 eth0 0.0.0.0/0 192.168.2.40 192.168.2.50 ndc resolver setnetdns 100 localdomain 192.168.2.40 192.168.2.50 (dns1 dns2) ndc network default set 100 
1
  • dhcpcd eth0.15 dhcpcd[4415]: version 5.5.6 starting setprop: applet not found setprop: applet not found dhcpcd[4415]: eth0.15: carrier lost setprop: applet not found dhcpcd[4415]: eth0.15: carrier acquired setprop: applet not found dhcpcd[4415]: eth0.15: sending IPv6 Router Solicitation dhcpcd[4415]: eth0.15: sendmsg: Cannot assign requested address dhcpcd[4415]: eth0.15: rebinding lease of 192.168.88.2 dhcpcd[4415]: eth0.15: sending IPv6 Router Solicitation dhcpcd[4415]: eth0.15: broadcasting for a lease dhcpcd[4415]: eth0.15: sending IPv6 Router Solicitation Commented Dec 20, 2022 at 9:30
0

try this way (My Android device worked)

DHCP IP

ifconfig eth0 dhcp 

OR

setprop dhcp.eth0 

OR

dhcpcd -k eth0 dhcpcd -n eth0 

OR

netcfg eth0 dhcp 

OR

getprop dhcp.eth0 

and Static IP

ifconfig eth0 192.168.70.145 netmask 255.255.255.0 up route add default gw 192.168.70.254 dev eth0 

or

su -c ifconfig eth0 192.168.70.145 netmask 255.255.255.0 up route add default gw 192.168.70.254 dev eth0 

Enable Ethernet

ifconfig eth0 up 

Disable Ethernet

ifconfig eth0 down 

and check wlan0 static or dynamic? my device when wlan0 is static force once set eth0 static and after set static change to dynamic

check the device ip:

ip addr 

********** try this android 5.1 ****************** eth0 dhcp

ifconfig eth0 down ifconfig eth0 up dhcpcd -k eth0 dhcpcd -n eth0 netcfg eth0 dhcp 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.