Estou configurando uma caixa Debian como roteador para 4 sub-redes. Para isso, defini 4 interfaces virtuais na NIC em que a LAN está conectada ( eth1
).
eth1 Link encap:Ethernet HWaddr 94:0c:6d:82:0d:98
inet addr:10.1.1.1 Bcast:10.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::960c:6dff:fe82:d98/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6026521 errors:0 dropped:0 overruns:0 frame:0
TX packets:35331299 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:673201397 (642.0 MiB) TX bytes:177276932 (169.0 MiB)
Interrupt:19 Base address:0x6000
eth1:0 Link encap:Ethernet HWaddr 94:0c:6d:82:0d:98
inet addr:10.1.2.1 Bcast:10.1.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:19 Base address:0x6000
eth1:1 Link encap:Ethernet HWaddr 94:0c:6d:82:0d:98
inet addr:10.1.3.1 Bcast:10.1.3.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:19 Base address:0x6000
eth1:2 Link encap:Ethernet HWaddr 94:0c:6d:82:0d:98
inet addr:10.1.4.1 Bcast:10.1.4.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:19 Base address:0x6000
eth2 Link encap:Ethernet HWaddr 6c:f0:49:a4:47:38
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::6ef0:49ff:fea4:4738/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:199809345 errors:0 dropped:0 overruns:0 frame:0
TX packets:158362936 errors:0 dropped:0 overruns:0 carrier:1
collisions:0 txqueuelen:1000
RX bytes:3656983762 (3.4 GiB) TX bytes:1715848473 (1.5 GiB)
Interrupt:27
eth3 Link encap:Ethernet HWaddr 94:0c:6d:82:c8:72
inet addr:192.168.2.5 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::960c:6dff:fe82:c872/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:110814 errors:0 dropped:0 overruns:0 frame:0
TX packets:73386 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16044901 (15.3 MiB) TX bytes:42125647 (40.1 MiB)
Interrupt:20 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:22351 errors:0 dropped:0 overruns:0 frame:0
TX packets:22351 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2625143 (2.5 MiB) TX bytes:2625143 (2.5 MiB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:41358924 errors:0 dropped:0 overruns:0 frame:0
TX packets:23116350 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:3065505744 (2.8 GiB) TX bytes:1324358330 (1.2 GiB)
Eu tenho dois outros computadores conectados a esta rede. Um tem o IP 10.1.1.12 (máscara de sub-rede 255.255.255.0) e o outro 10.1.2.20 (máscara de sub-rede 255.255.255.0). Quero poder acessar 10.1.1.12 a partir de 10.1.2.20.
Como o encaminhamento de pacotes está ativado no roteador e a política da cadeia FORWARD é ACEITAR (e não há outras regras), entendo que não deve haver nenhum problema para executar o ping entre 10.1.2.20 e 10.1.1.12 no roteador.
No entanto, é isso que recebo:
$ ping -c15 10.1.1.12
PING 10.1.1.12 (10.1.1.12): 56 data bytes
Request timeout for icmp_seq 0
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 81d4 0 0000 3f 01 e2b3 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 1
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 899b 0 0000 3f 01 daec 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 2
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 78fe 0 0000 3f 01 eb89 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 3
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 14b8 0 0000 3f 01 4fd0 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 4
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 8ef7 0 0000 3f 01 d590 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 5
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 ec9d 0 0000 3f 01 77ea 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 6
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 70e6 0 0000 3f 01 f3a1 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 7
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 b0d2 0 0000 3f 01 b3b5 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 8
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 f8b4 0 0000 3f 01 6bd3 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 9
Request timeout for icmp_seq 10
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 1c95 0 0000 3f 01 47f3 10.1.2.20 10.1.1.12
Request timeout for icmp_seq 11
Request timeout for icmp_seq 12
Request timeout for icmp_seq 13
92 bytes from router2.mydomain.com (10.1.2.1): Redirect Host(New addr: 10.1.1.12)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 62bc 0 0000 3f 01 01cc 10.1.2.20 10.1.1.12
Por que isso acontece?
Pelo que li, a Redirect Host
resposta tem algo a ver com o fato de os dois hosts estarem na mesma rede e de haver uma rota mais curta (ou pelo que entendi). Eles estão de fato na mesma rede física, mas por que haveria uma rota melhor se eles não estiverem na mesma sub-rede (eles não podem se ver)?
o que estou perdendo?
Algumas informações extras que você pode querer ver:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.8.0.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
127.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 lo
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
10.8.0.0 10.8.0.2 255.255.255.0 UG 0 0 0 tun0
192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth2
10.1.4.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.1.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.1.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth2
0.0.0.0 192.168.2.1 0.0.0.0 UG 100 0 0 eth3
# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
# iptables -L -n -t nat
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- !10.0.0.0/8 10.0.0.0/8
MASQUERADE all -- 10.0.0.0/8 !10.0.0.0/8
Chain OUTPUT (policy ACCEPT)
target prot opt source destination