Adding New IP Addresses to a CentOS/Fedora Server via SSH

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
  • 0 Users Found This Useful
這篇文章有幫助嗎?

相關文章

Disable Ping Response

Disable Ping Response What is a ping: A ping is a simple network utility used to check if a...

How To Block an IP Address

How To Block an IP Address Login to your Linux server via SSH. Blocking an IP Address To block...

How to Change SSH Port in CentOS

How to Change SSH Port in CentOS Login to your server via PuTTY or any other SSH client....

How to Reset MySQL Password

How to Reset MySQL Password If you have forgotten your MySQL root password, follow these steps...

How to Add a Port to iptables in Linux

How to Add a Port to iptables in Linux Note: This document is for reference only. We do not take...