Linux上的持久性ip规则(Redhat)

Linux上的持久性ip规则(Redhat),第1张

概述如何在 Linux上配置持久性ip规则(特别是基于Redhat的发行版)?有内置方法吗?我唯一的选择是添加到/etc/rc.d/rc.local还是创建自己的rc.d脚本? 编辑:为了澄清我不是指iptables而是ip工具(我认为很多人都不熟悉).在任何情况下,我试图保持的规则添加以下命令: # ip rule add fwmark 1 lookup 100# ip rule...3276 如何在 Linux上配置持久性ip规则(特别是基于Redhat的发行版)?有内置方法吗?我唯一的选择是添加到/etc/rc.d/rc.local还是创建自己的rc.d脚本?

编辑:为了澄清我不是指iptables而是ip工具(我认为很多人都不熟悉).在任何情况下,我试图保持的规则添加以下命令:

# ip rule add fwmark 1 lookup 100# ip rule...32765: from all fwmark 0x1 lookup 100...

我发现这样做的唯一参考来自Novell:http://www.novell.com/support/viewContent.do?externalId=7008874&sliceId=1,它建议创建一个rc.d脚本

解决方法 按照惯例,我在询问后不久就偶然发现了自己问题的答案:)在 http://grokbase.com/t/centos/centos/099bmc07mq/persisting-iproute2-routes-and-rules找到答案

在Redhat 5上,/ etc / sysconfig / network-scripts / ifup-routes脚本处理rule- *文件.相关代码如下:

# Routing rulesfileS="/etc/sysconfig/network-scripts/rule-"if [ -n "" -a "" != "" ]; then    fileS="$fileS /etc/sysconfig/network-scripts/rule-"fifor file in $fileS; do   if [ -f "$file" ]; then       { cat "$file" ; echo ; } | while read line; do           if [[ ! "$line" =~ $MATCH ]]; then           /sbin/ip rule add $line       fi       done   fidone

RHEL 6.5的脚本(可能是较旧的6):

# Routing rulesfileS="/etc/sysconfig/network-scripts/rule- /etc/sysconfig/network-scripts/rule6-"if [ -n "" -a "" != "" ]; thenfileS="$fileS /etc/sysconfig/network-scripts/rule- /etc/sysconfig/network-scripts/rule6-"fifor file in $fileS; do   if [ -f "$file" ]; then       handle_ip_file $file   fidonehandle_ip_file() {    local f t type= file= proto="-4"    f=${file##*/}    t=${f%%-*}    type=${t%%6}    if [ "$type" != "$t" ]; then        proto="-6"    fi    { cat "$file" ; echo ; } | while read line; do        if [[ ! "$line" =~ $MATCH ]]; then            /sbin/ip $proto $type add $line        fi    done}
总结

以上是内存溢出为你收集整理的Linux上的持久性ip规则(Redhat)全部内容,希望文章能够帮你解决Linux上的持久性ip规则(Redhat)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1043278.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存