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

Linux安全
1874
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


倒序看帖 只看楼主
热点关注
You need Perl 5 安装openssl时报错提示需要安装perl 5
shell 脚本中常见的 if [ $? -ne 0 ]; 意思
shell 中 if [ “x${var}“ == “x“ ] 中 x的作用
shell脚本每行后面多了一个^M的原因和解决办法
服务停止、启动、重启一体化脚本,万能语言启动脚本
shell参数判断
在后台用进程名运行bash脚本
shell脚本每行后面多了一个^M的原因和解决办法
定时检测服务,检测down掉后重启。系统检测到DMSERVER运行正常
挂载磁盘的时候遇到一个问题,挂载完磁盘之后重启服务器挂载的盘丢失了.
中标麒麟系统Your trial is EXPIRED and no VALID licens
termux 开启ssh并用用户名和密码登陆
extman-1.1自带了图形化显示日志的功能;此功能需要rrdtool的支持,您需要安装此些模块才可能正常显示图形日志。
postfix的相关个别参数设置
postfix中recipient/client/sender/helo四者的区别