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
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@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
On 2016/04/21 at 15:44, 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
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
I will send a patch applying "Delete duplicated lines" logic on dracut side as well.
Regards, Xunlei
}
#$1: netdev name
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 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
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.
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
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.
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
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
On 2016/04/25 at 13:24, Baoquan He wrote:
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.
Hereby I only summarize dhcp cases for specific $netif about the main process of dns handling, static cases is similar.
============= 1. The DNS handling in 1st kernel after the dracut stage =============
There are two network methods available in 1st kernel: network-manager(nmcli) and network-scripts(without network-manager by using scripts under /etc/sysconfig/network-scripts/, such as "if-eth", "ifup-post", etc).
a) The general entry is "/usr/sbin/ifup": need_config // find the right ifcfg file of the $config source_config // load the ifcfg file contents
b) Then if it is network-manager controlled, bring it up firstly via nmcli: if [ "$_use_nm" = "true" -a -n "$UUID" -a "$DEVICE" != "lo" ]; then if [ "foo$2" = "fooboot" ] && [ "${TYPE}" = "Wireless" ]; then exit 0 fi [ -n "${DEVICE}" ] && is_nm_handling ${DEVICE} && exit 0 nmcli con up uuid "$UUID" exit $? fi
All things are done by nmcli which is an ELF file, I didn't get its detail. All the knowledge if through experiments: -) Generate dhcp firstly -) Append the DNS1&DNS2 info in ifcfg to /etc/resolv.conf -) From my experiment, seems "PEERDNS=yes" and "PEERDNS=no" have the same effect.
c) Otherwise(without network-manager), it will generally use scripts under "/etc/sysconfig/network-scripts/" to do the job: OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
if [ ! -x ${OTHERSCRIPT} ]; then OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${TYPE}" fi
if [ ! -x ${OTHERSCRIPT} ]; then OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth" fi
exec ${OTHERSCRIPT} ${CONFIG} $2
d) Suppose we have ethernet type, ${OTHERSCRIPTS} is "ifup-eth", we enter "ifup-eth": After some specific type-parsing(bridge, vlan, team, etc), it will generally call "dhclient" to do the dhcp firstly. "/usr/sbin/dhclient-script" is called by "dhclient" to generate the initial "/etc/resolv.conf" file, can refer to function "make_resolv_conf" in dhclient-script for details. make_resolv_conf() { [ "${PEERDNS}" = "no" ] && return // handle PEERDNS
generate dns information to file ${rscf} using the contents provided by "dhclient"
change_resolv_conf ${rscf}
e) Finally, "ifup-post" script is called, it does mainly(omit some detail here): if [ "$PEERDNS" != "no" ] ; then // handle PEERDNS if [ -n "$DNS1" ] && ! grep -q "^nameserver $DNS1" /etc/resolv.conf && tr=$(mktemp /tmp/XXXXXX) ; then current_replacement="$DNS1" next_replacement="$DNS2" search= (cat /etc/resolv.conf ; echo EOF ; echo EOF) | while read answer ; do case $answer in nameserver*|EOF) if [ -n "$current_replacement" ] ; then echo "nameserver $current_replacement" >> $tr if [ -n "$next_replacement" ] ; then current_replacement="$next_replacement" next_replacement= else current_replacement= fi else if [ "$answer" != EOF ] ; then echo "$answer" >> $tr fi fi ;; <snip> esac done change_resolv_conf $tr fi fi
============= 2. The DNS handling in dump kernel by dracut ============= Using scripts under modules.d/40network/ a) The general entry is "ifup":
b) do nameserver and dns1/dns2 firstly, which is acquired from "nameserver=" and "ip=" cmdline of dracut setup in 1st kernel when making kdump initramfs. # Specific configuration, spin through the kernel command line # looking for ip= lines for p in $(getargs ip=); do ip_to_var $p
<snip>
# setup nameserver for s in "$dns1" "$dns2" $(getargs nameserver); do [ -n "$s" ] || continue echo nameserver $s >> /tmp/net.$netif.resolv.conf // Apparently, not deal with rd.peerdns done
c) "do_dhcp -4 ;;" This will trigger dhclient and "modules.d/40network/dhclient-script.sh", in setup_interface(), dracut will append dhcp-generated DNS information into "/tmp/net.$netif.resolv.conf": if getargbool 1 rd.peerdns; then // handle rd.peerdns globally [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf if [ -n "$namesrv" ] ; then for s in $namesrv; do echo nameserver $s done fi >> /tmp/net.$netif.resolv.conf // append dhcp dns fi
d) execute setup_net through initqueue scripts [ -e /tmp/net.$netif.resolv.conf ] && \ cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
============= 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:
- 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
On 2016/04/25 at 15:29, Xunlei Pang wrote:
On 2016/04/25 at 13:24, Baoquan He wrote:
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.
Hereby I only summarize dhcp cases for specific $netif about the main process of dns handling, static cases is similar.
============= 1. The DNS handling in 1st kernel after the dracut stage =============
There are two network methods available in 1st kernel: network-manager(nmcli) and network-scripts(without network-manager by using scripts under /etc/sysconfig/network-scripts/, such as "if-eth", "ifup-post", etc).
a) The general entry is "/usr/sbin/ifup": need_config // find the right ifcfg file of the $config source_config // load the ifcfg file contents
b) Then if it is network-manager controlled, bring it up firstly via nmcli: if [ "$_use_nm" = "true" -a -n "$UUID" -a "$DEVICE" != "lo" ]; then if [ "foo$2" = "fooboot" ] && [ "${TYPE}" = "Wireless" ]; then exit 0 fi [ -n "${DEVICE}" ] && is_nm_handling ${DEVICE} && exit 0 nmcli con up uuid "$UUID" exit $? fi
All things are done by nmcli which is an ELF file, I didn't get its detail. All the knowledge if through experiments: -) Generate dhcp firstly -) Append the DNS1&DNS2 info in ifcfg to /etc/resolv.conf -) From my experiment, seems "PEERDNS=yes" and "PEERDNS=no" have the same effect.
c) Otherwise(without network-manager), it will generally use scripts under "/etc/sysconfig/network-scripts/" to do the job: OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
if [ ! -x ${OTHERSCRIPT} ]; then OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${TYPE}" fi if [ ! -x ${OTHERSCRIPT} ]; then OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth" fi exec ${OTHERSCRIPT} ${CONFIG} $2
d) Suppose we have ethernet type, ${OTHERSCRIPTS} is "ifup-eth", we enter "ifup-eth": After some specific type-parsing(bridge, vlan, team, etc), it will generally call "dhclient" to do the dhcp firstly. "/usr/sbin/dhclient-script" is called by "dhclient" to generate the initial "/etc/resolv.conf" file, can refer to function "make_resolv_conf" in dhclient-script for details. make_resolv_conf() { [ "${PEERDNS}" = "no" ] && return // handle PEERDNS
generate dns information to file ${rscf} using the contents provided by "dhclient" change_resolv_conf ${rscf}
e) Finally, "ifup-post" script is called, it does mainly(omit some detail here): if [ "$PEERDNS" != "no" ] ; then // handle PEERDNS if [ -n "$DNS1" ] && ! grep -q "^nameserver $DNS1" /etc/resolv.conf && tr=$(mktemp /tmp/XXXXXX) ; then current_replacement="$DNS1" next_replacement="$DNS2" search= (cat /etc/resolv.conf ; echo EOF ; echo EOF) | while read answer ; do case $answer in nameserver*|EOF) if [ -n "$current_replacement" ] ; then echo "nameserver $current_replacement" >> $tr if [ -n "$next_replacement" ] ; then current_replacement="$next_replacement" next_replacement= else current_replacement= fi else if [ "$answer" != EOF ] ; then echo "$answer" >> $tr fi fi ;; <snip> esac done change_resolv_conf $tr fi fi
============= 2. The DNS handling in dump kernel by dracut ============= Using scripts under modules.d/40network/ a) The general entry is "ifup":
b) do nameserver and dns1/dns2 firstly, which is acquired from "nameserver=" and "ip=" cmdline of dracut setup in 1st kernel when making kdump initramfs. # Specific configuration, spin through the kernel command line # looking for ip= lines for p in $(getargs ip=); do ip_to_var $p
<snip> # setup nameserver for s in "$dns1" "$dns2" $(getargs nameserver); do [ -n "$s" ] || continue echo nameserver $s >> /tmp/net.$netif.resolv.conf // Apparently, not deal with rd.peerdns done
c) "do_dhcp -4 ;;" This will trigger dhclient and "modules.d/40network/dhclient-script.sh", in setup_interface(), dracut will append dhcp-generated DNS information into "/tmp/net.$netif.resolv.conf": if getargbool 1 rd.peerdns; then // handle rd.peerdns globally [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf if [ -n "$namesrv" ] ; then for s in $namesrv; do echo nameserver $s done fi >> /tmp/net.$netif.resolv.conf // append dhcp dns fi
d) execute setup_net through initqueue scripts [ -e /tmp/net.$netif.resolv.conf ] && \ cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
============= 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
- 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
network-manager may cache some ifcfg data, I tested further with a complete reboot each time I changed the ifcfg file:
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 8.8.8.8
Regards, Xunlei
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>")
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:
- 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
kexec mailing list kexec@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
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
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
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>")
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:
- 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
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:
- 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
On 2016/04/22 at 17:09, Minfei Huang wrote:
On 04/21/16 at 03:44pm, Xunlei Pang wrote:
- # Delete duplicated lines
- if [ -f "$_dnsfile" ]; then
awk '!a[$0]++' $_dnsfile > $_dnsfile.tmp
Hi.
Maybe storing the temporary file to ${initdir}/tmp/ is better. You can refer to function kdump_install_conf.
This is better, will do
Regards, Xunlei
Thanks Minfei
On 04/21/16 at 03:44pm, Xunlei Pang wrote:
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)
Hi.
This test is useful in previous context, since there may be duplicate DNS entries in /etc/resolv.conf. It is safe to remove it in your patch, because the deplicate DNS entries will be remove later.
Thanks Minfei
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
On 2016/04/22 at 17:26, Minfei Huang wrote:
On 04/21/16 at 03:44pm, Xunlei Pang wrote:
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)
Hi.
This test is useful in previous context, since there may be duplicate DNS entries in /etc/resolv.conf. It is safe to remove it in your patch, because the deplicate DNS entries will be remove later.
Actually, this condition always returns true, you can test it :-)
Regards, Xunlei
Thanks Minfei
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
On 04/22/16 at 10:54pm, Xunlei Pang wrote:
On 2016/04/22 at 17:26, Minfei Huang wrote:
On 04/21/16 at 03:44pm, Xunlei Pang wrote:
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)
Hi.
This test is useful in previous context, since there may be duplicate DNS entries in /etc/resolv.conf. It is safe to remove it in your patch, because the deplicate DNS entries will be remove later.
Actually, this condition always returns true, you can test it :-)
Thanks for pointing it out.
This error is caused by misusing brackets. Removing this brackets can make this test work. It's lucky that kdump can work as well, although there are duplicate DNS entry in resolv.conf.
Thanks Minfei