首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过URL删除ip路由?

问如何通过URL删除ip路由?
EN

Unix & Linux用户
提问于 2018-07-28 16:41:21
回答 1查看 1.1K关注 0票数 1

在运行了一个(可能已损坏) openvpn脚本之后,我有一个IP路由表,其中一个条目是URL:

代码语言:javascript
复制
# netstat -r                                        
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         10.0.0.1        0.0.0.0         UG        0 0          0 wlp58s0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 wlp58s0
google.com      10.0.0.1        255.255.255.255 UGH       0 0          0 wlp58s0

如何删除最后一行?常规方式会引发错误:

代码语言:javascript
复制
# ip route del google.com
Error: any valid prefix is expected rather than "google.com".

如果这重要的话,我现在使用的是gentoo linux。

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2018-07-28 17:19:00

条目google.com不是一个URL;它是一个域名,或者可能是一个主机名。(不过,它可能是URL的一部分。)

如果您使用netstat -rn,您将在第一列中获得IP地址而不是名称。从那里,您可以删除路由-再次引用其网络和子网寻址。

代码语言:javascript
复制
netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         server.roaima   0.0.0.0         UG        0 0          0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
google.com      0.0.0.0         255.255.255.255 UH        0 0          0 eth1

netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.2.2     0.0.0.0         UG        0 0          0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
216.58.198.174  0.0.0.0         255.255.255.255 UH        0 0          0 eth1

route delete -host 216.58.198.174

您也可以使用更新的ip route进行此操作,后者只列出具有IP地址的路由。使用ip route del删除不需要的条目。

票数 5
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/459064

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档