web analytics

Blog

CentOS: Adding static IP/ IP range

Tags: ifconfigIP configurationLinux networking

Published on: October 18, 2014 by Sreejith K R

CentOS:  Adding static IP/ IP range

Scenario:

To add static IP – Single IP

Create/edit file named ifcfg-<interface> in /etc/sysconfig/network-scripts/

How to get  Interface Information?
Usually, the interface will be eth0. It can be determined from ifconfig result. Interface is the name under which new IP will be added.

Add the following details :

 DEVICE="interface name to which IP is to be added"

BOOTPROTO="static"

ONBOOT="yes"

IPADDR="IP address to be added"

NETMASK="netmask" 

 

Eg: to add IP 111.92.64.16 as a static IP to eth0:1

DEVICE=”eth0:1″

BOOTPROTO=”static”

ONBOOT=”yes”

IPADDR=”111.92.64.16″

NETMASK=’255.255.255.0″

Then restart the network service or start the interface :

 /etc/init.d/network restart 

or

 service network restart 

or

Start the interface

 ifup eth0:1 

Using setup command

There is a command “setup” which can do this.

1. Run “setup” as root user.
2. Select “Network Configuration” and click “Run Tool”.
3. Select “New Device” and provide the details. Click ok to save.
4. Restart network service.

To add IP range

Create/edit file named ifcfg-<interface>-range0 in /etc/sysconfig/network-scripts/

Add the following details :

 IPADDR_START="starting IP"

IPADDR_END='ending IP"

CLONENUM_START="starting number assigned to virtual interface"

NETMASK='netmask" 

 

Eg: To add IPs 10.10.2.1 to 20.10.2.254

IPADDR_START=”10.10.2.1″

IPADDR_END=’20.10.2.254″

CLONENUM_START=”0″

BOOTPROTO=’static”

ONBOOT=”yes”

This binds the IP 10.10.2.1 to eth0:0 and 10.10.2.1 to eth0:1 and so on.

Then restart the network service or start the interface :

 /etc/init.d/network restart 

OR

 service network restart 

 

Category : General, Howtos, Linux, Troubleshooting

Sreejith K R

Sreejith K R

Sreejith is an early adopter of upcoming technologies and has got immense interest on exploring its features for improving productivity. He is quite proficient in various scripting languages and loves to enhance work flow through development of various automation scripts. He is video game junkie and is a perfect choice for the position of a game tester :-)

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Get new updates

Categories

$0.000 items