This is my interfaces file:
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
auto eth1
iface eth1 inet static
address 192.168.2.10
netmask 255.255.255.0
gateway 192.168.2.1
If I restart networking daemon I get this error: eth1 is not up
. I want two default gateways to achieve what is mentioned in the accepted answer to the question here. This is how my routing table should be:
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
default 192.168.2.1 0.0.0.0 UG 0 0 0 eth1
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
I got the above table by using ifconfig
and route add default gw
commands. But I want to do it with the /etc/network/interfaces
file. How can I do it?
Update1:
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
up ip route del 192.168.1.0/24
post-up ip route add 192.168.1.0/24 dev eth0 metric 1
up route add default gw 192.168.1.1 metric 1