How can i update/refresh DNS records using console

I figured out that the file that stores my wifi dns settings is /etc/resolv.conf. I want to create a script that will change them to something else when i press a button on my remote…but what is the command to ‘refresh’ the dns records in Kodi as well ?
None of the following methods are valid for osmc

sudo /etc/init.d/nscd restart
sudo /etc/init.d/networking restart
sudo /etc/init.d/dns-clean start
sudo service nscd restart

What’s the proper command ? So i dont have to do it manually all the time via MyOSMC.
Thanks

There is no DNS caching in OSMC by default. So you shouldn’t need to do anything.

BTW resolv.conf is written by connman automatically so expect your changes to be overwritten at unexpected times.

A better approach would be to use connmanctl to change the DNS servers via the proper connman API.

Nice, thanks,
For anyone interested first do connmanctl services to get your wifi’s id
Then to set up new nameserver do:
connmanctl config wifi_blahblah_your_id_managed_psk --nameservers 8.8.8.8 8.8.4.4

Btw, i see them set in MyOsmc, but do i need to restart connmanctl after i set them or it’s not needed ?

Nope, no need to restart anything. Btw if you are scripting something you can use connmanctl in non-interactive mode:

connmanctl config wifi_blahblah --nameservers 8.8.8.8 8.8.4.4

You could run this from any script as connmanctl does not require root access.

2 Likes

Yeah thats what i was thinking of doing. Much easier than re-writing a conf file with new dns all the time. hehe
thanks drake