Warning: preg_match(): Unknown modifier '{' in /home/wwwroot/yicool.com.cn/includes/learning_seo_md.php on line 63

Warning: preg_match(): Unknown modifier '{' in /home/wwwroot/yicool.com.cn/includes/learning_seo_md.php on line 63

Warning: preg_match(): Unknown modifier '{' in /home/wwwroot/yicool.com.cn/includes/learning_seo_md.php on line 63

Warning: preg_match(): Unknown modifier '{' in /home/wwwroot/yicool.com.cn/includes/learning_seo_md.php on line 63

route 命令详解

网络与远程 · 查看和设置 Linux 内核中的网络路由表

语法

route [选项] [参数]

实用示例

  • route
  • Kernel IP routing table
  • Destination Gateway Genmask Flags Metric Ref Use Iface
  • 112.124.12.0 * 255.255.252.0 U 0 0 0 eth1
  • 10.160.0.0 * 255.255.240.0 U 0 0 0 eth0
  • 192.168.0.0 10.160.15.247 255.255.0.0 UG 0 0 0 eth0

原文摘录

route 命令用来查看和设置 Linux 内核中的网络路由表,route 命令设置的路由主要是静态路由。要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或者同时位于两个网络的网关来实现。
参考:http://man.linuxde.net/route

示例:

# 查看当前路由
route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
112.124.12.0    *               255.255.252.0   U     0      0        0 eth1
10.160.0.0      *               255.255.240.0   U     0      0        0 eth0
192.168.0.0     10.160.15.247   255.255.0.0     UG    0      0        0 eth0
172.16.0.0      10.160.15.247   255.240.0.0     UG    0      0        0 eth0
10.0.0.0        10.160.15.247   255.0.0.0       UG    0      0        0 eth0
default         112.124.15.247  0.0.0.0         UG    0      0        0 eth1

route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0    # 添加网关/设置网关
route add -net 224.0.0.0 netmask 240.0.0.0 reject      # 屏蔽一条路由
route del -net 224.0.0.0 netmask 240.0.0.0             # 删除路由记录
route add default gw 192.168.120.240                   # 添加默认网关
route del default gw 192.168.120.240                   # 删除默认网关

内容与示例整理自 dunwu/linux-tutorial,遵循 CC BY-SA 4.0;本站保留原作者署名与许可,命令仅供学习,执行前请核对目标环境。