linux添加删除路由命令行,Linux之路由的添加删除(ip route)

#route

#route -n

#ip route show | column -t

1bcece3da946269ea8976caee37f7ecd.png

获取帮助

[root@x101 ~]# man ip route

[root@x101 ~]# ip route help

[root@x101 ~]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1

[root@x101 ~]# ip route del 192.168.0.0 via 0.0.0.0

RTNETLINK answers: No such process

删除路由表指定条目信息

[root@x101 ~]# ip route del 192.168.0.0/24 via 0.0.0.0

[root@x101 ~]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1

[root@x101 ~]#

[root@x101 ~]# ip route help

Usage: ip route { list | flush } SELECTOR

ip route save SELECTOR

ip route restore

ip route showdump

ip route get ADDRESS [ from ADDRESS iif STRING ]

[ oif STRING ] [ tos TOS ]

[ mark NUMBER ]

ip route { add | del | change | append | replace } ROUTE

[root@x101 ~]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1

添加路由表指定路由信息

[root@x101 ~]# ip route add 192.168.0.0/24 via 0.0.0.0 dev eth0 metric 99

[root@x101 ~]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 99 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1

[root@x101 ~]#

添加默认路由信息

[root@x101 ~]# ip route add default via 192.168.1.1(网关地址) dev eth0

[root@x101 ~]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 99 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1

删除默认路由信息

[root@x101 ~]# ip route del default via 192.168.0.1 dev eth0

[root@x101 ~]# route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.0.0 0.0.0.0 255.255.255.0 U 99 0 0 eth0

192.168.0.0 0.0.0.0 255.255.255.0 U 101 0 0 eth1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值