如何永久更新iptables [英] How to permanently update iptables

查看:139
本文介绍了如何永久更新iptables的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将http流量重定向到同一台计算机上的端口8080,并使下面的iptables规则正常工作.

I'm trying to redirect http traffic to port 8080 on the same machine and have the iptables rules below working.

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080

我正在尝试找出如何在系统重新启动的情况下使此更改永久生效.

I'm trying to figure out how to make this change permanent incase of a reboot of the system.

我正在使用Ubuntu 11.10服务器.

I'm using Ubuntu 11.10 server.

推荐答案

一种方法是:

One way to do this would be:

vim /etc/network/interfaces

在您的lo指令后面加上以下行:

Append the below line along with your lo directives:

post-up /sbin/iptables-restore < /etc/iptables-up.rules

现在运行以下命令

iptables-save > /etc/iptables-up.rules

我希望这会有所帮助.

这篇关于如何永久更新iptables的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