格式:
route [-f/-p/[command] [destination] [mask netmask] [gateway] [metric] [dev if]]
command 指定想要进行的操作 add change delete print
destination 指定该路由的网络目标
mask netmask 指定与网络目标相关的子网掩码
gateway 网关
metric 为路由指定一个整数成本指标,当路由表的多个路由进行选择时可以使用
dev if 为可以访问目标的网络接口指定接口索引
** 显示所有路由表
[root@c7 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.181.2 0.0.0.0 UG 100 0 0 ens33 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 192.168.181.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
# 添加一条路由:发往192.168.60.0网段的全部要经过网关192.168.19.1
route add -net 192.168.60.0 netmask 255.255.255.0 gw 192.168.19.1
# 删除一条路由 删除的时候不需要网关
route del -net 192.168.60.0 netmask 255.255.255.0