为了保护内核,我可以在 /etc/sysctl.conf 中修改什么?

为了保护内核,我可以在 /etc/sysctl.conf 中修改什么?

我想让我的 Linux 机器成为网络服务器。我希望通过应用更改来保护内核/etc/sysctl.conf。我将首先向您描述我的 Web 应用程序的内容。

该应用程序将是一个分类广告网站(如 gumtree.co.uk),用户可以:

-sell their items, upload images, send to and receive emails from the admin. 
-It will use SSL for some pages. I will also need SSH.

在 中/etc/sysctl.conf,我取消了所有这些选项的注释,但我不知道可以取消哪些选项的注释以更好地保护内核并同时满足我的网络托管目的。

以下是不同的选项:

1) Turn on Source Address Verification in all interfaces to prevent spoofing attacks
2) Uncomment the next line to enable packet forwarding for IPv4
3) Uncomment the next line to enable packet forwarding for IPv6
4) Do no accept ICMP redirects (we are not a router)
5) Accept ICMP redirects only for gateways listed in our default gateway list
6) Do not send ICMP redirects
7) Do not accept IP source route packets (we are not a router)
8) Log Martian Packets

我可以取消注释哪些?另外,您还有其他建议来保护内核吗?

非常感谢。问候

答案1

简而言之,我会首先关注防火墙,然后我会启用选项 2、3、7。不更改任何选项,您将拥有一个相对安全的服务器,但是更改 2、3、7 应该是安全的。

加强内核安全性是件好事,但首先做好其他事情会让您事半功倍。如果您担心安全性,那么首先应该安装防火墙,阻止除 Web 流量(80 和 443)和来自适当位置的 SSH(22)之外的所有传入连接。

为了攻击内核,他们需要能够连接到您的服务器,无论是向 Apache 发送填充数据包,还是暴力破解您的 SSH 密码。首先要限制这些攻击媒介。如果您没有硬件防火墙,所有主要发行版都附带一个,例如 centos/rhel 的 iptables 或 ubuntu 的 ufw。

有了这些……内核大部分都是开箱即用的。sysctl 选项的详细描述如下:http://www.mjmwired.net/kernel/Documentation/sysctl/kernel.txt。我管理着 300 多台服务器,一般为了安全起见会避免使用 sysctl.conf,一般只用它来进行流量调整。

相关内容