cancel
Showing results for 
Search instead for 
Did you mean: 
sofi
Cadet
Cadet
  • 3,620 Views

How to add multiple IP range in RHEL9

Jump to solution

Hello,

For Rhel 6, 7, and 8, we followed the methods listed below to configure the network. However, Rhel 9 introduced new networking concepts, and we learned how to configure the network using configuration files in /etc/Networkmanager/system-connections. Since we had to add each IP address one by one, To configuring 250–300 IP addresses took longer. Therefore, how can we modify the file or what steps should we take to configure more than 200–300 IP addresses in a range?


# cd /etc/sysconfig/network-scripts/

Create a file named ifcfg-eth0-range0

# vim ifcfg-eth0-range0

Add the following lines as below to add the first set of range (ie..192.168.10.2-6)

ONBOOT=yes
IPADDR_START=192.168.10.2
IPADDR_END=192.168.10.6
NETMASK=255.255.255.248
CLONENUM_START=1


For the same above configuration which is equivalent in RHEL9 ? 

1 Solution

Accepted Solutions
Fran_Garcia
Starfighter Starfighter
Starfighter
  • 3,562 Views

You can use nmcli to add IPs programatically as shown below (note the + preceeding ipv4.address, this tells nmcli to add extra addresses):

# nmcli connection mod 'System eth0' +ipv4.address 192.168.2.21/24

If you need to add a range, you can do that in a quick script like:

for i in {2..6}; do

  nmcli connection mod 'System eth0' +ipv4.address 192.168.2.$i/24

done

 

To remove the IPs, use the "-ipv4.address" modifier:

for i in {2..6}; do

  nmcli connection mod 'System eth0' -ipv4.address 192.168.2.$i/24

done

 

Network-scripts (icfg-*) files are deprecated in RHEL9 and due to be removed in the next major version, so it's best to invest in using nmcli commands, or the RHEL Network ansible role: https://access.redhat.com/articles/3050101 

Cheers

Fran

 

View solution in original post

3 Replies
Fran_Garcia
Starfighter Starfighter
Starfighter
  • 3,563 Views

You can use nmcli to add IPs programatically as shown below (note the + preceeding ipv4.address, this tells nmcli to add extra addresses):

# nmcli connection mod 'System eth0' +ipv4.address 192.168.2.21/24

If you need to add a range, you can do that in a quick script like:

for i in {2..6}; do

  nmcli connection mod 'System eth0' +ipv4.address 192.168.2.$i/24

done

 

To remove the IPs, use the "-ipv4.address" modifier:

for i in {2..6}; do

  nmcli connection mod 'System eth0' -ipv4.address 192.168.2.$i/24

done

 

Network-scripts (icfg-*) files are deprecated in RHEL9 and due to be removed in the next major version, so it's best to invest in using nmcli commands, or the RHEL Network ansible role: https://access.redhat.com/articles/3050101 

Cheers

Fran

 

sofi
Cadet
Cadet
  • 3,527 Views

Yes, that looks good. I think it will function well.

AMC_RHA
Cadet
Cadet
  • 3,523 Views

How can we use nmcli command to name the interfaces like enp1s0:1, enp1s0:2,... etc? because when we use more than 400 ip's all the ip's are name with enp1s0 only, so how can we number them ? 

which parameter replaces the ARPCHECK=0 ? in rhel 9 ? 

0 Kudos
Join the discussion
You must log in to join this conversation.