MrG MrG - 5 months ago 34
Java Question

okhttp3 how to set Dns

I need set a DNS in my app.

I can't figure out how to add it:

//Http Client
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.addInterceptor(interceptor);
client.dns("172.10.0.100");

Answer

You can set the DNS via the WIFI settings and then just do this:

client.dns(Dns.SYSTEM);

now it should get the info from there.

Comments