iptables示例,只允许某一网段IP访问操作系统

Linux安全
1406
linux
linux 举报
2020-05-29

iptables示例,只允许某一网段IP访问操作系统


iptables -F

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
#如果你把OUTPUT 设置成DROP,就需要加上这个规则,否则SSH还是不能登录,因为SSH服务职能进不能出。


#允许loopback回环通信
iptables -A INPUT -i lo -p all -j ACCEPT 
iptables -A OUTPUT -o lo -p all -j ACCEPT


#多端口匹配
iptables -A INPUT -p tcp -m multiport --dports 21,22,25,80,110 -j ACCEPT

iptables -P INPUT DROP
iptables -A INPUT -s  192.168.222.0/24   -d  192.168.222.0/24 -j ACCEPT

iptables -P OUTPUT DROP
iptables -A OUTPUT -d  192.168.222.0/24  -s  192.168.222.0/24 -j ACCEPT


#丢弃非法连接
iptables -A INPUT   -m state --state INVALID -j DROP
iptables -A OUTPUT -m state --state INVALID -j DROP
iptables -A FORWARD -m state --state INVALID -j DROP

iptables-save


倒序看帖 只看楼主
热点关注
postfix下过滤垃圾邮件的有效方法
shell脚本每行后面多了一个^M的原因和解决办法
定时检测服务,检测down掉后重启。系统检测到DMSERVER运行正常
挂载磁盘的时候遇到一个问题,挂载完磁盘之后重启服务器挂载的盘丢失了.
中标麒麟系统Your trial is EXPIRED and no VALID licens
termux 开启ssh并用用户名和密码登陆
组成共享库的目标文件和一般的目标文件有所不同,在编译时要加-fPIC和-share选项,例如:
gcc指定链接库路径后还是找不到库文件
./configure -build,-host,-target设置
关于Linux系统中configure中build,target,host中的若干问题
不用单独编译gmp、mpfr和mpc三个包,放在gcc源码下面一起编译
安装最新版本的GCC编译器(./configure执行编译报错 C++ compiler too old)
在后台用进程名运行bash脚本
shell参数判断
postfix过滤规则的几个关键规则