networking - 了解路由表条目

标签 networking routes

我想问一个关于Linux下route命令的问题。我已在 Linux 终端中输入以下命令

> 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

任何人都可以向我解释一下此条目在数据包发出和到达我的主机方面的含义吗?

最佳答案

让我们逐一浏览一下这些行:

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 发出(除非更具体的路由覆盖此路由)。

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0

这表示目的地为 192.168.122.0 到 192.168.122.255 的任何数据包都将在不使用网关的情况下发送到 virbr0。 (同样,除非更具体的路线覆盖此路线。)

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
link-local      *               255.255.0.0     U     1000   0        0 eth0

这表示任何带有 link-local address 的数据包将被发送到没有网关的接口(interface)eth0

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

这表示任何发送到没有其他路由的目的地的数据包都将使用 192.168.1.1 作为网关从 eth0 发出。

关于networking - 了解路由表条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8599424/

相关文章:

routes - 将路由与 Symfony 中的当前请求进行比较

Laravel错误: Unable to prepare route [login] for serialization

javascript - 类似 url 的 AngularJS 正则表达式路由以加载不同的 Controller 和 View

azure - 谁在 Azure 中的 VNet 内使用子网

url - Angular2 反向/从路由生成 url( typescript )

c - 如何停止自己的广播消息?

networking - 有没有firefox OS的广告网络

php - 如何最好地实现数据库驱动的动态 url/ Controller 名称?

c++ - 查找 DNS 服务器和网关的 IP 和 MAC 地址

python - 如何检测 Linux 上 Twisted 的非正常断开连接?