如何判断是路由器还是交换机?来自专用 LAN 中主机的数据包中的地址?

发布于 2024-08-23 13:33:23 字数 1275 浏览 1 评论 0原文

我在一个校园网络中,网络有层次结构。我们使用代理服务器连接到互联网。我们所有的计算机 IP 都类似于 10.*.*.*

  • 10.1.*.* =>第一系(数学)
    • 10.1.1.* =>本部一楼。
    • 10.1.1.2 =>本楼层默认网关1
    • 10.1.2.* =>本部二楼。
    • 10.1.2.2 =>本楼层默认网关2
    • 10.1.3.* =>本部三楼。
    • 10.1.3.2 =>本楼层默认网关3

其他部门同理

  • 10.2.*.* =>第2系(计算机科学)
    • 10.2.1.* =>本部一楼。
    • 10.2.1.2 =>本楼层默认网关1
    • 10.2.2.* =>本部二楼。
    • 10.2.2.2 =>本楼层默认网关2
    • 10.2.3.* =>本部三楼。
    • 10.2.3.2 =>本楼层默认网关3

3 等。这适用于 30 个这样的部门。我希望你能看到照片。现在,我有以下疑问:

  1. 我想知道用作“默认网关”的硬件(挂在每层楼的走廊上)是路由器还是交换机?我有它的物理地址“00:07:0d:e2:57:fc”/Cisco_e2:57:fc。嗯,我没有任何权限来检查硬件。它被锁在一个盒子里,悬挂在3米高的地方。

  2. 我想知道从我的计算机(我的 IP 是 10.3.2.47)发送并由 google.com 接收的数据包的 IP 标头中的 src 地址是什么。这是我的本地 IP 地址吗?这不会造成问题吗? google.com 如何再次向我发送回复数据包?因为我的电脑在校园之外是看不见的。

  3. 如果我想将数据包从我的机器(10.3.2.47)发送到另一个像我的私有局域网中的计算机,该怎么办?对中国大学数学系的一个人说。他的 IP 地址可能是 (10.3.2.57),甚至是我的 IP 地址 (10.3.2.47)。

我真的很好奇私人局域网中的计算机与外界之间的通信是如何发生的。

I'm in a campus network, Where the network has an hierarchy. We connect to internet using Proxy servers. All our computer IPs are something like 10.*.*.*.

  • 10.1.*.* => Dept 1 (mathematics)
    • 10.1.1.* => 1st floor of this dept.
    • 10.1.1.2 => Default gateway for this floor1
    • 10.1.2.* => 2nd floor of this dept.
    • 10.1.2.2 => Default gateway for this floor2
    • 10.1.3.* => 3rd floor of this dept.
    • 10.1.3.2 => Default gateway for this floor3

Similarly for other department

  • 10.2.*.* => Dept 2 (computer science)
    • 10.2.1.* => 1st floor of this dept.
    • 10.2.1.2 => Default gateway for this floor1
    • 10.2.2.* => 2nd floor of this dept.
    • 10.2.2.2 => Default gateway for this floor2
    • 10.2.3.* => 3rd floor of this dept.
    • 10.2.3.2 => Default gateway for this floor3

etc.. This goes on for 30 such deparments. I hope you got the picture. Now, I've following queries:

  1. I want to know if the hardware (which is hanging in the corridor of each floor) that is used as "Default Gateway" is a Router or a Switch? I've its physical address "00:07:0d:e2:57:fc" / Cisco_e2:57:fc. Well, I don't have any kind of access to inspect the hardware. Its locked inside a box and hanging at a height of 3 meters.

  2. I'm wondering what would be the src address in the IP Header of a packet that is sent from my computer (my IP is 10.3.2.47) and received by say google.com. Will it be my local IP address? Wouldn't that cause problem? How would google.com again send a reply packet to me? Because my computer is not visible outside my campus.

  3. What if I want to send a packet from my machine( 10.3.2.47) to a computer in another private lan like mine. Say to a guy in mathematics deptartment in university of china. He may have IP address like (10.3.2.57) or even my IP address ( 10.3.2.47).

