ifconfig en0
en0: flags=8863mtu 1500
inet6 fe80::226:8ff:fe09:fbea%en0 prefixlen 64 scopeid 0x4
inet 192.168.155.111 netmask 0xffffff00 broadcast 192.168.155.255
ether 00:26:08:09:fb:ea
media: autoselect (100baseTX) status: active
supported media: none autoselect 10baseT/UTP10baseT/UTP 10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX 100baseTX 1000baseT 1000baseT 1000baseT
sudo route add 1.2.3.4 0.0.0.0
add host 1.2.3.4: gateway 0.0.0.0
ping 1.2.3.4
PING 1.2.3.4 (1.2.3.4): 56 data bytes
ping: sendto: Network is unreachable
ping: sendto: Network is unreachable
ping: sendto: Network is unreachable
^C
--- 1.2.3.4 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss
sudo tcpdump -i en0 "arp"
Password:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on en0, link-type EN10MB (Ethernet), capture size 96 bytes
20:21:51.948290 arp who-has 1.2.3.4 tell 192.168.155.111
20:21:52.580102 arp who-has 1.2.3.4 tell 192.168.155.111
^C
2 packets captured
420 packets received by filter
0 packets dropped by kernel
То есть, по локальной сети система начала отправлять ARP запросы, которые используются лишь при обмене данными внутри локальной сети.
Если же поднять интерфейс 1.2.3.4 с маской 255.255.255.0 на соседней машине, подключенной к этому же свитчу (в моем случае она была с Windows XP), то tcpdump покажет примерно следующее:
21:36:43.368393 arp reply 1.2.3.4 is-at 00:19:b9:4e:e2:91 (oui Unknown)
21:36:43.368556 arp who-has 192.168.155.1 tell 1.2.3.4
И пинг заработает:
macbook-pavel-odincov:~ nrg$ ping 1.2.3.4
PING 1.2.3.4 (1.2.3.4): 56 data bytes
64 bytes from 1.2.3.4: icmp_seq=0 ttl=127 time=0.930 ms
64 bytes from 1.2.3.4: icmp_seq=1 ttl=127 time=0.589 ms
64 bytes from 1.2.3.4: icmp_seq=2 ttl=127 time=0.675 ms
64 bytes from 1.2.3.4: icmp_seq=3 ttl=127 time=0.688 ms
64 bytes from 1.2.3.4: icmp_seq=4 ttl=127 time=0.559 ms
^C
--- 1.2.3.4 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.559/0.688/0.930/0.131 ms
macbook-pavel-odincov:~ nrg$ ping 192.168.155.1
PING 192.168.155.1 (192.168.155.1): 56 data bytes
64 bytes from 192.168.155.1: icmp_seq=0 ttl=255 time=0.447 ms
64 bytes from 192.168.155.1: icmp_seq=1 ttl=255 time=0.423 ms
64 bytes from 192.168.155.1: icmp_seq=2 ttl=255 time=0.444 ms
64 bytes from 192.168.155.1: icmp_seq=3 ttl=255 time=0.430 ms
^C
--- 192.168.155.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.423/0.436/0.447/0.010 ms
А arp в свою очередь закэширует адрес второй машины:
arp -a
? (1.2.3.4) at 0:19:b9:4e:e2:91 on en0 [ethernet]
? (192.168.155.1) at 0:1c:f0:a9:78:9c on en0 [ethernet]
В процессе тестов все работала стабильно, так что, полагаю, данный вариант вполне работоспособен при сопряжении двух различных сетей построенных на одном свитче.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.