linuxroute命令安装
linuxroute命令安装详细介绍
在 Linux 里,route 命令属于 net-tools 工具集。不过如今它已经渐渐被 ip 命令替代,ip 命令是 iproute2 工具集的一部分。下面是在不同 Linux 发行版中安装 net-tools 或者使用 ip 命令的说明:
安装
net-tools(用于获取
route 命令)
Debian 或 Ubuntu
在基于 Debian 或者 Ubuntu 的系统中,你可以使用 apt 来安装 net-tools:
bash
updatenet-tools
CentOS 或 Fedora
在基于 CentOS 或者 Fedora 的系统中,你可以使用 yum 或者 dnf 来安装 net-tools:
- CentOS 7 及之前版本:
bash
yum net-tools
- CentOS 8 及之后版本、Fedora:
bash
dnf net-tools
使用
ip 命令替代
route 命令
ip 命令是 iproute2 工具集的一部分,多数 Linux 发行版默认已安装。以下是一些 ip 命令的常用示例:
显示路由表
bash
route show
添加默认网关
bash
route default via 网关地址
删除路由
bash
route del 目标网络
912 ip route del <目标网络>
你可以按照自身需求选择是安装 net-tools 来使用 route 命令,还是直接使用 ip 命令。