问题描述
我想问一个关于Linux中的route命令的问题。我在Linux终端机中输入了以下命令
I want to ask a question about route command in Linux. I have enter following command in Linux terminal
> route
并得到输出:
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 1 0 0 eth0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
link-local * 255.255.0.0 U 1000 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
我不明白。这是否意味着任何ip 192.168.1.0
的数据包都将从 *
网关发出?
为什么将DESTINATION写入那里,不应该将其作为源,因为从主机发出的数据包的源IP为 192.168.1.0
?
I don't understand it. Does this mean that any packet with ip 192.168.1.0
will go out from *
gateway?Why is it DESTINATION written there shouldn't it be source because the packet going out from my host have source IP of 192.168.1.0
?
有人可以向我解释此条目在数据包传出并到达我的主机方面的含义吗?
Can anyone explain me the meaning of this entry in terms of packet going out and coming to my host?
推荐答案
我们一步一步地进行操作:
Let's go through the lines one by one:
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 1 0 0 eth0
这表示具有目的地的任何数据包192.168.1.0到192.168.1.255之间的数据将在不使用网关的情况下发出 eth0
(除非更具体的路由会覆盖此路由)。
This says that any packet with a destination of 192.168.1.0 through 192.168.1.255 will be sent out eth0
without using a gateway (unless a more-specific route overrides this one).
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
这说t目的地为192.168.122.0到192.168.122.255的任何数据包将在不使用网关的情况下从 virbr0
发送出去。 (同样,除非有更特定的路由覆盖此路由。)
This says that any packet with a destination of 192.168.122.0 through 192.168.122.255 will be sent out virbr0
without using a gateway. (Again, unless a more-specific route overrides this one.)
Destination Gateway Genmask Flags Metric Ref Use Iface
link-local * 255.255.0.0 U 1000 0 0 eth0
这表示任何带有将通过接口 eth0 $ c $发送出去c>没有网关。
This says that any packet with a link-local address will be sent out interface eth0
with no gateway.
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
这表示到目的地而没有其他路由的任何数据包将被发送 eth0
,使用192.168.1.1作为网关。
This says that any packet to a destination without another route will be sent out eth0
, using 192.168.1.1 as a gateway.
这篇关于了解路由表条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!