route 路由配置 命令

来源:互联网 发布:samba端口 编辑:程序博客网 时间:2024/03/28 21:09

route 命令:显示和设置路由,可以通过 add|del参数改变路由表 

【支持的地址族】

inet DARPA 互联网

inet6 IPv6

ax25 AMPR AX.25

netrom AMPR NET/ROM

ipx Novell IPX

DDP Appletalk DDP

X25 CCITT X.25

实例解析:(转载)

范例1:显示当前路由

 

[root@hnlinux ~]# route 

Kernel IP routing table

Destination   Gateway     Genmask     Flags Metric Ref  Use Iface

192.168.0.0          255.255.255.0         eth0

default     192.168.0.1   0.0.0.0     UG       eth0

[root@hnlinux ~]# 

 

范例2: 删除默认网关

 

[root@hnlinux ~]# route del default gw 192.168.0.1

 

 

范例3:添加默认网关/设置网关

 

[root@hnlinux ~]# route add default gw 192.168.0.1

 

 

范例4:增加一条路由

 

[root@hnlinux ~]# route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0

[root@hnlinux ~]# route 

Kernel IP routing table

Destination   Gateway     Genmask     Flags Metric Ref  Use Iface

192.168.0.0          255.255.255.0         eth0

224.0.0.0           240.0.0.0           eth0

default     192.168.0.1   0.0.0.0     UG       eth0

[root@hnlinux ~]# 

 

//增加一条 到达244.0.0.0的路由

 

范例5:屏蔽一条路由

 

[root@hnlinux ~]# route add -net 224.0.0.0 netmask 240.0.0.0 reject 

[root@hnlinux ~]# route 

Kernel IP routing table

Destination   Gateway     Genmask     Flags Metric Ref  Use Iface

192.168.0.0          255.255.255.0         eth0

224.0.0.0           240.0.0.0           eth0

default     192.168.0.1   0.0.0.0     UG       eth0

[root@hnlinux ~]# 

 

//增加一条 屏蔽的路由 目的地址为 224.x.x.x 将被拒绝

 

添加默认网关192.168.1.1:
route -p add 0.0.0.0 mask 0.0.0.0 192.168.1.1

 

 

0 0
原创粉丝点击