Archive for the ‘linux’ Category

Virtual interfaces under linux.

Friday, January 15th, 2010

As with other operating systems it is possible to bring multiple service ip-addresses online under one physical NIC under linux. This is just at brief howto on doing it.

ubuntu:

sudo vi /etc/network/interfaces
# The primary network interface
auto eth0
iface eth0 inet static
 address 192.168.1.2
 netmask 255.255.255.0
 network 192.168.1.0
 broadcast 192.168.1.255
 gateway 192.168.1.1
# The first virtual interface
auto eth0:1
iface eth0:1 inet static
 address 192.168.1.100
 netmask 255.255.255.0
 broadcast 192.168.1.255
 gateway 192.168.1.1

After you have edited that file, issue

sudo /etc/init.d/networking restart

RHEL (Redhat)/Centos:

cd /etc/sysconfig/network-scripts
 sudo cp ifcfg-eth0 ifcfg-eth0:0
 sudo vi ifcfg-eth0:0

 cat ifcfg-eth0:0

 > DEVICE=eth0:0
 > BOOTPROTO=none
 > IPADDR=192.168.1.100
 >  NETMASK=255.255.255.0
 > GATEWAY=192.168.100
 > ONBOOT=yes

After that, issue

sudo service network restart