iloahz
iloahz

Reputation: 4561

How to modify dns server in C++?

I want to change the primary dns server to some ip(e.g. 8.8.8.8), for all active adapters.

I tried to modify the registry, for all interfaces under HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters, the NameServer is changed to what i want.

However it doesn't work. ipconfig /all shows that the dns is changed, however the system seems didn't apply that. If I open the attribute of TCP/IPv4, the dns is already changed, then i click OK, until now the dns is put into use.

Could someone tell me how to solve this? you may go some other ways, besides registry.

Update: what i did will finally apply, after about 6~8 mins.

Upvotes: 1

Views: 1832

Answers (1)

iloahz
iloahz

Reputation: 4561

Just for if someone need this, finally I used ipconfig /registerdns to refresh dns config in registry.

Upvotes: 1

Related Questions