diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 6644600e7..47a2c6714 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -702,6 +702,15 @@ elif [ "$1" = "-s" ];then hostname $NODE echo $NODE > /etc/HOSTNAME else + # Extract the first numeric part of the VERSION_ID, ignoring any non-numeric characters. + os_major_version=`cat /etc/os* | grep VERSION_ID | cut -d '=' -f2 | sed s/\"//g | cut -d "." -f1` + + if [[ -z "${os_major_version}" ]] ; then + logger -t xcat -p local4.err "configeth: Could not determine the OS version, defaulting to the RHEL 7 behavior" + log_warn "configeth on $NODE: Could not determine the OS version, defaulting to the RHEL 7 behavior" + os_major_version=7 + fi + #write ifcfg-* file for redhat con_name="xcat-"${str_inst_nic} str_inst_prefix=$(v4mask2prefix ${str_inst_mask}) @@ -715,7 +724,7 @@ elif [ "$1" = "-s" ];then tmp_con_name=${str_inst_nic}"-tmp" nmcli con modify $con_name connection.id $tmp_con_name fi - nmcli con add type ethernet con-name $con_name ifname ${str_inst_nic} ipv4.method manual ipv4.addresses ${str_inst_ip}/${str_inst_prefix} connection.autoconnect-priority 9 + nmcli con add type ethernet con-name $con_name ifname ${str_inst_nic} ipv4.method manual ipv4.addresses ${str_inst_ip}/${str_inst_prefix} connection.autoconnect-priority 9 gw4 ${str_inst_gateway} str_conf_file_1="/etc/sysconfig/network-scripts/ifcfg-xcat-${str_inst_nic}-1" if [ -f $str_conf_file_1 ]; then grep $con_name $str_conf_file_1 >/dev/null 2>/dev/null @@ -732,6 +741,11 @@ elif [ "$1" = "-s" ];then echo "ONBOOT=yes" >> $str_conf_file echo "NAME=${con_name}" >> $str_conf_file echo "HWADDR=${str_inst_mac}" >> $str_conf_file + + # Add GATEWAY to $str_conf_file only if the OS version is above RHEL 7.x. + if (( $os_major_version > 7 )) ; then + echo "GATEWAY=${str_inst_gateway}" >> $str_conf_file + fi fi if [ $networkmanager_active -eq 2 ]; then echo "AUTOCONNECT_PRIORITY=9" >> $str_conf_file @@ -748,13 +762,17 @@ elif [ "$1" = "-s" ];then echo "MTU=${str_inst_mtu}" >> $str_conf_file fi fi - if [ -n "$str_inst_gateway" ];then - grep -i "GATEWAY" /etc/sysconfig/network - if [ $? -eq 0 ];then - sed -i "s/.*GATEWAY.*/GATEWAY=${str_inst_gateway}/i" /etc/sysconfig/network - else - echo "GATEWAY=${str_inst_gateway}" >> /etc/sysconfig/network - fi + + # Add GATEWAY to the network file only if the OS version is RHEL 7.x or below. + if (( $os_major_version < 8 )) ; then + if [ -n "$str_inst_gateway" ];then + grep -i "GATEWAY" /etc/sysconfig/network + if [ $? -eq 0 ];then + sed -i "s/.*GATEWAY.*/GATEWAY=${str_inst_gateway}/i" /etc/sysconfig/network + else + echo "GATEWAY=${str_inst_gateway}" >> /etc/sysconfig/network + fi + fi fi #add extra params i=0