I am connecting to my WiFi network from adb shell using the following command:
iw dev wlan1 connect -w WiFi-AP
There is a DHCP server running on the AP as well, but whenever I try to get IP address using dhclient -v wlan1
, I get the following error:
sh: dhclient: not found
Is there a way to install dhclient on Android 8.1, or is there any other way to request IP address from the DHCP server over a wlan interface?
dhcpcd
up to Lollipop (or KitKat?). Now the client runs as a service inside Java runtime. No native tool available. You can build a static DHCP client binary from source. – Irfan Latif Jul 16 '19 at 12:37dhcpcd
isn't that much complicated, but it won't be of any use. Linux distributions have simpler network configuration, usually usemain
routing table and/etc/resolv.conf
for DNS. Android has a dynamic routing policy, containing scores of rules and routes, continuously updated bynetd
with network changes. Plus Android's Bionic libc doesn't use/etc/resolv.conf
. So even ifdhcpcd
gets you an IP and DNS nameserver from DHCP server, you still have to manually configure routing, NATing, forwarding etc. – Irfan Latif Jul 18 '19 at 13:23main
table may work. – Irfan Latif Jul 18 '19 at 14:03