免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2654 | 回复: 6
打印 上一主题 下一主题

[通信方式] 内核路由表怎么会有IP地址全0的缺省网关,删都删不掉,没法通信 [复制链接]

论坛徽章:
9
程序设计版块每日发帖之星
日期:2016-02-13 06:20:00数据库技术版块每日发帖之星
日期:2016-06-15 06:20:00数据库技术版块每日发帖之星
日期:2016-06-16 06:20:00数据库技术版块每日发帖之星
日期:2016-06-18 06:20:00程序设计版块每日发帖之星
日期:2016-06-27 06:20:00程序设计版块每日发帖之星
日期:2016-07-09 06:20:00IT运维版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-07-27 06:20:00程序设计版块每日发帖之星
日期:2016-08-18 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-08-22 17:22 |只看该作者 |倒序浏览
本帖最后由 mordorwww 于 2016-08-22 17:41 编辑

删都删不掉,没法通信


root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
0.0.0.0         1.1.1.50        0.0.0.0         UG    0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~#
root@imx6solosabresd:~#
root@imx6solosabresd:~# root@imx6solosabresd:~# ifconfig
data      Link encap:Ethernet  HWaddr 3A:F7:79:3A:05:3A  
          inet6 addr: fe80::38f7:79ff:fe3a:53a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 7A:23:29:F8:7A:FE  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:700 (700.0 B)  TX bytes:700 (700.0 B)

root@imx6solosabresd:~# ifconfig data 1.1.1.3
root@imx6solosabresd:~# ping 1.1.1.5^C
root@imx6solosabresd:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
1.0.0.0         *               255.0.0.0       U     0      0        0 data
root@imx6solosabresd:~# ping 1.1.1.50
PING 1.1.1.50 (1.1.1.50): 56 data bytes
64 bytes from 1.1.1.50: seq=0 ttl=64 time=3.502 ms
^C
--- 1.1.1.50 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 3.502/3.502/3.502 ms
root@imx6solosabresd:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
1.0.0.0         *               255.0.0.0       U     0      0        0 data
root@imx6solosabresd:~#
root@imx6solosabresd:~#
root@imx6solosabresd:~# route add -net 0.0.0.0 netmask 0.0.0.0 gw 1.1.1.5
root@imx6solosabresd:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

default         1.1.1.5         0.0.0.0         UG    0      0        0 data
default         *               0.0.0.0         U     0      0        0 data
1.0.0.0         *               255.0.0.0       U     0      0        0 data
169.254.0.0     *               255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~#
root@imx6solosabresd:~# ping 172.16.20.207
PING 172.16.20.207 (172.16.20.207): 56 data bytes
^C
--- 172.16.20.207 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss
root@imx6solosabresd:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         1.1.1.5         0.0.0.0         UG    0      0        0 data
default         *               0.0.0.0         U     0      0        0 data
1.0.0.0         *               255.0.0.0       U     0      0        0 data
169.254.0.0     *               255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~#
root@imx6solosabresd:~# ifconfig
data      Link encap:Ethernet  HWaddr 3A:F7:79:3A:05:3A  
          inet addr:1.1.1.3  Bcast:1.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::38f7:79ff:fe3a:53a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:25 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 7A:23:29:F8:7A:FE  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:21 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1644 (1.6 KiB)  TX bytes:1644 (1.6 KiB)

root@imx6solosabresd:~#
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
0.0.0.0         1.1.1.50        0.0.0.0         UG    0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~#


root@imx6solosabresd:~# ifconfig
data      Link encap:Ethernet  HWaddr 62:92:A6:FF:354  
          inet addr:1.1.1.3  Bcast:1.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::6092:a6ff:feff:35d4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:224 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 3A:AA:00:99:4F:18  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:75 errors:0 dropped:0 overruns:0 frame:0
          TX packets:75 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:6160 (6.0 KiB)  TX bytes:6160 (6.0 KiB)

