On 04/25/16 at 10:56am, Xunlei Pang wrote:
On 2016/04/22 at 22:53, Xunlei Pang wrote:
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
Thanks for the test, the Dracut's dhcp order may have problems, it should be like network-manager: dhcp firstly, then append DNS<n> in ifcfg files.
I will double confirm this later.
I checked the implementation of /etc/sysconfig/network-scripts/ and the actual effect of network-manager, they are differently implemented. Seems there is no standard to follow. I'd rather leave this alone(only improve the duplicated items) for safety as we discussed last week, since there are no bugs related to this reported.
I think we can summarize the knowing we have discussed about the behaviour of Netowrkmanager, network-scripts and dracut implementation on dns. Then ask network expert to help to check this, which one is reasonable. After making this clear proper fix can be done.
Regards, Xunlei
Regards, Xunlei
Thanks Minfei
There are two issues by doing this:
- The dns sequence is different from that in 1st system.
- 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@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
done < "/etc/resolv.conf"echo "nameserver=$_dns" >> "$_dnsfile"
- 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@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org