I've encountered problems with DNS at my father's office router. When I connect using windows, there is no problem because windows could find a way to detect the DNS server itself. But with ubuntu, i have to set it manually.
As i connected to the router using DHCP to gain IP, my DNS keep changing to default after certain time. So I had to lock the resolv.conf to prevent my dns from changing. To lock the resolv.conf, I applied this command in terminal:
- sudo chattr +i /etc/resolv.conf
- sudo chattr -i /etc/resolv.conf
- Open up terminal (Application>Accessories>terminal)
- cd /usr/bin <-- Goto directory /usr/bin where all command was stored.
- sudo gedit dnslock <-- This will open up text editor for you to write the bash script.
- Copy this bash script:
# script to record MP3 broadcast stream
# The command is all on one line ending with a semi-colon
# $1 is for lock or unlock
# lock = +
# unlock = -
sudo chattr $1"i" /etc/resolv.conf
- now we have a script called dnslock.
- sudo chmod 755 dnslock <-- to make script executable.
- Now, to lock your DNS you just have to apply "dnslock +" command on the terminal without the " quote. In other hands, to unlock it use "dnslock -" command.