ptables的NAT功能设置和linux升级内核后遇到 can't initialize iptables table `nat': Table does not exist 问题

如何使用iptables的NAT功能把红帽企业版Linux作为一台路由器使用?


方法:


提示: 以下方法只适用于红帽企业版Linux 3 以上。


1、打开包转发功能:


echo "1" > /proc/sys/net/ipv4/ip_forward


2、修改/etc/sysctl.conf文件,让包转发功能在系统启动时自动生效:
# Controls IP packet forwarding


net.ipv4.ip_forward = 1


3、打开iptables的NAT功能:


/sbin/iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE


说明:上面的语句中ppp0是连接外网或者连接Internet的网卡. 执行下面的命令,保存iptables的规则: service iptables save


4、查看路由表:


netstat -rn 或   route -n


5、查看iptables规则:


iptables -L


查看nat表

iptables -t nat -L



编译好新内核后
# iptables -t nat -nL 提示


iptables v1.3.5: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.


解决方法: 编译内核时加入以下模块


Linux Kernel Configuration
    -> Networking support
        -> Networking options
            -> Network packet filtering framework(netfilter)
                -> Core netfilter configuration
                    -> Netfilter connection tracking support
                    -> Netbios name service protocal support(new)
                    -> Netfilter Xtables support (required for ip_tables)


Linux Kernel Configuration
    -> Networking support
        -> Networking options
            -> Network packet filtering framework(netfilter)
                -> IP: Netfilter Configuration
                    -> IPv4 connection tracking support (require for NAT)
                    -> IP tables support (required for filtering/masq/NAT)
                -> Full NAT
                    -> MASQUERADE target support
                    -> REDIRECT target support


make -j2

make -j2 all

make -j2 modules_install

make -j2 install


升级完成后重启重新配置nat即可。


参考:http://blog.sina.com.cn/s/blog_654a4e8b0100ii3y.html


  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值