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:
/etc/network/interfaces
And adding this:
dns-nameservers 8.8.8.8
So now interfaces file looks like this:
allow-hotplug eth0
iface eth0 inet dhcp
dns-nameservers 8.8.8.8
To have DHCP and static DNS at the same time, but after restarting networking.service nothing will change.
when using DHCP:
ps aux | grep dhcp
dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
**Manually editing**
If I manually edit /etc/resolv.conf and put nameserver 8.8.8.8 there, after restarting networking.service, system DNS server changes to 8.8.8.8, but after doing a ifup:
sudo ifup eth0
Again /etc/resolv.conf automatically changes to 192.168.1.1.
**NetworkManager**
Then I decide to use network-manager, 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 8.8.8.8.
So it's not network-manager which overrides /etc/resolv.cof
**Static config**
After facing all these I decide to go with static configuration.
First I uninstalled network-manager then I added static configuration to:
/etc/network/interfaces
something like this:
iface eth0 inet static
address 192.168.1.10
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 8.8.8.8
After restarting 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.
**Permission**
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 there anything that I'm missing here?
Asked by Ravexina
(2748 rep)
Jun 28, 2016, 09:04 AM
Last activity: Nov 7, 2024, 08:26 AM
Last activity: Nov 7, 2024, 08:26 AM