Multiple IP addresses on the one network interface eth0 CentOS

From vpsget wiki
Jump to: navigation, search

if you need to assign several IP addresses to the 1 network interface on your dedicated server you can do it in several ways:

1. create eth0:1 config file

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1

Edit ifcfg-eth0:1 and change IP and DEVICE section. Also GW if need.For example:

DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.0.15 
NETMASK=255.255.255.0
ONBOOT=yes

Restart network:

service network restart

check with

ifconfig
ip addr list dev eth0


2.OR: Run the next command:

ifconfig eth0:1 10.10.10.45 netmask 255.255.255.0 up  

3. OR: Another command:

ip addr add 10.20.30.176/24 dev eth0