I'm using Debian jessie and I don't have network-manager or resolvconf installed and I'm using DHCP.
DHCP with static DNS
First of all I tried editing:
And adding this:
So now interfaces file looks like this:
allow-hotplug eth0 iface eth0 inet dhcp dns-nameservers 126.96.36.199
To have DHCP and static DNS at the same time but after restarting networking.service nothing will changes.
when using DHCP:
ps aux | grep dhcp dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
If I manually edit /etc/resolv.conf and put nameserver 188.8.131.52 there, after restarting networking.service, system DNS server changes to 184.108.40.206 but after doing a ifup:
sudo ifup eth0
Again /etc/resolv.conf automatically changes to 192.168.1.1.
Then I decide to use network-manger, I installed network-manager and after setting DNS server IP in default connection and reconnecting it, it works but after rebooting the system, network-manager creates a new connection with default DNS server (192.168.1.1) and automatically connects to this one.
I also checked automatically connect to this network when it is available in correct connection but after reboot network-manager again connects to the other one.
Reseting after 10 Hour
I somehow managed to fix this issue by changing the new connection configs, now it does not create a new connection in every boot and connects to correct connection however now after something around 10 Hours DNS server automatically changes to 192.168.1.1 and I should reconnect the connection or restart NetworkManager.service to get DNS back into 220.127.116.11.
So it's not network-manager which overrides /etc/resolv.cof
After facing all these I decide to go with static configuration.
First I unistalled network-manager then I added static configuration to:
something like this:
iface eth0 inet static address 192.168.1.10 gateway 192.168.1.1 netmask 255.255.255.0 dns-nameservers 18.104.22.168
After restaring networking.service these setting will not apply to system and interface has no IP so network is unreachable too.
Turning router DHCP off Now that I turned my router's DHCP off, static config works fine but I need DHCP to be on for other devices.
I can edit /etc/resolv.conf and change it's permission so nobody can edit it...
But I'm looking for a reason. I want to know why these are not working, which program overrides /etc/resolv.conf and what is the right way to set DNS server.
Is tehre anything that i'm missing here?