0.0.0.0 网关的含义 您所在的位置:网站首页 换网关是什么意思 0.0.0.0 网关的含义

0.0.0.0 网关的含义

2023-12-08 11:21| 来源: 网络整理| 查看: 265

简介

使用 route 命令查看linux的路由时候常遇到 gateway为0.0.0.0 的情况(注意不是目标网段),让人很困惑,仔细看看这些网卡往往时候一些虚拟出来的网卡,比如docker0。 0.0.0.0 或者* 表示不需要路由,目标地址和自己属于同一个二层网络,通过ARP协议获取目标的MAC地址后通信,不需要网关的转发,比如一些虚拟网卡,不需要路由。

[root@xxxx ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.0.1 0.0.0.0 UG 100 0 0 eth0 9.251.0.0 172.17.0.1 255.255.0.0 UG 0 0 0 docker0 10.0.0.0 0.0.0.0 255.255.192.0 U 100 0 0 eth0 169.254.169.0 10.0.0.1 255.255.255.0 UG 100 0 0 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0

如果使用 ip route就能看到真实情况,比如172.17.0.0/16 目标地址段是没有网关的,这条规则是由kernel自动生成。

[root@xxxx ~]# ip route show | column -s" " -t default via 10.0.0.1 dev eth0 proto dhcp metric 100 9.251.0.0/16 via 172.17.0.1 dev docker0 10.0.0.0/18 dev eth0 proto kernel scope link src 10.0.0.89 metric 100 169.254.169.0/24 via 10.0.0.1 dev eth0 proto dhcp metric 100 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1

linux 下删除所有路由

ip route flush table main 参考

https://unix.stackexchange.com/questions/94018/what-is-the-meaning-of-0-0-0-0-as-a-gateway https://stackoverflow.com/questions/12768907/how-can-i-align-the-columns-of-tables-in-bash man ip-route iproute详解 https://baturin.org/docs/iproute2/#Link%20group%20management



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有