常用iptables规则整理

1、仅允许内部合法的IP地址访问服务器

#setting access rules

#one,in access rules,allow all the ips of hudong.com

iptables -A INPUT -s 192.168.3.3/24 -p all -j ACCEPT

iptables -A INPUT -s 192.168.4.4/24 -p all -j ACCEPT

........

2、仅允许内部合法IP段访问监控服务nagios

#second,port access rules

#nagios

iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 5666 -j ACCEPT

.......

3、仅允许内部合法的IP段访问Mysql和ORACLE数据库

iptables -A INPUT -s 192.168.4.4/24 -p tcp --dport 3306 -j ACCEPT

........

4、仅允许内部合法的IP段访问SSH远程连接服务

#ssh difference form other servers hers

iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 45215 -j ACCEPT

......

(注意:SSH端口最好改为其他端口。还有,最好只让内部网络可以连接)

5、对HTTP服务的不同限制

a、对外提供HTTP服务的业务,要允许HTTP服务通过,并且不限制IP。

#http

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

.......

b、对内提供HTTP服务的业务,一般用特殊端口,并且限制合法IP连接或VPN连接。

iptables -A INPUT -s 192.168.1.0/24 -p tcp -m multiport --dport 8080,8081,8082,8888 -j ACCEPT

........

5、SNMP的限制

#snmp

iptables -A INPUT -s 192.168.1.0/24 -p UDP --dport 161 -j ACCEPT

......

6、rsync服务的限制策略

#rsync

iptables -A INPUT -s 192.168.1.0/24 -p tcp -m tcp --dport 873 -j ACCEPT

.......

7、ftp服务限制

#others RELATED

#ftp

#iptables -A INPUT -p tcp --dport 20:21 -j ACCEPT(这里不兴允许21端口,也要允许20号端口)

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

说明:

iptables -A INPUT -m state --state 状态 -j ACCEPT

state

this module,when combined with connection tracking,allows access to the connection tracking state for this packet.

时间: 2024-08-03 06:29:15

常用iptables规则整理的相关文章

iptables 规则整理

一.iptables命令帮助信息 1.1 实际测试iptables规则1.1.1启动和查看iptables状态 /etc/init.d/iptables start iptables -L -n或iptables -L -n -v -x实例演示1: [[email protected] ~]# iptables -V iptables v1.4.7 [[email protected] ~]# iptables -h iptables v1.4.7 Usage: iptables -[ACD]

Sonar 常用代码规则整理

摘要:公司部署了一套sonar,经过一段时间运行,发现有一些问题出现频率很高,因此有必要将这些问题进行整理总结和分析,避免再次出现类似问题. 作者原创技术文章,转载请注明出处id: 83 name: A method/constructor shouldnt explicitly throw java.lang.Exception type: CODE SMELL severity: MAJOR Comment: It is unclear which exceptions that can b

iptables常用的规则设定

iptables 4个表和5个涟 iptables 显示相关的命令 iptables -L -n -x -v 查看iptables的status 为Firevall is stopped 解决: Linux命令行输入 step --Firevall configuration--enable 清除默认的规则 iptables -F 等价于iptables --flush//清除所有的规则 iptables -X 等价于iptables --delete-chain//删除用户自定义规则 ipta

iptables防火墙规则整理

iptables防火墙规则整理 iptables是组成Linux平台下的包过滤防火墙,与大多数的Linux软件一样,这个包过滤防火墙是免费的,它可以代替昂贵的商业防火墙解决方案,完成封包过滤.封包重定向和网络地址转换(NAT)等功能.在日常Linux运维工作中,经常会设置iptables防火墙规则,用来加固服务安全.以下对iptables的规则使用做了总结性梳理: iptables由两部分组成: 1.framework:netfilter hooks function钩子函数,实现网络过滤器的基

归纳常用的iptables规则

以下是Linux系统常用的一些iptables规则: 清除已有iptables规则 iptables -F  是清空所有的规则,请谨慎使用,因为ssh远程连接服务器会马上断开.(警告:这只适合在没有配置防火墙的环境中,如果已经配置过默认规则为deny的环境,此步骤将使系统的所有网络访问中断) iptables -X  是删除使用者自订 iptable 项目 开放指定的端口 #允许本地回环接口(即运行本机访问本机) iptables -A INPUT -s 127.0.0.1 -d 127.0.0

常用iptables配置实例

常用iptables配置实例 iptables命令可用于配置Linux的包过滤规则,常用于实现防火墙.NAT.咋一看iptables的配置很复杂,掌握规律后,其实用iptables完成指定任务并不难,下面我们通过具体实例,学习iptables的详细用法. 1.删除已有规则 在新设定iptables规则时,我们一般先确保旧规则被清除,用以下命令清除旧规则: iptables -F (or iptables --flush) 2.设置chain策略 对于filter table,默认的chain策略

9个常用iptables配置实例

iptables命令可用于配置Linux的包过滤规则,常用于实现防火墙.NAT.咋一看iptables的配置很复杂,掌握规律后,其实用iptables完成指定任务并不难,下面我们通过具体实例,学习iptables的详细用法. 1.删除已有规则 在新设定iptables规则时,我们一般先确保旧规则被清除,用以下命令清除旧规则: iptables -F (or iptables --flush) 2.设置chain策略 对于filter table,默认的chain策略为ACCEPT,我们可以通过以

iptables规则配置

iptables常用的表有filter,nat,mangle表 对于filter来讲一般只能做在3个链上:INPUT ,FORWARD ,OUTPUT 对于nat来讲一般也只能做在3个链上:PREROUTING ,OUTPUT ,POSTROUTING mangle则是5个链都可以做:PREROUTING,INPUT,FORWARD,OUTPUT,POSTROUTING 配置iptables表的默认规则 iptables -P INPUT DROP iptables -P OUTPUT DROP

iptables(三)iptables规则管理(增、删、改)

上一篇文章中,我们已经学会了怎样使用iptables命令查看规则,那么这篇文章我们就来总结一下,怎样管理规则. 之前,我们把查看iptables规则的操作比作"增删改查"当中的"查",那么在这篇文章中,我们就聊聊怎样对iptables进行"增.删.改"操作. 注意:在参照本文进行iptables实验时,请务必在个人的测试机上进行,因为如果iptables规则设置不当,有可能使你无法连接到远程主机中. 首先,我们来回顾一下什么是iptables的规