@@ -486,13 +486,25 @@ IPADDR_$ipindex=$nicip" >> $dir/ifcfg-$nic
486
486
if [ $ipindex -eq 1 ]
487
487
then
488
488
if [[ " $OSVER " =~ ^(rhels9| alma9| rocky9) ]]; then
489
- # ipv6
490
- if echo $nicip | grep : 2>&1 1> /dev/null
491
- then
492
- nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
493
- else # ipv4
494
- prefix=$( convert_netmask_to_cidr $netmask )
495
- nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip /$prefix
489
+ if nmcli --field connection.id con show $nic 2>&1 1> /dev/null
490
+ then # modify current connection
491
+ # ipv6
492
+ if echo $nicip | grep : 2>&1 1> /dev/null
493
+ then
494
+ nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
495
+ else # ipv4
496
+ prefix=$( convert_netmask_to_cidr $netmask )
497
+ nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip /$prefix
498
+ fi
499
+ else # create new connection
500
+ # ipv6
501
+ if echo $nicip | grep : 2>&1 1> /dev/null
502
+ then
503
+ nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
504
+ else # ipv4
505
+ prefix=$( convert_netmask_to_cidr $netmask )
506
+ nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip /$prefix
507
+ fi
496
508
fi
497
509
else
498
510
nmcontrol=" "
@@ -540,7 +552,7 @@ IPADDR=$nicip" > $dir/ifcfg-$nic
540
552
value=" ${array_extra_param_values[$i]} "
541
553
echo " $i : name=$name value=$value "
542
554
if [[ " $OSVER " =~ ^(rhels9| alma9| rocky9) ]]; then
543
- nmcli con modify $con_name $name $value
555
+ nmcli con modify $nic $name $value
544
556
else
545
557
grep -i " ${name} " $dir /ifcfg-$nic
546
558
if [ $? -eq 0 ]; then
@@ -553,13 +565,25 @@ IPADDR=$nicip" > $dir/ifcfg-$nic
553
565
done
554
566
else # not the first ip address
555
567
if [[ " $OSVER " =~ ^(rhels9| alma9| rocky9) ]]; then
556
- # ipv6
557
- if echo $nicip | grep : 2>&1 1> /dev/null
558
- then
559
- nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
560
- else # ipv4
561
- prefix=$( convert_netmask_to_cidr $netmask )
562
- nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip /$prefix
568
+ if nmcli --field connection.id con show $nic 2>&1 1> /dev/null
569
+ then # modify current connection
570
+ # ipv6
571
+ if echo $nicip | grep : 2>&1 1> /dev/null
572
+ then
573
+ nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
574
+ else # ipv4
575
+ prefix=$( convert_netmask_to_cidr $netmask )
576
+ nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip /$prefix
577
+ fi
578
+ else # create new connection
579
+ # ipv6
580
+ if echo $nicip | grep : 2>&1 1> /dev/null
581
+ then
582
+ nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
583
+ else # ipv4
584
+ prefix=$( convert_netmask_to_cidr $netmask )
585
+ nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip /$prefix
586
+ fi
563
587
fi
564
588
else
565
589
# ipv6
@@ -620,7 +644,7 @@ IPADDR$ipindex=$nicip"
620
644
value=" ${array_extra_param_values[$i]} "
621
645
echo " $i : name=$name value=$value "
622
646
if [[ " $OSVER " =~ ^(rhels9| alma9| rocky9) ]]; then
623
- nmcli con modify $con_name $name $value
647
+ nmcli con modify $nic $name $value
624
648
else
625
649
grep -i " ${name} " $cfgfile
626
650
if [ $? -eq 0 ]; then
0 commit comments