Linux安全优化

本文深入探讨了iptables和netfilter的基本概念,并提供了关键规则配置示例,旨在帮助理解网络防火墙策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

iptables
iptables -A INPUT -p all -m state --state INVALID -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A INPUT -p icmp --icmp-type 0 -m length --length :100 -m limit --limit 6/s --limit-burst 10 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -m length --length :100 -m limit --limit 6/s --limit-burst 10 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 11 -m length --length :100 -m limit --limit 6/s --limit-burst 10 -j ACCEPT
iptables -A INPUT -p icmp -j DROP
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --syn -m state --state NEW --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --syn -m state --state NEW --dport 1433 -j ACCEPT
iptables -A INPUT -p tcp --syn -m state --state NEW --dport 3389 -j ACCEPT
iptables -A INPUT -p tcp --syn -m state --state NEW --dport 5022 -j ACCEPT
iptables -A INPUT -p udp --dport 3389 -j ACCEPT
iptables -A INPUT -p tcp -m multiport --dport 80,1433,3389,5022 -j DROP


netfilter
net.ipv4.tcp_fastopen = 1
net.ipv4.tcp_thin_linear_timeouts= 0
net.ipv4.tcp_thin_dupack= 0
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_conntrack_max = 655360
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
kernel.exec-shield = 1
kernel.randomize_va_space = 1
- -



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值