Embora existam vários artigos discutindo sobre o assunto, eu preciso de alguns conselhos, porque ainda estou enfrentando o problema.
Eu tenho 3 interfaces em uma máquina virtual (centésimos 6.6)
[root@localhost network-scripts]# ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN_
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host_
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bf:6e:7b brd ff:ff:ff:ff:ff:ff
inet 192.168.1.140/24 brd 192.168.1.255 scope global eth0
inet6 fe80::20c:29ff:febf:6e7b/64 scope link_
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bf:6e:85 brd ff:ff:ff:ff:ff:ff
inet 172.16.64.7/24 brd 172.16.64.255 scope global eth1
inet6 fe80::20c:29ff:febf:6e85/64 scope link_
valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bf:6e:8f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.151/24 brd 192.168.1.255 scope global eth2
inet6 fe80::20c:29ff:febf:6e8f/64 scope link_
valid_lft forever preferred_lft forever
A eth1 é usada na linha de gerenciamento. Eu quero atribuir 192.168.1.140 e 192.168.1.150 a eth0 e eth2, respectivamente. Como eth0 e eth2 participam de uma mesma sub-rede, eu configurei o roteamento baseado em políticas.
[root@localhost /]# cat /etc/sysconfig/network-scripts/route-eth0
192.168.1.0/24 dev eth0 src 192.168.1.140 table eth0
default via 192.168.1.1 dev eth0 table eth0
[root@localhost /]# cat /etc/sysconfig/network-scripts/route-eth2
192.168.1.0/24 dev eth2 src 192.168.1.151 table eth2
default via 192.168.1.1 dev eth2 table eth2
[root@localhost /]# cat /etc/sysconfig/network-scripts/rule-eth0
from 192.168.1.140 table eth0 priority 1000
[root@localhost /]# cat /etc/sysconfig/network-scripts/rule-eth2
from 192.168.1.151 table eth2 priority 1001
Então eu configurei o seguinte parâmetro em /etc/sysctl.conf
net.ipv4.conf.all.arp_filter = 1
net.ipv4.conf.default.rp_filter = 0
Reiniciou a máquina virtual para ativar as alterações no parâmetro do kernel e na configuração da rede. O resultado na tabela de roteamento é o seguinte.
[root@localhost /]# ip rule show
0: from all lookup local
1000: from 192.168.1.140 lookup eth0
1001: from 192.168.1.151 lookup eth2
32766: from all lookup main
32767: from all lookup default
[root@localhost /]# ip route show table eth0
192.168.1.0/24 dev eth0 scope link src 192.168.1.140
default via 192.168.1.1 dev eth0
[root@localhost /]# ip route show table eth2
192.168.1.0/24 dev eth2 scope link src 192.168.1.151
default via 192.168.1.1 dev eth2
A configuração parecia boa, mas é de alguma forma impossível fazer ping para a Internet.
[root@localhost /]# ping -c 1 -I eth0 8.8.8.8_
PING 8.8.8.8 (8.8.8.8) from 192.168.1.140 eth0: 56(84) bytes of data.
From 192.168.1.140 icmp_seq=1 Destination Host Unreachable
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 3001ms
[root@localhost /]# ping -c 1 -I eth2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.1.151 eth2: 56(84) bytes of data.
From 192.168.1.151 icmp_seq=1 Destination Host Unreachable
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 3003ms
Alguma idéia?
Tags networking routing linux