My Debian server has 2 NICs with 2 VLANs:
- Nic1 = vlan10 = 192.168.10.5 (static)
- Nic2 = vlan20 = 192.168.20.5 (static)
/etc/network/interface:
auto ens192
iface ens192 inet static
address 192.168.10.5
netmask 255.255.255.0
gateway 192.168.10.1
dns-nameservers 127.0.0.1 1.1.1.1 8.8.8.8
auto ens224
iface ens224 inet static
address 192.168.20.5
netmask 255.255.255.0
gateway 192.168.20.1
dns-nameservers 127.0.0.1 1.1.1.1 8.8.8.8
I imagine that if I set nic1 gateway 192.168.10.1, nic2 gateway 192.168.20.1, the traffic to 192.168.10.0/24 will route to nic1, and the same with nic2
But then I got the error, Googled it and found out I can't have 2 gateway in the /etc/network/interface. To achieve what I want, I need to configure static route.
I belive I learned in school that routing table is generated from /etc/network/interface. So my question is: why I'm not allowed to use 2 gateways?