Administration CentOS Debian Fedora Linux Ubuntu

Assign range of IP addresses to an interface.

Sometimes you may need to assign a wide range of IP addresses to your network interface in Linux systems. Instead of manually creating aliases for the network interface, it is much quicker to use the network ip range instead.

For example, you need to assign the IP range 192.168.10.6 – 192.168.10.100 to your eth0 interface.

Create a range file in /etc/sysconfig/network-scripts/ifcfg-eth0-range0 as below

DEVICE=eth0
BOOTPROTO=static
IPADDR_START=192.168.10.6
IPADDR_END=192.168.10.100
NETMASK=255.255.255.0
CLONENUM_START=1
ONBOOT=yes
TYPE=Ethernet

CLONENUM_START is the number that will be assigned to the first IP alias interface (eth0:1 in this example).

If you need to add more ranges of IPs then just use a different file for eg. ifcfg-eth0-range1, for each one of the ranges. Make sure CLONENUM_START does not overwrite other aliases.

Once you have configured the range/s of IPs you just need to restart the network service in order to activate it

service network restart

Related Articles

  • Denial Of Service: iptables Defense

    Servers sometimes get hit with what are know as DOS attacks. The offending IP address is usually readily available in the logs for the server being hit. If your SSH...
  • Extract Tar Files to a Different Directory

    Syntax Typical Unix tar syntax: tar -xf file.name.tar -C /path/to/directory GNU/tar syntax: tar xf file.tar -C /path/to/directory tar xf file.tar --directory /path/to/directory Example: Extract files to another directory In this...
  • Verify RPM package integrity

    In the case of Centos/RedHat OS, RPM tool can be used to verify the integrity of the installed package and check if any of the package has been compromised or not....
  • How to get rid of ^M characters.

    When you edit a file in Windows and then open in UNIX, you must have seen ^M characters getting appended in the content. How to get rid of it ?...