2

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?

  • Do you've the tool named netcfg? – Firelord Apr 3 '16 at 16:27
  • @Firelord command netcfg works. How can I use it to enable/disable DHCP? – Hong Apr 3 '16 at 16:36
  • Try with netcfg eth0 dhcp. See headlessandroid.blogspot.in/2012/06/…. Don't know how to disable DHCP. – Firelord Apr 3 '16 at 16:40
  • @Firelord I have just tried that. It did not return anything. – Hong Apr 3 '16 at 16:56
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
0

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

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.