Adding New IP Addresses to a CentOS/Fedora Server via SSH
Follow the procedure below to add newly assigned IP addresses. These steps are specific to CentOS and Fedora operating systems.
Step 1: Login to the server via SSH
Login to your server as root using SSH.
Step 2: Go to the network-scripts directory
Navigate to the following directory:
cd /etc/sysconfig/network-scripts/
Step 3: Verify the network interface
Check which network interface you’ll be using to add the IP addresses. Typically, this will be eth0
for public IP addresses. You can verify the interface by running:
/sbin/ifconfig
Step 4: Make copies of ifcfg-eth0
Make a copy of the ifcfg-eth0
configuration file for each additional IP address you want to assign. Name them as ifcfg-eth0:0
, ifcfg-eth0:1
, etc.
cp ifcfg-eth0 ifcfg-eth0:0
cp ifcfg-eth0 ifcfg-eth0:1
cp ifcfg-eth0 ifcfg-eth0:2
cp ifcfg-eth0 ifcfg-eth0:3
cp ifcfg-eth0 ifcfg-eth0:4
Step 5: Edit each interface file
Open each new ifcfg-eth0:X
file and update the fields DEVICE
, IPADDR
, and NETMASK
according to the IP addresses you are assigning.
A sample configuration might look like this:
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=34.123.111.21
NETMASK=255.255.255.0
ONBOOT=yes
Step 6: Restart the network
After making the changes, restart the network service to apply the new IP configurations:
/etc/init.d/network restart
Step 7: Verify the assigned IP addresses
To check the newly assigned IP addresses, use the ifconfig
command:
/sbin/ifconfig