I should be able to do so with a static IP addresses, but I would like to know how to do it getting an IP address over DHCP. I thought that changing
/etc/resolv.conf would be permanent, but it dismisses the changes after a reboot.
The only thing that worked for me was:
Edit /etc/dhcp/dhclient.conf and un-comment the line:
prepend domain-name-servers 220.127.116.11;
Anyway thanks for your for your help!
dns-nameservers (and all others dns-xxx directives in /etc/network/interfaces) does not work in raspbian out of the box, since resolvconf is not installed by default.
sudo apt-get install resolvconf solves the issue.
I fixed this following the steps from cuonglm's answer on Unix & Linux Stack Exchange.
Edit the file /etc/dhcp/dhclient.conf and add
supersede domain-name-servers 18.104.22.168, 22.214.171.124;
Then restart network or run dhclient to make changes.
The supersede statement
supersede [ option declaration ]; If for some option the client should always use a locally-configured value or values rather than whatever is supplied by the server, these values can be defined in the supersede statement.
You can define them with a line in
Underneath your interface, add the following line, replacing the x's with the actual IP of the DNS server: