Thanks, Leo.
Hi Daniel and NetworkManager team,
We are kdump team dev, now have question about DNS handling from
NetworkManager and those scripts in /etc/sysconfig/network-scripts.
Could you please help to have a look when it's convenient to you?
Thanks
Baoquan
On 04/25/16 at 05:47pm, Hangbin Liu wrote:
> cc Daniel and network manager development team. They are experts on NM.
>
> On Mon, Apr 25, 2016 at 04:45:23PM +0800, Baoquan He wrote:
> > Hi network experts,
> >
> > We got confusion on network DNS handling when we try to fix a kdump
> > bug. For better representation let's assume a network interface enp0s25
> > with static DNS setting in ifcfg-enp0s25 as "DNS1=8.8.8.8", and
dhclient
> > privides 2 DNS server ip:
> >
> > 10.72.17.5
> > 10.68.5.26
> >
> >
> > Now the confusion is:
> >
> > 1) In 1st kernel if NetworkManager take control of the network setup and
> > PEERDNS=yes, the behaviour of DNS handling is that it adds dhclient's DNS
> > firstly then add static DNS from ifcfg-enp0s25. The result of
> > /etc/resolv.conf will be as follows:
> > nameserver 10.72.17.5
> > nameserver 10.68.5.26
> > nameserver 8.8.8.8
> >
> > - But if we set PEERDNS=no, the result of /etc/resolv.conf is:
> > nameserver 8.8.8.8
> > Apprently "PEERDNS=no" doesn't allow dhclient to add its DNS
into
> > /etc/resolv.conf.
> >
> > 2) However in 1st kernel if NetworkManager is disabled, means scripts
> > under /etc/sysconfig/network-scripts/ take control of network setup and
> > PEERDNS=yes, its behaviour is much different with NetworkManager. It
> > will firstly add dhclient's DNS, then replace the first entry, namely
> > "10.72.17.5" with the found static DNS from ifcfg-enp0s25. The result
of
> > /etc/resolv.conf will be like:
> > nameserver 8.8.8.8
> > nameserver 10.68.5.26
> >
> > - If PEERDNS=no set in ifcfg-enp0s25
> > /etc/resolv.conf won't be changed at all.
> >
> > Using NetworkManager or not using it can bring us so different
> > behaviours and different /etc/resolv.conf. Could you give suggestion how
> > we can make decision to choose a reasonable one since kdump probablly
> > need to cope with both of them?
> >
> > In fact above cases are not problems we have since dracut have another
> > different rules then above, and we need handle it. But now we need to
> > clarify how DNS handling acts in 1st kernel. Your suggestions and ideas
> > are very precisous to us.
> >
> > Thanks
> > Baoquan
> >
> > On 04/25/16 at 03:29pm, Xunlei Pang wrote:
> > > ============= 3. Conclusion =============
> > > Dracut, network-manager, and "network-scripts" all have different
hehavior
> > > in handling DNS.
> > >
> > > As a dhcp example:
> > > Suppose enp0s25, the dhcped DNSes are stable: 10.72.17.5 and 10.68.5.26
> > >
> > > In ifcfg-enp0s25:
> > > DNS1: 8.8.8.8
> > >
> > > 1) For 1st kernel's network-manager, the final nameservers in
/etc/resolv.conf
> > > -) If PEERDNS=yes(default is yes if PEERDNS doesn't exist) in
ifcfg-enp0s25
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > > -) If PEERDNS=no in ifcfg-enp0s25
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > >
> > > 2) For 1st kernel's scripts under /etc/sysconfig/network-scripts/
without network-manager
> > > -) If PEERDNS=yes in ifcfg-enp0s25
> > > nameserver 8.8.8.8
> > > nameserver 10.68.5.26
> > > -) If PEERDNS=no in ifcfg-enp0s25
> > > Not touch /etc/resolv.conf
> > > (i.e. /etc/resolv.conf is left unchanged as that before calling
"ifup <config>")
> > >
> > > 3) For dracut in latest fedora kexec-tools(1st kernel using
network-manager)
> > > "${initdir}/etc/cmdline.d/42dns.conf" will contain:
> > > nameserver=8.8.8.8
> > > nameserver=10.72.17.5
> > > nameserver=10.68.5.26
> > > nameserver=8.8.8.8
> > >
> > > -) If "rd.peerdns=1"(default is "1" if
"rd.peerdns" doesn't exist) is passed which is the default case
> > > nameserver 8.8.8.8
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > > nameserver 10.72.17.5 // the last two are drauct' dhcp generated
items
> > > nameserver 10.68.5.26
> > > -) If "rd.peerdns=0" is passed
> > > nameserver 8.8.8.8
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > >
> > >
> > > Regards,
> > > Xunlei
> > >
> > > >> Regards,
> > > >> Xunlei
> > > >>
> > > >>> Regards,
> > > >>> Xunlei
> > > >>>
> > > >>>> Thanks
> > > >>>> Minfei
> > > >>>>
> > > >>>>> There are two issues by doing this:
> > > >>>>> 1) The dns sequence is different from that in 1st
system.
> > > >>>>> 2) There are some duplicated items.
> > > >>>>> NOTE: kdump_setup_dns() meant to avoid the
duplication,
> > > >>>>> but the original shell command is actually
disfunctional:
> > > >>>>> "[ ! $(cat $_dnsfile | grep -q $_dns) ]"
(always true)
> > > >>>>>
> > > >>>>> Fix the issues by firstly parsing
"/etc/resolv.conf", then
> > > >>>>> parsing ifcfg file, finally delete the duplicated
items.
> > > >>>>>
> > > >>>>> Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
> > > >>>>> ---
> > > >>>>> dracut-module-setup.sh | 27
++++++++++++++++-----------
> > > >>>>> 1 file changed, 16 insertions(+), 11 deletions(-)
> > > >>>>>
> > > >>>>> diff --git a/dracut-module-setup.sh
b/dracut-module-setup.sh
> > > >>>>> index 350864e..b7763f7 100755
> > > >>>>> --- a/dracut-module-setup.sh
> > > >>>>> +++ b/dracut-module-setup.sh
> > > >>>>> @@ -68,14 +68,6 @@ kdump_setup_dns() {
> > > >>>>> local
_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
> > > >>>>> local ifcfg_file
> > > >>>>>
> > > >>>>> - ifcfg_file=$(get_ifcfg_filename $1)
> > > >>>>> - if [ -f "${ifcfg_file}" ]; then
> > > >>>>> - . ${ifcfg_file}
> > > >>>>> - fi
> > > >>>>> -
> > > >>>>> - [ -n "$DNS1" ] && echo
"nameserver=$DNS1" > "$_dnsfile"
> > > >>>>> - [ -n "$DNS2" ] && echo
"nameserver=$DNS2" >> "$_dnsfile"
> > > >>>>> -
> > > >>>>> while read content;
> > > >>>>> do
> > > >>>>> _nameserver=$(echo $content | grep
^nameserver)
> > > >>>>> @@ -84,10 +76,23 @@ kdump_setup_dns() {
> > > >>>>> _dns=$(echo $_nameserver | cut -d' '
-f2)
> > > >>>>> [ -z "$_dns" ] && continue
> > > >>>>>
> > > >>>>> - if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile
| grep -q $_dns) ]; then
> > > >>>>> - echo "nameserver=$_dns"
>> "$_dnsfile"
> > > >>>>> - fi
> > > >>>>> + echo "nameserver=$_dns" >>
"$_dnsfile"
> > > >>>>> done < "/etc/resolv.conf"
> > > >>>>> +
> > > >>>>> + unset DNS1 DNS2
> > > >>>>> + ifcfg_file=$(get_ifcfg_filename $1)
> > > >>>>> + if [ -f "${ifcfg_file}" ]; then
> > > >>>>> + . ${ifcfg_file}
> > > >>>>> + fi
> > > >>>>> +
> > > >>>>> + [ -n "$DNS1" ] && echo
"nameserver=$DNS1" >> "$_dnsfile"
> > > >>>>> + [ -n "$DNS2" ] && echo
"nameserver=$DNS2" >> "$_dnsfile"
> > > >>>>> +
> > > >>>>> + # Delete duplicated lines
> > > >>>>> + if [ -f "$_dnsfile" ]; then
> > > >>>>> + awk '!a[$0]++' $_dnsfile >
$_dnsfile.tmp
> > > >>>>> + mv -f $_dnsfile.tmp $_dnsfile
> > > >>>>> + fi
> > > >>>>> }
> > > >>>>>
> > > >>>>> #$1: netdev name
> > > >>>>> --
> > > >>>>> 1.8.3.1
> > > >>>>> _______________________________________________
> > > >>>>> kexec mailing list
> > > >>>>> kexec(a)lists.fedoraproject.org
> > > >>>>>
http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
> > > >>> _______________________________________________
> > > >>> kexec mailing list
> > > >>> kexec(a)lists.fedoraproject.org
> > > >>>
http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
> > > >> _______________________________________________
> > > >> kexec mailing list
> > > >> kexec(a)lists.fedoraproject.org
> > > >>
http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
> > >
>
> --
>
> Thanks & Best Regards
> Hangbin Liu <haliu(a)redhat.com>
> Leo on #kernel-qe, #kernel, #eng-china