How to set DNS resolver in Fedora using network-manager?

Method #1

Find the NetworkManager configuration file and add/modify the following entry (in CentOS5 it is in /etc/NetworkManager/nm-system-settings.conf or /etc/NetworkManager/system-connections/) and edit your DSL connection file :

[ipv4]
method=auto
dns=8.8.8.8;4.2.2.2;
ignore-auto-dns=true

Note:- if [ipv4] does not work then try with [ppp]

Method #2

You can change permission of /etc/resolv.conf so that it can't be written by other services or you can use chattr.

Method #3

Create a script as mentioned below in /etc/Networkmanager/dispatcher.d/ and don't forget to make it executable:

#!/bin/bash
#
# Override /etc/resolv.conf and tell
# NetworkManagerDispatcher to go pluck itself.
#
# scripts in the /etc/NetworkManager/dispatcher.d/ directory
# are called alphabetically and are passed two parameters:
# $1 is the interface name, and $2 is "up" or "down" as the
# case may be.

# Here, no matter what interface or state, override the
# created resolver config with my config.

cp -f /etc/resolv.conf.myDNSoverride /etc/resolv.conf

entry of /etc/resolv.conf.myDNSoverride

nameserver 8.8.8.8

Have a look at:

$ man NetworkManager.conf

It seems that if you add a line with dns=none in the [main] section, NetworkManager won't touch /etc/resolv.conf.


PPPD senario

Using ppon and ppoff probably means you are using pppd. In which case pon will execute the script /etc/ppp/ppp_on_boot. Unless you supply an argument to pon, it will load settings from /etc/ppp/peers/provider. If you provide an argument it will say for example pon interwebz it will look for /etc/ppp/peers/interwebz. There is also /etc/ppp/options to check too.

I would imagine that this file contains the setting usepeerdns. From the pppd man page:

usepeerdns
   Ask the peer for up to 2 DNS server addresses. The addresses supplied by the peer 
   (if any) are passed to the /etc/ppp/ip-up script in the environment variables 
   DNS1 and DNS2, and the environment variable USEPEERDNS will be set to 1. In 
   addition, pppd will create an /etc/ppp/resolv.conf file containing one or two
   nameserver lines with the address(es) supplied by the peer. 

Comment out this option, stop pppd with poff, edit your resolv.conf and then restart your pppd with pon and see if that resolves the issue.

eth0 senario

If you edit your interface settings file (/etc/sysconfig/network-scripts/ifcfg-eth0 for eth0), you can see what settings network manager is using.

If you have DHCP running on that interface BOOTPROTO=yes then you can tell it not to override your DNS settings with PEERDNS=no. If you are using a static address then you can set your DNS settings with

DNS1="8.8.4.4"
DNS2="8.8.8.8"
SEARCH="yourdomain.com"