I have a VPS that has been assigned three IP addresses. Let's say that these are 192.168.123.45/24, 192.168.225.98/23 and 192.168.225.99/23. (The actual addresses are globally routable, but that is irrelevant for the purposes of this question. The netmask lengths, however, are like that.) The two subnets have different gateways, each in the respective subnet (obviously).
Originally, only 192.168.123.45/24 was configured, through
inet stanzas in /etc/networking/interfaces specifying
Now I am trying to configure the other two IP addresses as well. The naïve approach of just adding
auto eth0:1 and
inet eth0:1 stanzas to
interfaces netted me an error
RTNETLINK answers: File exists - Failed to bring up eth0:1.. Googling suggested I should do
ifconfig eth0 add ... followed by
ifconfig eth0:1 netmask ... gw ..., but this feels fragile.
What is the proper way to, on Debian Wheezy, set up virtual interfaces (or even without virtual interfaces) for a single physical interface where the virtual interfaces are to be on different subnets?