论坛徽章:
20
程序设计版块每日发帖之星
日期:2015-08-17 06:20:00程序设计版块每日发帖之星
日期:2016-07-16 06:20:00程序设计版块每日发帖之星
日期:2016-07-18 06:20:00每日论坛发贴之星
日期:2016-07-18 06:20:00黑曼巴
日期:2016-12-26 16:00:3215-16赛季CBA联赛之江苏
日期:2017-06-26 11:05:5615-16赛季CBA联赛之上海
日期:2017-07-21 18:12:5015-16赛季CBA联赛之青岛
日期:2017-09-04 17:32:0515-16赛季CBA联赛之吉林
日期:2018-03-26 10:02:16程序设计版块每日发帖之星
日期:2016-07-15 06:20:0015-16赛季CBA联赛之江苏
日期:2016-07-07 18:37:512015亚冠之萨济拖拉机
日期:2015-08-17 12:21:08
2 [报告]
发表于 2016-08-22 17:37 |只看该作者
跟网卡IP一个网段的路由,不需要nexthop

论坛徽章:
9
程序设计版块每日发帖之星
日期:2016-02-13 06:20:00数据库技术版块每日发帖之星
日期:2016-06-15 06:20:00数据库技术版块每日发帖之星
日期:2016-06-16 06:20:00数据库技术版块每日发帖之星
日期:2016-06-18 06:20:00程序设计版块每日发帖之星
日期:2016-06-27 06:20:00程序设计版块每日发帖之星
日期:2016-07-09 06:20:00IT运维版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-07-27 06:20:00程序设计版块每日发帖之星
日期:2016-08-18 06:20:00
3 [报告]
发表于 2016-08-22 17:43 |只看该作者
本帖最后由 mordorwww 于 2016-08-22 17:51 编辑
nswcfd 发表于 2016-08-22 17:37
跟网卡IP一个网段的路由,不需要nexthop


缺省路由啊,缺省路由没有网关,缺省路由是直连的!




root@imx6solosabresd:~# ifconfig data 1.1.1.3
root@imx6solosabresd:~#
root@imx6solosabresd:~# ifconfig
data      Link encap:Ethernet  HWaddr 92A:27:BC:04:45  
          inet addr:1.1.1.3  Bcast:1.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::90da:27ff:febc:445/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr A6:34:70:AB:51:4F  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:700 (700.0 B)  TX bytes:700 (700.0 B)

root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
root@imx6solosabresd:~# route add default gw 1.1.1.50
root@imx6solosabresd:~#
root@imx6solosabresd:~# ping 1.1.1.50
PING 1.1.1.50 (1.1.1.50): 56 data bytes
64 bytes from 1.1.1.50: seq=0 ttl=64 time=3.516 ms
64 bytes from 1.1.1.50: seq=1 ttl=64 time=1.959 ms
^C
--- 1.1.1.50 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 1.959/2.737/3.516 ms
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         1.1.1.50        0.0.0.0         UG    0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
root@imx6solosabresd:~#
root@imx6solosabresd:~#
root@imx6solosabresd:~# ping 172.16.20.207
PING 172.16.20.207 (172.16.20.207): 56 data bytes
^C
--- 172.16.20.207 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
0.0.0.0         1.1.1.50        0.0.0.0         UG    0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# route del default gw 1.1.1.50
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# route del default gw 0.0.0.0
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# ifconfig
data      Link encap:Ethernet  HWaddr 92A:27:BC:04:45  
          inet addr:1.1.1.3  Bcast:1.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::90da:27ff:febc:445/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr A6:34:70:AB:51:4F  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:13 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1036 (1.0 KiB)  TX bytes:1036 (1.0 KiB)

root@imx6solosabresd:~#

root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# route del default gw 0.0.0.0
root@imx6solosabresd:~# route del default           
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 data
1.0.0.0         0.0.0.0         255.0.0.0       U     0      0        0 data
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 data
root@imx6solosabresd:~#

