2019-03-14 04:40:39 +00:00
|
|
|
# route
|
|
|
|
|
2021-08-02 09:41:09 +01:00
|
|
|
> 手动操作路由表。
|
|
|
|
> 需要 root 权限。
|
2022-07-29 07:13:36 +01:00
|
|
|
> 更多信息:<https://www.manpagez.com/man/8/route/>.
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2021-08-02 09:41:09 +01:00
|
|
|
- 通过网关向目标添加路由:
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2024-01-01 09:38:53 +00:00
|
|
|
`sudo route add "{{路由 ip 地址}}" "{{网关地址}}"`
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2021-08-02 09:41:09 +01:00
|
|
|
- 通过网关向 子网 / 24 添加路由:
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2024-01-01 09:38:53 +00:00
|
|
|
`sudo route add "{{子网 ip}}/24" "{{网关地址}}"`
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2021-08-02 09:41:09 +01:00
|
|
|
- 在测试模式下运行(不做任何操作,只打印):
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2024-01-01 09:38:53 +00:00
|
|
|
`sudo route -t add "{{路由 ip 地址}}/24" "{{网关地址}}"`
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2021-08-02 09:41:09 +01:00
|
|
|
- 删除所有路由:
|
2019-03-14 04:40:39 +00:00
|
|
|
|
|
|
|
`sudo route flush`
|
|
|
|
|
2021-08-02 09:41:09 +01:00
|
|
|
- 删除特定路由:
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2024-01-01 09:38:53 +00:00
|
|
|
`sudo route delete "{{路由 ip 地址}}/24"`
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2021-08-02 09:41:09 +01:00
|
|
|
- 查找并显示目标的路由(主机名或 IP 地址):
|
2019-03-14 04:40:39 +00:00
|
|
|
|
2024-01-01 09:38:53 +00:00
|
|
|
`sudo route get "{{目标}}"`
|