zoukankan      html  css  js  c++  java
  • Linux之路由的添加删除(ip route)

    查看路由:

    #route
    #route -n
    #ip route show | column -t

     

    获取帮助

    [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

      

  • 相关阅读:
    PBE加密 .net 实现
    手把手教你写一个windows服务 【基于.net】 附实用小工具{注册服务/开启服务/停止服务/删除服务}
    fish redux 个人理解
    .net Core 图片验证码 基于SkiaSharp实现
    .net core webapi jwt 更为清爽的认证 ,续期很简单(2)
    js删除数组对象中符合条件的数据
    编译.net .net Core程序 代码,仅做备份
    Mybatis架构相关的知识
    java选择题知识总结大全
    Mybatis详解(二) sqlsession的创建过程
  • 原文地址:https://www.cnblogs.com/xiaofeng666/p/12764656.html
Copyright © 2011-2022 走看看