寻觅生命中的那一片浅草......

文章属于类别 iptables

iptables v1.2.11: Unknown arg `–dport’

iptables -A RH-Firewall-1-INPUT -s 192.168.1.0/27 –dport 161 -j ACCEPT
iptables v1.2.11: Unknown arg `–dport’
Try `iptables -h’ or ‘iptables –help’ for more information.

改为这样就好了
iptables -A RH-Firewall-1-INPUT -p tcp -s 192.168.1.0/27 -m state –state NEW -m tcp –dport 161 -j ACCEPT

要在前面加 -p tcp

iptables的SNAT和DNAT

SNAT和DNAT是通过NAT表实现的

SNAT:

将172.16.1.78转换成192.168.1.19
iptables -t nat -A POSTROUTING -s 172.16.1.78 -j SNAT –to-source 192.168.1.19

DNAT:

iptables -t nat -A PREROUTING -d 192.168.1.19 -p tcp -m tcp –dport 80 -j DNAT –to-destination 172.16.1.78

这样访问192.168.1.19的端口就会转发到172.16.1.78的80端口上,如果想转发到172.16.1.78的8080端口上,可以用如下命令

iptables -t nat -A PREROUTING -d 192.168.1.19 -p tcp -m tcp –dport 80 -j DNAT –to-destination 172.16.1.78:8080

当然还需要在filter里允许访问80,8080端口,当然,这里允许了对局域网所有主机80,8080端口的访问,为安全,应该进一步细化规则

iptables -A FORWARD -p tcp -m tcp –dport 80 -j ACCEPT

iptables -A FORWARD -p tcp -m tcp –dport 8080 -j ACCEPT

如何恢复iptables的默认设置

/usr/local/sbin/iptables -P INPUT ACCEPT
/usr/local/sbin/iptables -P FORWARD ACCEPT
/usr/local/sbin/iptables -P OUTPUT ACCEPT

#
# reset the default policies in the nat table.
#
/usr/local/sbin/iptables -t nat -P PREROUTING ACCEPT
/usr/local/sbin/iptables -t nat -P POSTROUTING ACCEPT
/usr/local/sbin/iptables -t nat -P OUTPUT ACCEPT

#
# flush all the rules in the filter and nat tables.
#
/usr/local/sbin/iptables -F
/usr/local/sbin/iptables -t nat -F

#
# erase all chains that’s not default in filter and nat table.
#
/usr/local/sbin/iptables -X
/usr/local/sbin/iptables -t nat -X’

转载自:http://www.7880.com/Info/Article-657b9d40.html

iptables配置工具比较

本文将对iptables的配置做一个综述并且重点介绍一些iptables的配置工具。本文的讨论将着眼于linux内核的IP防火墙以及其各种界面的配置工具,比如:GUI或者脚本(shell、Perl或者特定的配置语言)。使用这些工具能够简化iptables的配置减少配置的错误。关于 iptables的知识请参考Rusty Russell写的Linux iptables HOWTO。

阅读全文»

iptables limit 参数备忘

* 限制特定封包傳入速度
* 限制特定埠口連入頻率
* iptables Log 記錄參數備忘
* 自定 Chain 使用備忘
* 防治 SYN-Flood 碎片攻擊
阅读全文»

2024年四月
« 5月    
1234567
891011121314
15161718192021
22232425262728
2930