Para configurar duas interfaces, diga que eth0 e eth1 usam duas redes 192.168.0.0/24
e 10.10.0.0/24
uma ferramenta iproute2
pode ser usado para conseguir isso.
Etapas:
-
Edite seu
/etc/network/interfaces
:auto lo iface lo inet loopback # The primary network interface allow-hotplug eth0 iface eth0 inet static address 192.168.0.10 netmask 255.255.255.0 gateway 192.168.0.1 # The secondary network interface allow-hotplug eth1 iface eth1 inet static address 10.10.0.10 netmask 255.255.255.0
-
Adicione a segunda tabela de roteamento editando '/ etc / iproute2 / rt_tables:
# # reserved values # 255 local 254 main 253 default 0 unspec # # local # #1 inr.ruhep 1 rt2
-
Preencha a nova tabela de roteamento:
ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2 ip route add default via 10.10.0.1 dev eth1 table rt2 # The first command says that the network, 10.10.0.0/24, can be reached through the eth1 interface. # The second command sets the default gateway.
-
Adicione regras de roteamento:
ip rule add from 10.10.0.10/32 table rt2 ip rule add to 10.10.0.10/32 table rt2 # These rules say that both traffic from the IP address, 10.10.0.10, as well as traffic directed to # or through this IP address, should use the rt2 routing table
-
Tornando a configuração permanente adicionando-a a
/etc/network/interfaces
:iface eth1 inet static address 10.10.0.10 netmask 255.255.255.0 post-up ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2 post-up ip route add default via 10.10.0.1 dev eth1 table rt2 post-up ip rule add from 10.10.0.10/32 table rt2 post-up ip rule add to 10.10.0.10/32 table rt2
Fonte: