How to assign additional IP's on CentOS Print

  • centos, additional, ip
  • 1

Assigning Additional IPs on CentOS

Over the following guide, we will address how to change/alter your IPs on a CentOS-based operating system. In this case, we will be using the network-script configs in order to efficiently integrate our additional IPs with ease.


Checking Our Interfaces

The first thing we have to do prior to beginning working with our Network Interfaces is actually gathering a list of our interfaces. We can run the following command in order to list all interfaces:

ip a

In this case, we will be using the eth0 interface as a building block for our additional addresses. We will access this by running the following command:

cat /etc/sysconfig/network-scripts/ifcfg-eth0

This will return a display such as the following:

This allows us to edit the eth0 interface configuration file- in the case we wanted to edit a different interface, we could swap the end portion (eth0)- having the file location look like /etc/sysconfig/network-scripts/ifcfg-<your-interface>.

Implementing Our Additional Address

For the implementation of our new address, we are going to use VIM- if you have no knowledge of how to use VIM I highly recommend checking out the VIM documentation here.

We are now going to move forward with implementing our additional addressing using the vim command, though first, we have to install this using:

sudo yum -y install vim

Following this, we have to create a sub-branch of our interface in a sense- by using:

sudo vim /etc/sysconfig/network-scripts/ifcfg-eth0:1

 In this case, we are going to write the following- using :i to insert our text:

DEVICE=eth0:1
BOOTPROTO=none
ONBOOT=yes
IPADDR=45.88.231.114

Within this, we are assigning the name eth0:1 no boot protocol, though it is initiated on boot with the address 45.88.231.114- Be sure to change this to the additional address you are trying to assign.

After inserting the information for our new server we have to :w (write) and :q (quit). Following this we have to reboot our OS to implement our newfound changes using:

sudo reboot

Verifying Our Changes

Following this we have to verify our changes were properly implemented- we can do so simply by running:

ip a

We should now see our newly implemented address listed under our original with a new inet address:

 

There are other methods to integrating additional IP's- such as using NMCLI though this method stems away from external libraries.


Was this answer helpful?

« Back