1

In the CentOS6, we can easily config a ip range(such as:192.168.1.10-192.168.1.254) to a NIC,
but how can we config a ip range in the CentOS7?

I can not use the method in the CentOS6, how to do with in CentOS7?

I can use below method to configure multi ip, but if I have 200 ip, how to do with that?

TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp0s3"
UUID="933cdc9b-b383-4ddd-b219-5a72c69c9cf0"
ONBOOT="yes"
HWADDR="08:00:27:3F:AB:68"
IPADDR0="192.168.1.150"
IPADDR1="192.168.1.151"
IPADDR2="192.168.1.152"
PREFIX0="24"
GATEWAY0="192.168.1.1"
DNS1="192.168.1.1"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"

2 Answers 2

5

You have to use a range file

  1. Edit /etc/sysconfig/network-scripts/ifcfg-enp0s3 and make sure that NM_CONTROLLED is set to NO (preventing the network manager to control the interface is required to use range files)

  2. Create /etc/sysconfig/network-scripts/ifcfg-enp0s3-range:

    IPADDR_START=192.168.1.10
    IPADDR_END=192.168.1.254
    PREFIX=24
    CLONENUM_START=0
    
  3. run systemctl restart network and the changes should be effective.

If you wanted to configure multiple ranges you could create other file (ifcfg-enp3s0-range0, ifcfg-enp3s0-range1, ...)

4
  • This method works for CentOS6 but not CentOS7.
    – lustre
    Commented Aug 11, 2017 at 10:27
  • 2
    I don't have a centos 7 runing at the moment but I really think it works last time I tried. You made sure to set NM_CONTROLLED=NO ?
    – Stolous
    Commented Aug 11, 2017 at 10:37
  • You need to set NM_CONTROLLED="no" even if you do not use network manager or have it installed.
    – Jinxmcg
    Commented Oct 26, 2018 at 16:12
  • I have the latest Centos 7 and this worked for me. The key is keeping NM out of the way for the device you are going to apply the range to.
    – Greg Sims
    Commented Dec 21, 2019 at 1:14
0

You can not set the ip range like CentOS6, in CentOS7 you can write script to archive that:

for I in {5..250}
> do nmcli con mod eth33554960 -ipv4.addresses 192.168.1.${I}/24
> nmcli con mod eth33554960 +ipv4.addresses 192.168.1.${I}/24
> done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .