On 2016/04/22 at 16:58, Minfei Huang wrote:
On 04/21/16 at 03:44pm, Xunlei Pang wrote:
> Current implementation of kdump_setup_dns() get the dns
> from interface's ifcfg file first, then parse those in
> "/etc/resolv.conf". For example, DNS1 in ifcfg file along
> with dhcp, the final dns(/etc/resolv.conf) in 1st system
> will be like(dhcp first, then ifcfg file appending end):
> dhcp dns1
> dhcp dns2
> dhcp dns3
> DNS1 in ifcfg
>
> After parsing, the dns(/etc/cmdline.d/42dns.conf) in kdump
> system will be like:
> DNS1 in ifcfg
> dhcp dns1
> dhcp dns2
> dhcp dns3
> DNS1 in ifcfg
Hi.
I have some confusion about the dns order in /etc/resolv.conf. From my
test, I found that dns client would append DNS entry to /etc/resolv.conf
in kdump kernel. Following is my test result.
kdump:/# cat /sysroot/etc/resolv.conf
# Generated by NetworkManager
search
nay.redhat.com redhat.com
nameserver 10.72.17.5
nameserver 10.68.5.26
nameserver 192.168.122.1
nameserver 8.8.8.8
kdump:/# cat /etc/resolv.conf
nameserver 10.72.17.5
nameserver 10.68.5.26
nameserver 192.168.122.1
nameserver 8.8.8.8
nameserver 192.168.122.1
The last dns entry "nameserver 192.168.122.1" is appended in kdump
kernel by DNS client. So the order may be like this:
dhcp dns1
DNS1
dhcp dns1
Actually, I think we can safely remove the ifcfg part, since we are using
"/etc/resolv.conf" directly which
was correctly parsed by the first system.
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