I'm really curious about how the communication occurs between a computer in private lan and outside world.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ぃ弥猫深巷。 2024-08-30 13:33:23

我无法回答该硬件是路由器还是交换机,但我会回答其他问题。像您在 #3 中建议的那样的私有 IP 地址冲突可以通过网络地址转换解决。对于问题#2,当您的请求发送到互联网时,IP 地址将被转换为适合互联网的地址。执行此操作的路由器或代理会记住您的请求,当响应返回时,它会反转转换并将其发送给 LAN 上您的私有 IP 地址。

编辑:
让我澄清一下,这两种场景都使用 NAT,但代理服务器并不完全执行 NAT,它们有类似的方法。

I can't answer whether that hardware is Router or Switch, but I will answer the other questions. Private IP address conflicts like the one you are suggesting in #3 are resolved by Network Address Translation. For question #2, as your request is sent to the internet, the IP address is translated into one that is suitable for the internet. The router or proxy that is doing this remembers your request and when the response comes back, it reverses the translation and sends it to you on the LAN at your private IP address.

EDIT:
Let me clarify that both of these scenarios use NAT, but a proxy server does not do NAT exactly, they have a similar method.

(り薆情海 2024-08-30 13:33:23
  1. 您可以尝试通过 telnet 或 http 端口与路由器通信。它可能不会让您进入,但其“离开”消息可能会向您提供有关其设备类型的一些信息。

答案2和3正如Segfault所说;维基百科页面值得一读。

  1. You can try talking to the router on its telnet or http port. It probably won't let you in but its "go away" message might give you some information of its device type.

Answers 2 and 3 are as Segfault said; the Wikipedia page is worth a read.

傾城如夢未必闌珊 2024-08-30 13:33:23
  1. 某些硬件同时执行交换机和路由器服务(例如,如果有 4 个端口,其中 2 个用于一个 VLAN,其中 2 个用于另一个 VLAN,则它充当两个 VLAN 之间的路由器,但它也在 2 个 VLAN 之间切换同一 VLAN 上的端口)。在不物理检查网络的情况下,很难判断交换机在哪里,但是如果您开始在交换机上traceroute,许多路由器会识别自己。

  2. google.come 收到的数据包的 IP 标头将由位于网络边缘某处执行 NAT 的计算机(很可能是您的互联网网关计算机)生成。因此,src 地址将是私有地址在 NAT 配置中映射到的任何公共 IP 地址。

  3. 如果您的组织 LAN 中有两个不同的 VLAN,您的流量将不受干扰地穿过它们,但递减的 TTL 除外。如果流量流向同一 vlan 上的不同主机,则可能不会发生任何变化。

  4. 您无法直接通过互联网在两个不同的专用 LAN 之间进行路由。这就是私人寻址的要点;)。任何发往或来自保留私有地址范围(例如 192.168.0.0/16、172.16.0.0/12、10.0.0.0/8)的数据包都将被任何受人尊敬的互联网路由器丢弃在地板上。但是,您可以使用多种 VPN/隧道解决方案中的任何一种在 Internet 上的两个专用网络之间创建隧道。

  1. Some hardware performs both switch and router services (eg if there's 4 ports, 2 of them are for one vlan and 2 of them are for the other, it acts as a router between the two vlans but it also switches between the 2 ports on the same vlan). It can be difficult to tell where switches are without physically inspecting the network, but a lot of routers identify themselves if you start tracerouteing across them.

  2. The IP headers of the packet received by google.come will be generated by a machine doing NAT somewhere on the edge of your network (more than likely your internet gateway machine). Thus the src address will be whatever public IP address the private address is mapped to in the NAT configuration.

  3. In the case of the two different vlans within your organizations LAN, your traffic will traverse them unmolested, except for a decremented TTL. In the case of traffic going to a different host on the same vlan, it will probably be unchanged all together.

  4. You cannot route between two different private LANs ove the internet directly. That's kind of the point of the private addressing ;). Any packets to/from a reserved private address range (eg. 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8) will be dropped on the floor by any respectable internet router. You can, however, create a tunnel between two private networks over the internet using any one of a number of VPN/tunneling solutions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文