2024年11月Linux下route命令操作实例汇总(3)

发布时间:

  ⑴实例:删除路由记录

  ⑵route del - ... mask ...

  ⑶route del - ... mask ... reject

  ⑷[rootlocalhost ~]# route

  ⑸Kernel IP routing table

  ⑹Destination Gateway Genmask Flags Metric Ref Use Iface

  ⑺... * ... U eth

  ⑻... ... ... UG eth

  ⑼... ... ... UG eth

  ⑽... - ... ! - -

  ⑾... * ... U eth

  ⑿default ... ... UG eth

  ⒀[rootlocalhost ~]# route del - ... mask ...

  ⒁[rootlocalhost ~]# route

  ⒂Kernel IP routing table

  ⒃Destination Gateway Genmask Flags Metric Ref Use Iface

  ⒄... * ... U eth

  ⒅... ... ... UG eth

  ⒆... ... ... UG eth

  ⒇... - ... ! - -

  ⒈default ... ... UG eth

  ⒉[rootlocalhost ~]# route del - ... mask ... reject

  ⒊[rootlocalhost ~]# route

  ⒋Kernel IP routing table

  ⒌Destination Gateway Genmask Flags Metric Ref Use Iface

  ⒍... * ... U eth

  ⒎... ... ... UG eth

  ⒏... ... ... UG eth

  ⒐default ... ... UG eth

  ⒑[rootlocalhost ~]#

  ⒒实例:删除和添加设置默认网关

  ⒓route del default gw ...

  ⒔route add default gw ...

  ⒕[rootlocalhost ~]# route del default gw ...

  ⒖[rootlocalhost ~]# route

  ⒗Kernel IP routing table

  ⒘Destination Gateway Genmask Flags Metric Ref Use Iface

  ⒙... * ... U eth

  ⒚... ... ... UG eth

  ⒛... ... ... UG eth

  ①[rootlocalhost ~]# route add default gw ...

  ②[rootlocalhost ~]# route

  ③Kernel IP routing table

  ④Destination Gateway Genmask Flags Metric Ref Use Iface

  ⑤... * ... U eth

  ⑥... ... ... UG eth

  ⑦... ... ... UG eth

  ⑧default ... ... UG eth

  ⑨[rootlocalhost ~]#

  ⑩上面就是Linux下route命令的操作实例的介绍了,从本文的介绍我们可以知道,route命令除了能够显示路由表外,还能够删除路由记录,屏蔽路由及设置网关。