0

In Android file system, How to get prop command will get the DNS server IP address?

Whether that command take DNS server IP address from any file present inthe filesystem or through any code.

Please can anybody answer from which file in the file system this will get the DNS Server address?

Rohan Lodhi
  • 1,385
  • 9
  • 24

1 Answers1

1

getprop net.dns1 or 2 in a shell. I don't think they're in any file like resource on the filesystem directly(could be wrong).

This is possibly a duplicate of this though. Check it out if you want to have it from java code. How do you get the current DNS servers for Android?

Also be advised, some Google portions will just use their own dns. Facebook app can sometimes do it too. If you're ever wondered how facebook has worked on your hotel wifi before logging in, this is how(if the wifi login is dns interception based).

EDIT: if you're looking to set the dns, you cannot do that without setting up a fake local VPN or using manufacturer specific apis(like Samsungs).

Lassi Kinnunen
  • 448
  • 4
  • 10
  • If you were looking for the actual mechanism how getprop works, it gets the properties from a properties server. but this is likely to not be useful. https://android.googlesource.com/platform/system/core/+/66b6875/libcutils/properties.c – Lassi Kinnunen Jan 09 '19 at 07:57
  • Thank you for your response. Is there any c code is there to get DNS server IP address? – shanmuga sundari Jan 09 '19 at 08:47
  • You could adapt that code I linked to, properties.c or getprop.c from same place. basically get the property from the property server. Although depending on your c skills it could just be easier to exec getprop net.dns1 and dns2 and parse that output. There might be some other places to pull the data from, there used to be, but it has been more than 6 years since I looked into the saved wifi networks information and such so I can't remember right now. – Lassi Kinnunen Jan 09 '19 at 09:32
  • Ok...I will try...If we update the android version whether file system will change or not? – shanmuga sundari Jan 10 '19 at 07:01
  • the properties server(and getprop) shouldn't change unless they change quite a lot the whole android system. – Lassi Kinnunen Jan 10 '19 at 07:06
  • We update the android version 8.0 ...previous android version I don't know.But previous version if I give getprop command.It will provide DNS server IP address information,but after android version updation getprop command didn't provide DNS server IP address.Is it possible? – shanmuga sundari Jan 11 '19 at 05:36
  • it's possible but I would think that to be more like a device feature than android 8.0 feature as the virtual devices still give it(don't have 8.0 device just now handy). is it a htc or huawei? – Lassi Kinnunen Jan 14 '19 at 07:43
  • No...none of them...It is a media tek board – shanmuga sundari Jan 18 '19 at 06:03