ip rule

http://blog.youkuaiyun.com/testfamily/article/details/29559485



Ip rule:

进行路由时,根据路由规则来进行匹配,按优先级(pref)从低到高匹配,直到找到合适的规则.所以在应用中配置默认路由是必要的

 

路由规则的添加
ip rule add from 192.168.1.10/32 table 1 pref 100
如果pref值不指定,则将在已有规则最小序号前插入

 

PS: 创建完路由规则若需立即生效须执行#ip route flush cache

        

From -- 源地址
        To -- 目的地址(这里是选择规则时使用,查找路由表时也使用)
   Tos -- IP包头的TOS(type of sevice)域Linux高级路由-
   Dev -- 物理接口
     Fwmark -- iptables标签

 

采取的动作除了指定路由表外,还可以指定下面的动作:
         Table 指明所使用的表
       Nat 透明网关

      Prohibit 丢弃该包,并发送 COMM.ADM.PROHIITED的ICMP信息 
      Reject 单纯丢弃该包
      Unreachable丢弃该包, 并发送 NET UNREACHABLE的ICMP信息

 

Usage: ip rule [ list | add | del ]SELECTOR ACTION
        SELECTOR := [ from PREFIX ] [ toPREFIX ] [ tos TOS ][ dev STRING ] [ pref NUMBER ]
        ACTION := [ table TABLE_ID ] [ natADDRESS ][ prohibit | reject | unreachable ]
                 [ flowid CLASSID ]
        TABLE_ID := [ local | main | default| new | NUMBER ]

srvcFpt.c:447:24: error: assignment to expression with array type handleCfg->rule.srcIp = ipRule->ipRule.sourceAddress; ^ srvcFpt.c:448:24: error: assignment to expression with array type handleCfg->rule.dstIp = ipRule->ipRule.destAddress; ^ srvcFpt.c:454:50: error: subscripted value is neither array nor pointer nor vector UINT8 srcIp[] = {ipRule->ipRule.sourceAddress[0], ipRule->ipRule.sourceAddress[1], ipRule->ipRule.sourceAddress[2], ipRule->ipRule.sourceAddress[3]}; ^ srvcFpt.c:454:83: error: subscripted value is neither array nor pointer nor vector UINT8 srcIp[] = {ipRule->ipRule.sourceAddress[0], ipRule->ipRule.sourceAddress[1], ipRule->ipRule.sourceAddress[2], ipRule->ipRule.sourceAddress[3]}; ^ srvcFpt.c:454:116: error: subscripted value is neither array nor pointer nor vector UINT8 srcIp[] = {ipRule->ipRule.sourceAddress[0], ipRule->ipRule.sourceAddress[1], ipRule->ipRule.sourceAddress[2], ipRule->ipRule.sourceAddress[3]}; ^ srvcFpt.c:454:149: error: subscripted value is neither array nor pointer nor vector UINT8 srcIp[] = {ipRule->ipRule.sourceAddress[0], ipRule->ipRule.sourceAddress[1], ipRule->ipRule.sourceAddress[2], ipRule->ipRule.sourceAddress[3]}; ^ srvcFpt.c:455:48: error: subscripted value is neither array nor pointer nor vector UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^ srvcFpt.c:455:22: error: initialization makes integer from pointer without a cast [-Werror=int-conversion] UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^ srvcFpt.c:455:22: note: (near initialization for 'dstIp[0]') srvcFpt.c:455:81: error: subscripted value is neither array nor pointer nor vector UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^ srvcFpt.c:455:55: error: initialization makes integer from pointer without a cast [-Werror=int-conversion] UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^ srvcFpt.c:455:55: note: (near initialization for 'dstIp[1]') srvcFpt.c:455:114: error: subscripted value is neither array nor pointer nor vector UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^ srvcFpt.c:455:88: error: initialization makes integer from pointer without a cast [-Werror=int-conversion] UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^ srvcFpt.c:455:88: note: (near initialization for 'dstIp[2]') srvcFpt.c:455:147: error: subscripted value is neither array nor pointer nor vector UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^ srvcFpt.c:455:121: error: initialization makes integer from pointer without a cast [-Werror=int-conversion] UINT8 dstIp[] = {ipRule->ipRule.destAddress[0], ipRule->ipRule.destAddress[1], ipRule->ipRule.destAddress[2], ipRule->ipRule.destAddress[3]}; ^
最新发布
11-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值