Virtual IPs in Debian
Posted by Matt Johnson | 2008-02-15 11:25:17
When you setup a virtual IP, you need to modify /etc/networking/interfaces. But before you do it, make a backup of the config file.
cd /etc/networking; cp interfaces interfaces.bak
After you've made a backup, open up interfaces
vi interfaces
Assuming your main ethernet is eth0, make the following changes
auto eth0 iface eth0 inet static address 192.168.1.101 netmask 255.255.255.0 network 192.168.1.0 gateway 192.168.1.1 auto eth0:1 iface eth0:1 inet static address 192.168.1.111 netmask 255.255.255.0 network 192.168.1.0 gateway 192.168.1.1
The first eth0 is setting up the static IP for the eth0 device. eth0:1 is setting another IP for the same ethernet device. Now restart networking
/etc/init.d/networking restart
So now you've got one NIC with two static IPs. Great for load balancers!