论坛徽章:
20
程序设计版块每日发帖之星
日期:2015-08-17 06:20:00程序设计版块每日发帖之星
日期:2016-07-16 06:20:00程序设计版块每日发帖之星
日期:2016-07-18 06:20:00每日论坛发贴之星
日期:2016-07-18 06:20:00黑曼巴
日期:2016-12-26 16:00:3215-16赛季CBA联赛之江苏
日期:2017-06-26 11:05:5615-16赛季CBA联赛之上海
日期:2017-07-21 18:12:5015-16赛季CBA联赛之青岛
日期:2017-09-04 17:32:0515-16赛季CBA联赛之吉林
日期:2018-03-26 10:02:16程序设计版块每日发帖之星
日期:2016-07-15 06:20:0015-16赛季CBA联赛之江苏
日期:2016-07-07 18:37:512015亚冠之萨济拖拉机
日期:2015-08-17 12:21:08
4 [报告]
发表于 2016-08-27 20:35 |只看该作者
不好意思,看错了。

它是怎么生成的?
看起来是在 ping 172.16.20.207 的过程中后台产生的?

论坛徽章:
20
程序设计版块每日发帖之星
日期:2015-08-17 06:20:00程序设计版块每日发帖之星
日期:2016-07-16 06:20:00程序设计版块每日发帖之星
日期:2016-07-18 06:20:00每日论坛发贴之星
日期:2016-07-18 06:20:00黑曼巴
日期:2016-12-26 16:00:3215-16赛季CBA联赛之江苏
日期:2017-06-26 11:05:5615-16赛季CBA联赛之上海
日期:2017-07-21 18:12:5015-16赛季CBA联赛之青岛
日期:2017-09-04 17:32:0515-16赛季CBA联赛之吉林
日期:2018-03-26 10:02:16程序设计版块每日发帖之星
日期:2016-07-15 06:20:0015-16赛季CBA联赛之江苏
日期:2016-07-07 18:37:512015亚冠之萨济拖拉机
日期:2015-08-17 12:21:08
5 [报告]
发表于 2016-08-27 21:05 |只看该作者
本帖最后由 nswcfd 于 2016-08-27 21:07 编辑

应该可以删除吧,估计是有后台运行的其它程序在不断尝试添加默认路由?
(以类似route add default dev data的形式)

论坛徽章:
20
程序设计版块每日发帖之星
日期:2015-08-17 06:20:00程序设计版块每日发帖之星
日期:2016-07-16 06:20:00程序设计版块每日发帖之星
日期:2016-07-18 06:20:00每日论坛发贴之星
日期:2016-07-18 06:20:00黑曼巴
日期:2016-12-26 16:00:3215-16赛季CBA联赛之江苏
日期:2017-06-26 11:05:5615-16赛季CBA联赛之上海
日期:2017-07-21 18:12:5015-16赛季CBA联赛之青岛
日期:2017-09-04 17:32:0515-16赛季CBA联赛之吉林
日期:2018-03-26 10:02:16程序设计版块每日发帖之星
日期:2016-07-15 06:20:0015-16赛季CBA联赛之江苏
日期:2016-07-07 18:37:512015亚冠之萨济拖拉机
日期:2015-08-17 12:21:08
6 [报告]
发表于 2016-08-27 21:11 |只看该作者
而且从楼主的命令行里看,执行的route del default都成功了,否则会报SIOCDELRT:no such process的错误。

论坛徽章:
9
程序设计版块每日发帖之星
日期:2016-02-13 06:20:00数据库技术版块每日发帖之星
日期:2016-06-15 06:20:00数据库技术版块每日发帖之星
日期:2016-06-16 06:20:00数据库技术版块每日发帖之星
日期:2016-06-18 06:20:00程序设计版块每日发帖之星
日期:2016-06-27 06:20:00程序设计版块每日发帖之星
日期:2016-07-09 06:20:00IT运维版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-07-27 06:20:00程序设计版块每日发帖之星
日期:2016-08-18 06:20:00
7 [报告]
发表于 2016-08-29 08:45 |只看该作者
nswcfd 发表于 2016-08-27 21:11
而且从楼主的命令行里看,执行的route del default都成功了,否则会报SIOCDELRT:no such process的错误。

偶尔能删成功,一般是删不掉的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP