Eu consegui!
Em UBUNTU1, tenho meu arquivo /etc/iproute2/rt_tables
como:
root@ubuntu-primary:/home# cat /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
1 net1
2 net2
3 net3
0 unspec
#
# local
#
#1 inr.ruhep
root@ubuntu-primary:/home#
Eu criei regras criadas com comandos:
ip rule add from 192.168.1.101 table net1
ip rule add oif eth1 table net1
ip rule add from 192.168.2.101 table net2
ip rule add oif eth2 table net2
ip rule add from 192.168.3.101 table net3
ip rule add oif eth3 table net3
Agora minhas regras no RPDB são como:
root@ubuntu-primary:/home# ip rule show
0: from all lookup local
32759: from all oif eth3 lookup net3
32760: from all oif eth2 lookup net2
32761: from 192.168.3.101 lookup net3
32762: from 192.168.2.101 lookup net2
32763: from all oif eth1 lookup net1
32765: from 192.168.1.101 lookup net1
32766: from all lookup main
32767: from all lookup default
root@ubuntu-primary:/home#
Então eu criei rotas em cada tabela, net1, net2 e net3 com comandos:
ip route add 192.168.4.0/24 table net1 scope global via 192.168.1.102 dev eth1 src 192.168.1.101
ip route add 192.168.1.0/24 table net1 scope link dev eth1 src 192.168.1.101
ip route add 192.168.4.0/24 table net2 scope global via 192.168.2.102 dev eth2 src 192.168.2.101
ip route add 192.168.2.0/24 table net2 scope link dev eth2 src 192.168.2.101
ip route add 192.168.4.0/24 table net3 scope global via 192.168.3.102 dev eth3 src 192.168.3.101
ip route add 192.168.3.0/24 table net3 scope link dev eth3 src 192.168.3.101
Agora, todas as três novas tabelas de rotas se parecem com:
root@ubuntu-primary:/home# ip route show table net1
192.168.1.0/24 dev eth1 scope link src 192.168.1.101
192.168.4.0/24 via 192.168.1.102 dev eth1 src 192.168.1.101
root@ubuntu-primary:/home#
root@ubuntu-primary:/home# ip route show table net2
192.168.2.0/24 dev eth2 scope link src 192.168.2.101
192.168.4.0/24 via 192.168.2.102 dev eth2 src 192.168.2.101
root@ubuntu-primary:/home#
root@ubuntu-primary:/home# ip route show table net3
192.168.3.0/24 dev eth3 scope link src 192.168.3.101
192.168.4.0/24 via 192.168.3.102 dev eth3 src 192.168.3.101
root@ubuntu-primary:/home#
Minha tabela de rotas principal parece:
root@ubuntu-primary:/home# ip route show table main
169.254.0.0/16 dev eth1 scope link metric 1000
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.101
192.168.2.0/24 dev eth2 proto kernel scope link src 192.168.2.101
192.168.3.0/24 dev eth3 proto kernel scope link src 192.168.3.101
root@ubuntu-primary:/home#
Depois, adicionei essas rotas a UBUNTU3:
ip route add 192.168.1.0/24 scope global via 192.168.4.102 dev eth1
ip route add 192.168.2.0/24 scope global via 192.168.4.102 dev eth1
ip route add 192.168.3.0/24 scope global via 192.168.4.102 dev eth1
E habilitei o encaminhamento de IP em UBUNTU2 com o comando:
echo 1 > /proc/sys/net/ipv4/ip_forward
E agora tudo está funcionando bem.
Eu posso pingar todas as eth1, eth2 e eth3 de UBUNTU1 de UBUNTU3, e posso fazer ping de eth1 de UBUNTU3 de UBUNTU1 com a aplicação de ping de pingamento para a interface como:
ping 192.168.4.103 -I eth1
ping 192.168.4.103 -I eth2
ping 192.168.4.103 -I eth3