linux/" style="color: rgb(0, 136, 209); text-decoration-line: none;">Linux多可支持255个路由表,查看当前路由表:
mportant; padding: 0px !important; outline: 0px !important; border-width: 0px !important; border-style: initial !important; border-color: initial !important; border-radius: 0px !important; background: none !important; inset: auto !important; float: none !important; line-height: 1.1em !important; overflow: visible !important; position: static !important; vertical-align: baseline !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; color: rgb(175, 175, 175) !important;" width="NaN" height="NaN"> 1 2 3 4 5 | ip rule ls 0: from all lookup local 32766: from all lookup main 32767: from all lookup default |
根据源IP或目标IP选择路由表:
1 2 3 4 5 6 7 8 | echo '252 onovps'>>/etc/iproute2/rt_tables #新建路由表ID与名称映射 ip rule add from 192.168.1.5 table onovps pref 32764 #新建路由表onovps,优先级32764 ip route add default via 192.168.1.2 dev pppoe-wan2 table onovps #新建路由表onovps默认路由项 ip route flush cache #刷新路由缓存 |
基于iptables标记选择路由表:
1 2 3 4 5 6 | ip rule add fwmark 20 table onovps pref 32763 #新建路由表,防火墙标记20的数据 ip route add default via 192.168.1.2 dev pppoe-wan2 table onovps #默认路由 iptables -t mangle -APREROUTING -p udp --dport 53 -j MARK --set-mark 20 #标记数据 |
查看当前路由表:
1 2 3 4 5 6 | ip rule ls 0: from all lookup local 32764: from 192.168.1.5 lookup onovps 32765: from all lookup main 32766: from all lookup main 32767: from all lookup default |
查看路由表onovps下路由项:
1 2 | ip route ls table onovps default via 192.168.1.2 dev eth1 |
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:http://hqyman.cn/post/3933.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~