Currently kdump uses dracut's "nameserver=" command to hande DNS, it is acquired both from ifcfg files and "/etc/resolv.conf".
This is improper for dhcp cases, as "/etc/resolv.conf" is generated by dhcp, the proper logic should be: 1) For static cases, DNS can be acquired from corresponding ifcfg file. 2) For dhcp cases, DNS is normally generated by dhcp, but extra DNS can still be specified in the ifcfg files mannually. 3) For special user-assigned DNS not specified in any ifcfg file, we can pass it to dracut via "nameserver=".
This patch improves the logic using the following "ip=" command format provided by dracut: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>: <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]]
Signed-off-by: Xunlei Pang xlpang@redhat.com --- dracut-module-setup.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..a18fdc0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -63,26 +63,19 @@ kdump_is_vlan() { }
# $1: netdev name -kdump_setup_dns() { - local _nameserver _dns - local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf - . /etc/sysconfig/network-scripts/ifcfg-$1 - - [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile" - [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile" +# return pattern ":<dns1>[<:dns2>]" if not "" +kdump_get_dns_from_ifcfg() { + local _dns
- while read content; - do - _nameserver=$(echo $content | grep ^nameserver) - [ -z "$_nameserver" ] && continue + unset DNS1 DNS2 + if [ -e /etc/sysconfig/network-scripts/ifcfg-$1 ]; then + . /etc/sysconfig/network-scripts/ifcfg-$1 + fi
- _dns=$(echo $_nameserver | cut -d' ' -f2) - [ -z "$_dns" ] && continue + [ -n "$DNS1" ] && _dns=${_dns}:$(echo $DNS1) + [ -n "$DNS2" ] && _dns=${_dns}:$(echo $DNS2)
- if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then - echo "nameserver=$_dns" >> "$_dnsfile" - fi - done < "/etc/resolv.conf" + echo -n "${_dns}" | cut -d':' -f1,2,3 }
#$1: netdev name @@ -254,22 +247,27 @@ kdump_setup_znet() { # Setup dracut to bringup a given network interface kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2 - local _static _proto _ip_conf _ip_opts _ifname_opts + local _static _proto _ip_conf _ip_opts _ifname_opts _ifcfg_dns + local _global_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev fi
- _netmac=$(kdump_get_mac_addr $_netdev) + # Using below "ip=" command format provided by dracut: + # ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>: + # <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]] _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none else _proto=dhcp + _static=":::::" fi
+ _ifcfg_dns=$(kdump_get_dns_from_ifcfg $_netdev) _ip_conf="${initdir}/etc/cmdline.d/40ip.conf" - _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}" + _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}${_ifcfg_dns}"
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates @@ -278,6 +276,12 @@ kdump_setup_netdev() { if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf + # In case of no DNS specified by iscsi. + if [ -n "${_ifcfg_dns}" ]; then + _ifcfg_dns=${_ifcfg_dns##:} + echo "nameserver=${_ifcfg_dns%%:*}" >> ${_global_dnsfile} + [ "${_ifcfg_dns}" = "${_ifcfg_dns%%:*}" ] || echo "nameserver=${_ifcfg_dns##*:}" >> ${_global_dnsfile} + fi fi
if kdump_is_bridge "$_netdev"; then @@ -292,8 +296,6 @@ kdump_setup_netdev() { _ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$(kdump_get_mac_addr $_netdev)" echo "$_ifname_opts" >> $_ip_conf fi - - kdump_setup_dns "$_netdev" }
get_ip_route_field()
On 03/03/16 at 10:49am, Xunlei Pang wrote:
Currently kdump uses dracut's "nameserver=" command to hande DNS,
handle
it is acquired both from ifcfg files and "/etc/resolv.conf".
This is improper for dhcp cases, as "/etc/resolv.conf" is generated by dhcp, the proper logic should be:
- For static cases, DNS can be acquired from corresponding ifcfg file.
- For dhcp cases, DNS is normally generated by dhcp, but extra DNS can still be specified in the ifcfg files mannually.
- For special user-assigned DNS not specified in any ifcfg file, we can pass it to dracut via "nameserver=".
This patch may cause a regression, since kdump doesn't take care of /etc/resolv.conf. Kdump kernel cann't get proper DNS, if it is appended manually in /etc/resolv.conf.
https://bugzilla.redhat.com/show_bug.cgi?id=1196085
This patch improves the logic using the following "ip=" command format provided by dracut: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>: <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]]
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-module-setup.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..a18fdc0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -63,26 +63,19 @@ kdump_is_vlan() { }
# $1: netdev name -kdump_setup_dns() {
- local _nameserver _dns
- local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
- . /etc/sysconfig/network-scripts/ifcfg-$1
- [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
- [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
+# return pattern ":<dns1>[<:dns2>]" if not "" +kdump_get_dns_from_ifcfg() {
- local _dns
- while read content;
- do
_nameserver=$(echo $content | grep ^nameserver)
[ -z "$_nameserver" ] && continue
- unset DNS1 DNS2
- if [ -e /etc/sysconfig/network-scripts/ifcfg-$1 ]; then
. /etc/sysconfig/network-scripts/ifcfg-$1
- fi
_dns=$(echo $_nameserver | cut -d' ' -f2)
[ -z "$_dns" ] && continue
- [ -n "$DNS1" ] && _dns=${_dns}:$(echo $DNS1)
- [ -n "$DNS2" ] && _dns=${_dns}:$(echo $DNS2)
if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
echo "nameserver=$_dns" >> "$_dnsfile"
fi
- done < "/etc/resolv.conf"
- echo -n "${_dns}" | cut -d':' -f1,2,3
Do we need to consider the case of IPv6 DNS?
}
#$1: netdev name @@ -254,22 +247,27 @@ kdump_setup_znet() { # Setup dracut to bringup a given network interface kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2
- local _static _proto _ip_conf _ip_opts _ifname_opts
local _static _proto _ip_conf _ip_opts _ifname_opts _ifcfg_dns
local _global_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev fi
- _netmac=$(kdump_get_mac_addr $_netdev)
- # Using below "ip=" command format provided by dracut:
- # ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:
- # <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]] _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none else _proto=dhcp
_static=":::::"
Is this $_static necessary if the mode is dhcp, since there is no assignment for _static previously?
fi
- _ifcfg_dns=$(kdump_get_dns_from_ifcfg $_netdev) _ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
- _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}${_ifcfg_dns}"
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates
@@ -278,6 +276,12 @@ kdump_setup_netdev() { if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf
# In case of no DNS specified by iscsi.
if [ -n "${_ifcfg_dns}" ]; then
_ifcfg_dns=${_ifcfg_dns##:}
echo "nameserver=${_ifcfg_dns%%:*}" >> ${_global_dnsfile}
[ "${_ifcfg_dns}" = "${_ifcfg_dns%%:*}" ] || echo "nameserver=${_ifcfg_dns##*:}" >> ${_global_dnsfile}
fi
I have a trouble understand why there is extra dns config for iSCSI?
Thanks Minfei
On 03/03/2016 at 11:40 AM, Minfei Huang wrote:
On 03/03/16 at 10:49am, Xunlei Pang wrote:
Currently kdump uses dracut's "nameserver=" command to hande DNS,
handle
it is acquired both from ifcfg files and "/etc/resolv.conf".
This is improper for dhcp cases, as "/etc/resolv.conf" is generated by dhcp, the proper logic should be:
- For static cases, DNS can be acquired from corresponding ifcfg file.
- For dhcp cases, DNS is normally generated by dhcp, but extra DNS can still be specified in the ifcfg files mannually.
- For special user-assigned DNS not specified in any ifcfg file, we can pass it to dracut via "nameserver=".
This patch may cause a regression, since kdump doesn't take care of /etc/resolv.conf. Kdump kernel cann't get proper DNS, if it is appended manually in /etc/resolv.conf.
IIRC(I will double check that) I've tested the case that adding manually a DNS entry into /etc/resolv.conf, after reboot the manually added entry will be cleaned up by the system using that in the ifcfg files.
This patch improves the logic using the following "ip=" command format provided by dracut: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>: <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]]
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-module-setup.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..a18fdc0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -63,26 +63,19 @@ kdump_is_vlan() { }
# $1: netdev name -kdump_setup_dns() {
- local _nameserver _dns
- local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
- . /etc/sysconfig/network-scripts/ifcfg-$1
- [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
- [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
+# return pattern ":<dns1>[<:dns2>]" if not "" +kdump_get_dns_from_ifcfg() {
- local _dns
- while read content;
- do
_nameserver=$(echo $content | grep ^nameserver)
[ -z "$_nameserver" ] && continue
- unset DNS1 DNS2
- if [ -e /etc/sysconfig/network-scripts/ifcfg-$1 ]; then
. /etc/sysconfig/network-scripts/ifcfg-$1
- fi
_dns=$(echo $_nameserver | cut -d' ' -f2)
[ -z "$_dns" ] && continue
- [ -n "$DNS1" ] && _dns=${_dns}:$(echo $DNS1)
- [ -n "$DNS2" ] && _dns=${_dns}:$(echo $DNS2)
if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
echo "nameserver=$_dns" >> "$_dnsfile"
fi
- done < "/etc/resolv.conf"
- echo -n "${_dns}" | cut -d':' -f1,2,3
Do we need to consider the case of IPv6 DNS?
}
#$1: netdev name @@ -254,22 +247,27 @@ kdump_setup_znet() { # Setup dracut to bringup a given network interface kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2
- local _static _proto _ip_conf _ip_opts _ifname_opts
local _static _proto _ip_conf _ip_opts _ifname_opts _ifcfg_dns
local _global_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev fi
- _netmac=$(kdump_get_mac_addr $_netdev)
- # Using below "ip=" command format provided by dracut:
- # ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:
- # <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]] _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none else _proto=dhcp
_static=":::::"
Is this $_static necessary if the mode is dhcp, since there is no assignment for _static previously?
fi
- _ifcfg_dns=$(kdump_get_dns_from_ifcfg $_netdev) _ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
- _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}${_ifcfg_dns}"
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates
@@ -278,6 +276,12 @@ kdump_setup_netdev() { if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf
# In case of no DNS specified by iscsi.
if [ -n "${_ifcfg_dns}" ]; then
_ifcfg_dns=${_ifcfg_dns##:}
echo "nameserver=${_ifcfg_dns%%:*}" >> ${_global_dnsfile}
[ "${_ifcfg_dns}" = "${_ifcfg_dns%%:*}" ] || echo "nameserver=${_ifcfg_dns##*:}" >> ${_global_dnsfile}
fi
I have a trouble understand why there is extra dns config for iSCSI?
If there is already an "ip=" command with no DNS specified, then we will lose the DNS information collected in the 2nd "ip=" which is acquired from ifcfg file
Regards, Xunlei
Thanks Minfei
On 03/03/16 at 12:21pm, Xunlei Pang wrote:
On 03/03/2016 at 11:40 AM, Minfei Huang wrote:
On 03/03/16 at 10:49am, Xunlei Pang wrote:
Currently kdump uses dracut's "nameserver=" command to hande DNS,
handle
it is acquired both from ifcfg files and "/etc/resolv.conf".
This is improper for dhcp cases, as "/etc/resolv.conf" is generated by dhcp, the proper logic should be:
- For static cases, DNS can be acquired from corresponding ifcfg file.
- For dhcp cases, DNS is normally generated by dhcp, but extra DNS can still be specified in the ifcfg files mannually.
- For special user-assigned DNS not specified in any ifcfg file, we can pass it to dracut via "nameserver=".
This patch may cause a regression, since kdump doesn't take care of /etc/resolv.conf. Kdump kernel cann't get proper DNS, if it is appended manually in /etc/resolv.conf.
IIRC(I will double check that) I've tested the case that adding manually a DNS entry into /etc/resolv.conf, after reboot the manually added entry will be cleaned up by the system using that in the ifcfg files.
Yes, /etc/resolv.conf will be re-generated after booting. For production environment, it is more convenience to use script to append manual DNS.
This patch improves the logic using the following "ip=" command format provided by dracut: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>: <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]]
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-module-setup.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..a18fdc0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -63,26 +63,19 @@ kdump_is_vlan() { }
# $1: netdev name -kdump_setup_dns() {
- local _nameserver _dns
- local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
- . /etc/sysconfig/network-scripts/ifcfg-$1
- [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
- [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
+# return pattern ":<dns1>[<:dns2>]" if not "" +kdump_get_dns_from_ifcfg() {
- local _dns
- while read content;
- do
_nameserver=$(echo $content | grep ^nameserver)
[ -z "$_nameserver" ] && continue
- unset DNS1 DNS2
- if [ -e /etc/sysconfig/network-scripts/ifcfg-$1 ]; then
. /etc/sysconfig/network-scripts/ifcfg-$1
- fi
_dns=$(echo $_nameserver | cut -d' ' -f2)
[ -z "$_dns" ] && continue
- [ -n "$DNS1" ] && _dns=${_dns}:$(echo $DNS1)
- [ -n "$DNS2" ] && _dns=${_dns}:$(echo $DNS2)
if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
echo "nameserver=$_dns" >> "$_dnsfile"
fi
- done < "/etc/resolv.conf"
- echo -n "${_dns}" | cut -d':' -f1,2,3
Do we need to consider the case of IPv6 DNS?
}
#$1: netdev name @@ -254,22 +247,27 @@ kdump_setup_znet() { # Setup dracut to bringup a given network interface kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2
- local _static _proto _ip_conf _ip_opts _ifname_opts
local _static _proto _ip_conf _ip_opts _ifname_opts _ifcfg_dns
local _global_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev fi
- _netmac=$(kdump_get_mac_addr $_netdev)
- # Using below "ip=" command format provided by dracut:
- # ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:
- # <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]] _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none else _proto=dhcp
_static=":::::"
Is this $_static necessary if the mode is dhcp, since there is no assignment for _static previously?
fi
- _ifcfg_dns=$(kdump_get_dns_from_ifcfg $_netdev) _ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
- _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}${_ifcfg_dns}"
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates
@@ -278,6 +276,12 @@ kdump_setup_netdev() { if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf
# In case of no DNS specified by iscsi.
if [ -n "${_ifcfg_dns}" ]; then
_ifcfg_dns=${_ifcfg_dns##:}
echo "nameserver=${_ifcfg_dns%%:*}" >> ${_global_dnsfile}
[ "${_ifcfg_dns}" = "${_ifcfg_dns%%:*}" ] || echo "nameserver=${_ifcfg_dns##*:}" >> ${_global_dnsfile}
fi
I have a trouble understand why there is extra dns config for iSCSI?
If there is already an "ip=" command with no DNS specified, then we will lose the DNS information collected in the 2nd "ip=" which is acquired from ifcfg file
If then, this block may be resident in else branch?
Thanks Minfei
On 03/03/2016 at 12:42 PM, Minfei Huang wrote:
On 03/03/16 at 12:21pm, Xunlei Pang wrote:
On 03/03/2016 at 11:40 AM, Minfei Huang wrote:
On 03/03/16 at 10:49am, Xunlei Pang wrote:
Currently kdump uses dracut's "nameserver=" command to hande DNS,
handle
it is acquired both from ifcfg files and "/etc/resolv.conf".
This is improper for dhcp cases, as "/etc/resolv.conf" is generated by dhcp, the proper logic should be:
- For static cases, DNS can be acquired from corresponding ifcfg file.
- For dhcp cases, DNS is normally generated by dhcp, but extra DNS can still be specified in the ifcfg files mannually.
- For special user-assigned DNS not specified in any ifcfg file, we can pass it to dracut via "nameserver=".
This patch may cause a regression, since kdump doesn't take care of /etc/resolv.conf. Kdump kernel cann't get proper DNS, if it is appended manually in /etc/resolv.conf.
IIRC(I will double check that) I've tested the case that adding manually a DNS entry into /etc/resolv.conf, after reboot the manually added entry will be cleaned up by the system using that in the ifcfg files.
Yes, /etc/resolv.conf will be re-generated after booting. For production environment, it is more convenience to use script to append manual DNS.
Yes, so in my view, we can ignore /etc/resolv.conf completely.
This patch improves the logic using the following "ip=" command format provided by dracut: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>: <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]]
Signed-off-by: Xunlei Pang xlpang@redhat.com
dracut-module-setup.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4cd7107..a18fdc0 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -63,26 +63,19 @@ kdump_is_vlan() { }
# $1: netdev name -kdump_setup_dns() {
- local _nameserver _dns
- local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
- . /etc/sysconfig/network-scripts/ifcfg-$1
- [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
- [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
+# return pattern ":<dns1>[<:dns2>]" if not "" +kdump_get_dns_from_ifcfg() {
- local _dns
- while read content;
- do
_nameserver=$(echo $content | grep ^nameserver)
[ -z "$_nameserver" ] && continue
- unset DNS1 DNS2
- if [ -e /etc/sysconfig/network-scripts/ifcfg-$1 ]; then
. /etc/sysconfig/network-scripts/ifcfg-$1
- fi
_dns=$(echo $_nameserver | cut -d' ' -f2)
[ -z "$_dns" ] && continue
- [ -n "$DNS1" ] && _dns=${_dns}:$(echo $DNS1)
- [ -n "$DNS2" ] && _dns=${_dns}:$(echo $DNS2)
if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
echo "nameserver=$_dns" >> "$_dnsfile"
fi
- done < "/etc/resolv.conf"
- echo -n "${_dns}" | cut -d':' -f1,2,3
Do we need to consider the case of IPv6 DNS?
}
#$1: netdev name @@ -254,22 +247,27 @@ kdump_setup_znet() { # Setup dracut to bringup a given network interface kdump_setup_netdev() { local _netdev=$1 _srcaddr=$2
- local _static _proto _ip_conf _ip_opts _ifname_opts
local _static _proto _ip_conf _ip_opts _ifname_opts _ifcfg_dns
local _global_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
if [ "$(uname -m)" = "s390x" ]; then kdump_setup_znet $_netdev fi
- _netmac=$(kdump_get_mac_addr $_netdev)
- # Using below "ip=" command format provided by dracut:
- # ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:
- # <interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<dns1>][:<dns2>]] _static=$(kdump_static_ip $_netdev $_srcaddr) if [ -n "$_static" ]; then _proto=none else _proto=dhcp
_static=":::::"
Is this $_static necessary if the mode is dhcp, since there is no assignment for _static previously?
fi
- _ifcfg_dns=$(kdump_get_dns_from_ifcfg $_netdev) _ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
- _ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}${_ifcfg_dns}"
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same. # so we have to avoid adding duplicates
@@ -278,6 +276,12 @@ kdump_setup_netdev() { if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\ ! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then echo "$_ip_opts" >> $_ip_conf
# In case of no DNS specified by iscsi.
if [ -n "${_ifcfg_dns}" ]; then
_ifcfg_dns=${_ifcfg_dns##:}
echo "nameserver=${_ifcfg_dns%%:*}" >> ${_global_dnsfile}
[ "${_ifcfg_dns}" = "${_ifcfg_dns%%:*}" ] || echo "nameserver=${_ifcfg_dns##*:}" >> ${_global_dnsfile}
fi
I have a trouble understand why there is extra dns config for iSCSI?
If there is already an "ip=" command with no DNS specified, then we will lose the DNS information collected in the 2nd "ip=" which is acquired from ifcfg file
If then, this block may be resident in else branch?
Ah, right, thanks for the catch. Will modify that.
Regards, Xunlei
Thanks Minfei
On 03/03/16 at 01:07pm, Xunlei Pang wrote:
On 03/03/2016 at 12:42 PM, Minfei Huang wrote:
On 03/03/16 at 12:21pm, Xunlei Pang wrote:
On 03/03/2016 at 11:40 AM, Minfei Huang wrote:
On 03/03/16 at 10:49am, Xunlei Pang wrote:
Currently kdump uses dracut's "nameserver=" command to hande DNS,
handle
it is acquired both from ifcfg files and "/etc/resolv.conf".
This is improper for dhcp cases, as "/etc/resolv.conf" is generated by dhcp, the proper logic should be:
- For static cases, DNS can be acquired from corresponding ifcfg file.
- For dhcp cases, DNS is normally generated by dhcp, but extra DNS can still be specified in the ifcfg files mannually.
- For special user-assigned DNS not specified in any ifcfg file, we can pass it to dracut via "nameserver=".
This patch may cause a regression, since kdump doesn't take care of /etc/resolv.conf. Kdump kernel cann't get proper DNS, if it is appended manually in /etc/resolv.conf.
IIRC(I will double check that) I've tested the case that adding manually a DNS entry into /etc/resolv.conf, after reboot the manually added entry will be cleaned up by the system using that in the ifcfg files.
Yes, /etc/resolv.conf will be re-generated after booting. For production environment, it is more convenience to use script to append manual DNS.
Yes, so in my view, we can ignore /etc/resolv.conf completely.
Hmm, I think kdump should handle it as well. For a large number of machines, it is difficult to configure DNS manually in general.
Thanks Minfei
On 03/03/2016 at 01:50 PM, Minfei Huang wrote:
On 03/03/16 at 01:07pm, Xunlei Pang wrote:
On 03/03/2016 at 12:42 PM, Minfei Huang wrote:
On 03/03/16 at 12:21pm, Xunlei Pang wrote:
On 03/03/2016 at 11:40 AM, Minfei Huang wrote:
On 03/03/16 at 10:49am, Xunlei Pang wrote:
Currently kdump uses dracut's "nameserver=" command to hande DNS,
handle
it is acquired both from ifcfg files and "/etc/resolv.conf".
This is improper for dhcp cases, as "/etc/resolv.conf" is generated by dhcp, the proper logic should be:
- For static cases, DNS can be acquired from corresponding ifcfg file.
- For dhcp cases, DNS is normally generated by dhcp, but extra DNS can still be specified in the ifcfg files mannually.
- For special user-assigned DNS not specified in any ifcfg file, we can pass it to dracut via "nameserver=".
This patch may cause a regression, since kdump doesn't take care of /etc/resolv.conf. Kdump kernel cann't get proper DNS, if it is appended manually in /etc/resolv.conf.
IIRC(I will double check that) I've tested the case that adding manually a DNS entry into /etc/resolv.conf, after reboot the manually added entry will be cleaned up by the system using that in the ifcfg files.
Yes, /etc/resolv.conf will be re-generated after booting. For production environment, it is more convenience to use script to append manual DNS.
Yes, so in my view, we can ignore /etc/resolv.conf completely.
Hmm, I think kdump should handle it as well. For a large number of machines, it is difficult to configure DNS manually in general.
For large number of machines, they should rely on dhcp to deploy, specifying DNS directly through /etc/resolv.conf is not standard, the info will be overridden by the info in ifcfg files and dhcp after each reboot (I verified this both on RHEL and fedora), so it would be better if kdump can follow the same way as RHEL and fedora.
If customers want to add extra DNS to kdump, the recommended way is specifying them in the corresponding ifcfg file. But they also can do it through cmdline using dracut's "nameserver=" command, or just specify them in /etc/sysconfig/kdump via KDUMP_COMMANDLINE_APPEND.
Just regard /etc/resolv.conf as a temporary volatile memory.
Regards, Xunlei
Thanks Minfei
On 03/03/16 at 07:40pm, Xunlei Pang wrote:
For large number of machines, they should rely on dhcp to deploy, specifying DNS directly through /etc/resolv.conf is not standard, the info will be overridden by the info in ifcfg files and dhcp after each reboot (I verified this both on RHEL and fedora), so it would be better if kdump can follow the same way as RHEL and fedora.
It can be fixed, if there is local script to appending specific DNS after /etc/resolv.conf being generated by NM.
If customers want to add extra DNS to kdump, the recommended way is specifying them in the corresponding ifcfg file. But they also can do it through cmdline using dracut's "nameserver=" command, or just specify them in /etc/sysconfig/kdump via KDUMP_COMMANDLINE_APPEND.
Just regard /etc/resolv.conf as a temporary volatile memory.
The net device name may be different with other machines. It's hard to configurate DNS in ifcfg-$dev using script.
Thanks Minfei
On 03/03/2016 at 08:01 PM, Minfei Huang wrote:
On 03/03/16 at 07:40pm, Xunlei Pang wrote:
For large number of machines, they should rely on dhcp to deploy, specifying DNS directly through /etc/resolv.conf is not standard, the info will be overridden by the info in ifcfg files and dhcp after each reboot (I verified this both on RHEL and fedora), so it would be better if kdump can follow the same way as RHEL and fedora.
It can be fixed, if there is local script to appending specific DNS after /etc/resolv.conf being generated by NM.
Then in dhcp cases we can't decide whether one entry in /etc/resolv.conf is generated by dhcp or user local scripts. It will make some trouble if dealing with /etc/resolv.conf especially in the dhcp cases.
Also what if the local script appends DNS to /etc/resolv.conf dynamically: one day generate 1.1.1.1, another day generate 2.2.2.2 instead of 1.1.1.1, so it's hard to support all those non-standard and peculiar cases.
Regards, Xunlei
If customers want to add extra DNS to kdump, the recommended way is specifying them in the corresponding ifcfg file. But they also can do it through cmdline using dracut's "nameserver=" command, or just specify them in /etc/sysconfig/kdump via KDUMP_COMMANDLINE_APPEND.
Just regard /etc/resolv.conf as a temporary volatile memory.
The net device name may be different with other machines. It's hard to configurate DNS in ifcfg-$dev using script.
Thanks Minfei