LinuxMoz

Linux Stuff && Coffee

CentOS HowTo Add IP Address to Interface

| Comments

CentOS how to add multiple IP addresses to the existing network interface, this is also known as “adding a network alias”. Please note – this is not a tutorial for adding an second interface, it adds an additional IP address to the existing network card.

This article is useful for the following:

  • CentOS add IP address
  • Adding a second IP address in CentOS
  • CentOS add multiple IP addresses
  • Add IP address to interface

CentOS Add Second IP Address

1
cd /etc/sysconfg/network-scripts

Copy the existing network script:

1
[root@thor network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1 

After you have copied the file open it and edit it to look like:

1
2
3
4
IPADDR=XXX.XXX.XXX.XXX
NETMASK=255.255.255.0
GATEWAY=XXX.XXX.XXX.XXX
TYPE=Ethernet

Obviously enter your IP address information, I don’t think type=ethernet is actually required.

Confirm the IP address information is correct and restart the network service:

1
service network restart

When the service restarts you should be able to access your server via the new IP address.

Note, you can add multiple IP addresses to the same interface in CentOS by creating fcfg-eth0:1, fcfg-eth0:2, fcfg-eth0:3 and so on…

Comments