Eu criei duas interfaces estáticas, eth0 e eth1. Aqui está como meu arquivo /etc/network/interfaces
se parece.
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
# This is an autoconfigured IPv6 interface
auto eth0
iface eth0 inet static
#iface eth0 inet static
address 192.168.2.42
netmask 255.255.252.0
gateway 192.168.0.11
dns-nameserver 192.168.1.7
auto eth1
iface eth1 inet static
address 192.168.2.44
netmask 255.255.252.0
gateway 192.168.0.11
dns-nameserver 192.168.1.7
O eth0 funciona perfeitamente e eu posso pingar no IP da eth1 de outra máquina na rede. O problema é que eu não posso pingar para qualquer outra máquina através da eth1:
aneesh@worker42:~$ ping -Ieth0 -c5 192.168.1.15
PING 192.168.1.15 (192.168.1.15) from 192.168.2.42 eth0: 56(84) bytes of data.
64 bytes from 192.168.1.15: icmp_seq=1 ttl=64 time=0.140 ms
64 bytes from 192.168.1.15: icmp_seq=2 ttl=64 time=0.131 ms
64 bytes from 192.168.1.15: icmp_seq=3 ttl=64 time=0.149 ms
64 bytes from 192.168.1.15: icmp_seq=4 ttl=64 time=0.153 ms
64 bytes from 192.168.1.15: icmp_seq=5 ttl=64 time=0.152 ms
--- 192.168.1.15 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3997ms
rtt min/avg/max/mdev = 0.131/0.145/0.153/0.008 ms
aneesh@worker42:~$ ping -Ieth1 -c5 192.168.1.15
PING 192.168.1.15 (192.168.1.15) from 192.168.2.44 eth1: 56(84) bytes of data.
From 192.168.2.44 icmp_seq=1 Destination Host Unreachable
From 192.168.2.44 icmp_seq=2 Destination Host Unreachable
From 192.168.2.44 icmp_seq=3 Destination Host Unreachable
From 192.168.2.44 icmp_seq=4 Destination Host Unreachable
From 192.168.2.44 icmp_seq=5 Destination Host Unreachable
--- 192.168.1.15 ping statistics ---
5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4023ms
pipe 3
Eu posso pingar para 192.168.1.44
de 192.168.1.15
:
aneesh@aneesh:~$ ping -c5 192.168.1.44
PING 192.168.1.44 (192.168.1.44) 56(84) bytes of data.
64 bytes from 192.168.1.44: icmp_seq=1 ttl=64 time=0.146 ms
64 bytes from 192.168.1.44: icmp_seq=2 ttl=64 time=0.192 ms
64 bytes from 192.168.1.44: icmp_seq=3 ttl=64 time=0.178 ms
64 bytes from 192.168.1.44: icmp_seq=4 ttl=64 time=0.177 ms
64 bytes from 192.168.1.44: icmp_seq=5 ttl=64 time=0.174 ms
--- 192.168.1.44 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3996ms
rtt min/avg/max/mdev = 0.146/0.173/0.192/0.019 ms
Aqui está a saída de ifconfig
:
aneesh@worker42:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:0f:0b:38
inet addr:192.168.2.42 Bcast:192.168.3.255 Mask:255.255.252.0
inet6 addr: 2001:df0:6000:0:a00:27ff:fe0f:b38/64 Scope:Global
inet6 addr: fe80::a00:27ff:fe0f:b38/64 Scope:Link
inet6 addr: 2001:df0:6000:0:397f:1b8f:468a:9424/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10086 errors:0 dropped:1422 overruns:0 frame:0
TX packets:524 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1190111 (1.1 MB) TX bytes:63594 (63.5 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:4c:fd:42
inet addr:192.168.2.44 Bcast:192.168.3.255 Mask:255.255.252.0
inet6 addr: fe80::a00:27ff:fe4c:fd42/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:2448 (2.4 KB)
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:65536 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2352 (2.3 KB) TX bytes:2352 (2.3 KB)
Tabela de roteamento:
aneesh@worker42:~$ sudo route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.11 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.252.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.252.0 U 0 0 0 eth1
A máquina é uma VM virtualbox rodando o Ubuntu 13.10. A VM possui 2 adaptadores de rede em ponte, eth0 e eth1.
Atualizações:
Mudei o adaptador de rede da eth1 para "hospedar apenas" o IP da eth1 para o da virtualbox (por meio do dhcp): 192.168.56.101. Depois disso, consegui fazer o ping pela eth1. Por que não consigo fazer isso quando o eth1 é um adaptador em ponte com IP - 192.168.2.42?