ant*_*tel 12 security firewall debian iptables
我最近决定做一些安全维护。我看到了我的日志,并且有一些针对我的 SSH 服务器的尝试。起初,我从默认的 22 端口移开了 SSH 端口。之后,我读了一些关于Fail2ban、BlockHosts和DenyHosts 的内容。
我先看了看:配置简单,一切都好理解;但是当我试图“探索它的保护”时,测试失败了。一切似乎都很好,但我仍然可以访问服务器。
我还测试了 IPtables:# iptables -I INPUT -j DROP
- 之后我的 SSH 连接丢失了(所以,我想要什么)。然后# iptables -I INPUT -s 84.x.y.z -j DROP
,这也奏效了。
但是,Fail2ban 做了什么规则,这不起作用:($ sudo iptables -L
)
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-apache tcp -- anywhere anywhere multiport dports www,https
fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh
fail2ban-ssh-ddos tcp -- anywhere anywhere multiport dports ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-apache (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh (1 references)
target prot opt source destination
DROP all -- 84.x.y.z anywhere
RETURN all -- anywhere anywhere
Chain fail2ban-ssh-ddos (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Run Code Online (Sandbox Code Playgroud)
加载的内核模块:( $ lsmod | grep ip
)
iptable_nat 4680 0
nf_nat 15576 1 iptable_nat
nf_conntrack_ipv4 12268 3 iptable_nat,nf_nat
nf_conntrack 55540 4 xt_state,iptable_nat,nf_nat,nf_conntrack_ipv4
xt_multiport 2816 2
iptable_filter 2624 1
ip_tables 10160 2 iptable_nat,iptable_filter
x_tables 13284 5 xt_state,xt_tcpudp,iptable_nat,xt_multiport,ip_tables
ipv6 235396 24
Run Code Online (Sandbox Code Playgroud)
版本:
openssh-server
1:5.1p1-5测试#1 一步一步:
iptables -L
向我展示了上面提到的内容。所以禁令是有效的,当我连接时,命令我的服务器。逐步测试#2:
at
脚本,以在将来删除下面写的禁止规则。( iptables -D INPUT 1
)iptables -I INPUT 1 -s 84.x.y.z -j DROP
at
脚本之后,我可以访问我的服务器。我没有看到解决方案,我应该怎么做才能使我的 IPtables 禁令(由 Fail2ban 制造)起作用?
在安装fail2ban之前,我发现了问题,我做了什么。对不起,你的时间。
出于安全原因,我将 sshd 从端口 22 移到另一个端口。中的引用iptables
仅指端口 22。我想,它是一个变量,总是指当前的 sshd 端口。但不是。
确切的解决方案(如果您将守护进程从其原始端口移开):
port
部分修复为所有. 例子:port = all
banaction
在端口行之后添加或编辑现有行,值为iptables-allports。例子:banaction = iptables-allports
。# service fail2ban restart
。我找不到更改port ssh
指令的解决方案,或者在那里写一个数字。如果您有非全端口解决方案,我会听的!
归档时间: |
|
查看次数: |
17770 次 |
最近记录: |