shahooo
shahooo

Reputation: 593

How to set DNS when the device is connected via Ethernet?

My android target is connect via Ethernet using static IP. I am able to connect it by using ADB, but I am not able to ping any server. Please tell me how can I configure my DNS setting so that I can ping any server.

Upvotes: 7

Views: 11219

Answers (2)

izhoujinjian
izhoujinjian

Reputation: 125

Android 8.0

////////////////////////////////////////////////////////////

ifconfig usb0 192.168.225.3 netmask 255.255.255.0

ndc network create 9792

ndc network interface add 9792 usb0

ndc network route add 9792 usb0 0.0.0.0/0 192.168.225.1

ndc resolver setnetdns 9792 8.8.8.8 8.8.4.4

ndc network default set 9792

///////////////////////////////////////////////////////////

Upvotes: 2

Aditya Pratap Singh
Aditya Pratap Singh

Reputation: 84

Use this Command by superuser

su

for versions before marshmallow 6.x

ndc resolver setifdns (interface) (dns1) (dns2)

e.g.- ndc resolver setifdns eth0 8.8.8.8 8.8.4.4

for versions from marshmallow 6.x

ndc resolver setnetdns (interface) (dns1) (dns2)

e.g.- ndc resolver setnetdns eth0 8.8.8.8 8.8.4.4

Upvotes: 6

Related Questions