yar*_*can 3 linux firewall ssh openvpn iptables
我有一些 vps 空间,但根据我在 iftop 中看到的内容,我得到了很多扫描。我尝试了一些 iptables 的东西,但是将我在日志中看到的所有 ip 放在一起会很累而且毫无用处。我想知道最好的方法来确保我可以稳定连接到我的 vps,同时保持几乎所有功能关闭,直到我想通过 iptables 启用。/
目前我有 Debian,并在其上运行活动的 Vpn 和 Ssh。我想要最基本的东西+VPN+ssh 接受传入和传出连接,其余的可以留在我的前院之外。
基本上我正在寻找可以与 Debian 一起使用的命令列表。我根据我在网上看到的内容尝试了很多东西。有些东西引发了错误,有些让我感到困惑。无论如何,我能够将一些事情结合起来,比如接受 VPN 上的连接。我想我只需要一份清晰的清单。
我不需要定义负责连接的单个 ip,所以 ports 会为我做这件事。我可以稍后自己添加 IP 目的地。
谢谢
这是一个教程: https: //help.ubuntu.com/community/IptablesHowTo
总结一下:
# Allow packets for existing connections (this is required for replies
# from the internet to connections you initiate from the vps):
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Allow connecting to SSH, the established session is handled above:
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
# Allow connecting to the VPN server, assuming default OpenVPN w/ TCP:
iptables -A INPUT -p tcp --dport openvpn -j ACCEPT
# Does anybody need to ping you? If you never want to do that:
# iptables -A INPUT -p icmp -m icmp --icmp-type echo-request -j DROP
#
# (Almost) All other ICMP is important, don't bother trying to make exceptions:
iptables -A INPUT -p icmp -j ACCEPT
# If you run OpenVPN in UDP mode, want to run traceroute to yourself,
# or use NFS over UDP, accept them here. Remember to explicitly allow replies,
# for services you access.
# Drop everything else. Two ways to do this:
# The common catch-all rule, which makes adding rules later harder
# (need to "-I"nsert instead of "-A"ppend; order matters!):
# iptables -A INPUT -j DROP
#
# Alternatively, set the default policy:
iptables -P INPUT DROP
Run Code Online (Sandbox Code Playgroud)
不过,我不确定这会给你带来什么。扫描数据包无论如何都会进入您的网络接口,因此您只保存出站“没有在该端口上侦听”回复(如果有东西正在侦听:如果您不需要它,请将其关闭,如果需要,您需要无论如何都允许访问),并且打开一些端口后,您无论如何都不会隐形。
不过,祝你好运。请记住,很容易意外地将自己锁在门外,因此请小心行事。
| 归档时间: |
|
| 查看次数: |
6775 次 |
| 最近记录: |