I like the OpenDns service, and want to use their DNS servers as the default ones in my ubuntu.
But I got some hard-time figuring out how to do it – so now that I found a mature way of doing I will share my failed attempts and the solution found to make it easy for others.
This will work at least for Ubuntu, Kubuntu, Xubuntu and any other debian based distros which use NetworkManager (and consequently dhclient)
The failed attempts to solve it:
First I found that linux will read the DNS servers from the file /etc/resolv.conf
Reading the man page of it (see “man resolv.conf”) I tried to change the file to add the OpenDnss IPs into it – it was as easy as inserting at the top of /etc/resolv.conf the lines:
and it should be done – DNSs configured for the entire system and for all programs! But no, it was not that easy… it only worked temporarily – after a while or after reboot the file resolv.conf was again without the OpenDnss servers I’ve added, and had to manually insert the OpenDnss again… and that is no solution.
What was happening behind the scene? Well, (K/L/X)ubuntus, they all use by default a program named NetworkManager to manage all the systems interfaces that connect to internet.
In turn, the NetworkManager will then use another program named dhclient to get the IP address and DNS servers from a DHCP server, everytime an interface is establishing a connection (when an interface is being put “up”).
And dhclient will itself overwritte the file /etc/resolv.conf with the DNS servers it gets from the DHCP, everytime it gets a DHCP lease for any interface.
So everytime an interface connects (for example, when the wireless interface changes ESSID), the file resolv.conf got overwritten with the DHCP DNSs and so the OpenDns servers manually inserted would not persist.
The good attempt that solved it:
Now dhclient, uses it’s own configuration file (/etc/dhcp3/dhclient.conf , see also “man dhclient.conf”) where it is possible to tell it to always prepend the OpenDnss before the DHCP DNSs when it overwrittes the file resolv.conf.
This way the OpenDns servers will always be included and get first priority over the DHCP DNSs (which also get included, but with a secondary priority)
And this was the solution that made the OpenDnss always present – it was necessary to change only /etc/dhcp3/dhclient.conf
The changes needed in /etc/dhcp3/dhclient.conf were to add these lines at the bottom of the file (but continue reading to use an automated script presented below!):
#:) Prepend the OpenDns servers into /etc/resolv.conf
prepend domain-name-servers 18.104.22.168, 22.214.171.124;
I’ve made a very basic script (you can see it in gist) to automate the adding of the OpenDns server in /etc/dhcp3/dhclient.conf , so that one can simply run the following in a console:
And from then on, the OpenDns server will be used permanently (surviving all the reboots and reconnects! )
This will work for all standard K/X/L ubuntus because they use NetworkManager by default.
If you use Wicd instead of NetworkManager, then this solution will not solve it – because Wicd runs dhclient using a different dhclient.conf file that is not the /etc/dhcp3/dhclient.conf file.
When I get clear about Wicd , I will post here how to do it. UPD 20120528: just stumbled upon the wicd different dhclient.conf file – it’s /etc/wicd/dhclient.conf.template (get more info about it with “man wicd”)
I use dropbox between several computers, and recently decided to put my very-good-personal notes in Dropbox, so as to keep them always updated.
So I’ve moved the notes to inside the Dropbox folder, and then at the end realized that it’s very conforting to have everything important in dropbox, but… what if dropbox fails by some-obscure-reason?
So I’ve decided to make regular local backups of the Dropbox folder-contents into the home directory of my kubuntu, to use just in case.
To make the backup process easy and fast, I’ve made a little bash script (view the script), which I leave in the Dropbox folder to execute whenever I want to launch a backup of that folder.
So this post is no-more-nor-less than to share the lessignificant backup-script I made.
The script when executed, will compress the contents of the current folder, into a a ZIP file created inside the $HOME folder.
The name of the ZIP file will have the current-folder-name as prefix and the actual date and time (ex: “Dropbox_Backup_2010-09-03_21:49:04.zip”)
So to make Dropbox backups:
Drop a comment with your thoughts
The script can also be used to make backups of others folders – it will backup up the directory where it is run (using the directory name as the ZIP file prefix)
There is a dropbox client adapted for KDE – it’s called Kdropbox Kfilebox and runs pretty well 🙂
Has all the normal features, except that the icons are not yet updated in Konqueror/Dolphin when a file is being updated (uploaded/download) as happens with nautilus.
Nonetheless, feels to me that it won’t take long before this minor exception gets fixed…
Oh, and give credit to the guy that created the Kfilebox “Guillermo Amat”, because he did it from his own initiative. An then, after all his hard work, he got an email from the dropbox-officials commanding him to rip away the dropbox name and icon from his Kdropbox Kfilebox.
The guy took it a litle hard and with some reasons… shame on you dropbox-officials, you should be much nicer with your supporters…