了解Windows路由表

use*_*892 5 ip networking routing

This is my current routing table (I rearranged it and grouped it by interface):

     Destination    Network mask          Gateway    Interface        Metric
          0.0.0.0          0.0.0.0    192.168.178.1    192.168.178.28     50

    192.168.178.0    255.255.255.0       On-link    192.168.178.28    306
   192.168.178.28  255.255.255.255       On-link    192.168.178.28    306
  192.168.178.255  255.255.255.255       On-link    192.168.178.28    306
        224.0.0.0        240.0.0.0       On-link    192.168.178.28    306
  255.255.255.255  255.255.255.255       On-link    192.168.178.28    306

        127.0.0.0        255.0.0.0       On-link         127.0.0.1    331 
        127.0.0.1  255.255.255.255       On-link         127.0.0.1    331 
  127.255.255.255  255.255.255.255       On-link         127.0.0.1    331 
        224.0.0.0        240.0.0.0       On-link         127.0.0.1    331 
  255.255.255.255  255.255.255.255       On-link         127.0.0.1    331 

     192.168.56.0    255.255.255.0      On-link      192.168.56.1    281 
     192.168.56.1  255.255.255.255      On-link      192.168.56.1    281 
   192.168.56.255  255.255.255.255      On-link      192.168.56.1    281 
  255.255.255.255  255.255.255.255      On-link      192.168.56.1    281 
        224.0.0.0        240.0.0.0      On-link      192.168.56.1    281 

    192.168.137.0    255.255.255.0      On-link     192.168.137.1    271 
    192.168.137.1  255.255.255.255      On-link     192.168.137.1    271 
  192.168.137.255  255.255.255.255      On-link     192.168.137.1    271 
        224.0.0.0        240.0.0.0      On-link     192.168.137.1    271 
  255.255.255.255  255.255.255.255      On-link     192.168.137.1    271 
Run Code Online (Sandbox Code Playgroud)

a) The first line is the default route that should be taken if no other route matches, correct?. In that case, the packet should be sent over the interface 192.168.178.28 to my default gateway.

Is it correct that from the routing table I can tell that only the NIC with 192.168.178.28 has access to the internet? If the other NICs had, there would have to be an entry for the default gateway for theses NICs as well, right?

b) The line

192.168.178.0    255.255.255.0       On-link    192.168.178.28    306
Run Code Online (Sandbox Code Playgroud)

means that any packet addressed to a host in the 192.168.178 network should leave via the 192.168.178.28 interface (my wireless NIC), right?

c) But what does this entry mean?

   192.168.178.28  255.255.255.255       On-link    192.168.178.28    306
Run Code Online (Sandbox Code Playgroud)

Packets addressed to my computer should be sent via my wireless NIC? I don't really understand this entry. Where would the packet be coming from?

d) And this entry

  192.168.178.255  255.255.255.255       On-link    192.168.178.28    306
Run Code Online (Sandbox Code Playgroud)

is a boradcast, isn't it? So when an application on my pc sends a packet to this address, it is a broadcast to any host inside the 192.168.178 network?

e) And then the next two entries:

 224.0.0.0        240.0.0.0      On-link    192.168.178.28    306
 255.255.255.255  255.255.255.255    On-link    192.168.178.28    306
Run Code Online (Sandbox Code Playgroud)
  • 224.0.0.0 is a multicast, right?
  • And 255.255.255.255 is also a broadcast to any host inside my LAN? What is the differnce to 192.168.178.255 ?
  • And why do these two entries exist for all of my NICs?

f) and one general question: I always thought that only routers have routing tables, but it must be the case that any system than has the IP protocol implemented has a routing table, so every tablet, smartphone and PC, right?

g) And a last one:

192.168.178.28 and 192.168.56.1 are on different subnets (according to the subnet mask). So when I want to send a packet from one to the other, the packet has to go through the router, even though both NICs are on my machine, correct?

Thanks for help and explanations!

小智 5

通常,路由表是按优先级组织的(因此您显示的顺序没有太大意义)。Windows将表倒置显示:最后一条规则是最后一条规则(即,如果所有其他规则均失败,则使用此规则)。

对于每个IP目的地,将按顺序处理整个表,并寻求匹配项。如果多个规则匹配,则使用最小的度量。

a)是,如果没有其他规则与之匹配,则第一行是默认路由。

但是,该接口可以访问Internet并不是完全正确的:它是唯一(希望)知道如何将数据处理到其他规则未提及的其他网络的接口。例如,如果它指向路由器,则可以访问Internet ...

b)是的,这是一个网络入口

c)它是主机条目:如果应用程序绑定到192.168.178.28,并且会将数据发送到该地址。它将使用相同的接口(通常,路由表允许主机条目允许特定主机的特殊规则)

d)是的,它是特定nw的本地网络广播

e)224 ....是多播,是的。255.255.255.255从理论上讲是向全世界广播的。幸运的是,尽管它只传输到本地接口:-)如果执行ping 255.255.255.255,则此规则将“捕获”。ping 192.168.178.255将使用其他规则。

所有接口必须具有完整的路由信息​​,因此默认情况下会为每个nw接口创建所有规则。

f)每个具有IP接口的设备都会有一个路由表。路由器中的表可能要复杂得多,主机通常具有操作系统自动创建的表。

g)否,路由表告诉IP堆栈使用正确的接口作为传出接口,无需发送到路由器。因此,如果您PC中应用程序希望将数据发送到192.168.56.x,它将通过192.168.56.1接口(在您的情况下,它看起来像是虚拟NW卡)发送数据