Alias interfaces defined in /etc/network/interfaces cannot have multiple default gateways. Unfortunately I would like to use the same interface to access 2 different nets, and I need to define 2 addresses and 2 gateways, on the same interface.
This alias interface has to be on eth1 interface because eth0 is used on the local network. If I define only one gateway for the main eth1 interface, and manually do route add default gw 1.2.3.4
for the alias eth1:0 it works.
But I would like it to set up correctly at boot time automatically.
This is my last trial /etc/network/interfaces :
# The loopback network interface
auto lo
iface lo inet loopback
# The external network interface, address on university internal network
auto eth1
iface eth1 inet static
address 172.x.y.33
netmask 255.255.255.224
network 172.x.y.32
broadcast 172.x.y.63
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers x.x.x.x
dns-search mysite.org
# multiple gateways are not allowed, so I try to add them like that:
post-up route add default gw 172.x.y.62 metric 1
pre-down route del default gw 172.x.y.62
# external interface with external world IP address
auto eth1:0
iface eth1:0 inet static
address 1.2.3.1
netmask 255.255.255.128
network 1.2.3.0
broadcast 1.2.3.128
# dns on ensg dns
dns-nameservers x.x.x.x
dns-search mysite.org
# multiple gateways are not allowed, so I try to add them like that:
post-up route add default gw x.x.x.x metric 2
pre-down route del default gw x.x.x.x
# internal network for my cluster
auto eth0
iface eth0 inet static
address 10.1.1.1
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
gateway 10.1.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 10.1.1.1 127.0.0.1
dns-search cluster
But when I try to bring up one interface I get:
root@server:~# ifconfig eth1:0 up
SIOCSIFFLAGS: Cannot assign requested address
I cannot find a further solution on my own, does anyone have an idea?
Thanks, best regards.
SOLUTION:
I have finally solved it like that:
# The primary network interface
auto eth1
iface eth1 inet static
address a.b.c.1
netmask 255.255.255.128
network a.b.c.0
broadcast a.b.c.128
# this is the interface with the default gateway!
gateway a.b.c.126
dns-nameservers a.d.e.f
dns-search mysite.org
auto eth1:0
iface eth1:0 inet static
address 172.x.y.33
netmask 255.255.255.224
network 172.x.y.32
broadcast 172.x.y.63
# multiple gateways are not allowed, so we do it like that
post-up route add -net 172.x.y.32 netmask 255.255.255.224 gw 172.x.y.62
pre-down route del -net 172.x.y.32 netmask 255.255.255.224 gw 172.x.y.62
auto eth0
iface eth0 inet static
address 10.1.1.1
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 10.1.1.1 127.0.0.1
dns-search cluster