如何在不同子网上的两个IP主机之间发送数据包? [英] How to Send Packets Between Two IP Hosts on Different Subnets?

查看:500
本文介绍了如何在不同子网上的两个IP主机之间发送数据包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主持人1:
10.10.0.1

Host 1: 10.10.0.1

主持人2:
10.10.1.2

Host 2: 10.10.1.2

掩码是:
255.255.255.0

Mask is both: 255.255.255.0

如何从主机1向主机2发送数据包?

How to send a packet from Host 1 to Host 2?

推荐答案

将主机1的默认网关设置为10.10.0 / 24网络和10.10.1 / 24网络上的网关机器。然后在网关机器上启用IP转发。

Set the default gateway of Host 1 to a gateway machine that is on both the 10.10.0/24 network and the 10.10.1/24 network. Then enable IP forwarding on the gateway machine.

除非实际位于同一物理网络上,否则无法直接发送数据包。如果它们位于不同的物理子网上,您会将数据包发送到哪个MAC地址?没有一个 - 因为主机2不在同一物理网络上 - 这就是您将其发送到网关的原因。

You can't send the packet directly unless they are really on the same physical network. If they are on different physical subnets what MAC address would you send the packet to? There isn't one - because Host 2 isn't on the same physical network - that's why you send it to gateway instead.

如果主机1和主机2打开相同的物理网络,那么你不是在寻找一般的解决方案。在这种情况下,您可以发送ARP请求,然后将数据包发送到您收到回复的MAC地址,它将到达主机2 - 通常,TCP / IP数据包通过以太网发送到同一网络上的主机。

If Host 1 and Host 2 are on the same physical network then you aren't looking for a general solution. In that case you can send an ARP request and then send the packet to the MAC address you get the reply from and it will arrive at Host 2 - the same way TCP/IP packets are usually sent over Ethernet to hosts on the same network.

这篇关于如何在不同子网上的两个IP主机之间发送数据包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