禁用不必要内核模块可同时缩小攻击面、降低内存开销、减少漏洞暴露点;需通过lsmod识别零使用模块,modinfo确认功能,结合业务场景(如web服务器禁用bluetooth、firewire_core等)判断冗余,再以blacklist+install /bin/false写入/etc/modprobe.d/配置文件,执行update-initramfs -u或dracut -f生效,并通过lsmod、dmesg和modprobe验证禁用效果。

禁用不必要内核模块是服务器基础安全中最直接、见效快的一环。它不依赖额外软件,也不改变业务逻辑,却能同时缩小攻击面、降低内存开销、减少潜在漏洞暴露点。
识别哪些模块该禁用
先看当前加载了什么:
- 运行 lsmod 查看已加载模块列表,重点关注使用计数(Used by)为 0 的模块
- 用 modinfo 模块名 确认功能,例如
modinfo bluetooth显示“Bluetooth protocol support”,而你的 VPS 根本没有蓝牙硬件,就可判定冗余 - 结合业务场景过滤:Web 服务器通常不需要
firewire、ipx、dccp、irda、usb-storage;容器主机一般禁用bluetooth、cfg80211(除非跑 WiFi 相关服务) - 注意保留云平台必需模块:如
virtio_net、virtio_blk、xen-netfront等,误禁会导致网络或磁盘不可用
持久化禁用的正确写法
仅卸载模块(modprobe -r)重启即失效,必须写入配置文件:
- 在 /etc/modprobe.d/ 下新建文件(如
disable-unneeded.conf),避免直接改blacklist.conf(易被系统更新覆盖) - 每行一条规则:
blacklist bluetoothblacklist firewire_core - 更彻底禁用(防间接加载)加 install 行:
install bluetooth /bin/falseinstall firewire_core /bin/false - Debian/Ubuntu 执行
sudo update-initramfs -u,RHEL/CentOS 执行sudo dracut -f,否则新内核启动时黑名单不生效
验证是否真正禁用
别只信配置文件,要验证结果:
- 重启后运行
lsmod | grep -E 'bluetooth|firewire',应无任何输出 - 检查内核日志:
dmesg | grep -i "bluetooth.*disabled\|loading.*fail",看到拒绝加载记录才可靠 - 模拟模块手动加载:
sudo modprobe bluetooth,应返回modprobe: FATAL: Module bluetooth not found in directory或被/bin/false阻断 - 若某模块仍被加载,用
modprobe -D bluetooth查依赖链,顺藤摸瓜禁用上游模块
常见高危模块清单(VPS 场景通用)
以下模块在纯云服务器环境普遍无用且存在历史漏洞风险,可优先处理:
- bluetooth:无外设,CVE-2020-12351 等多次被利用
- firewire_core / ohci1394:虚拟化中不存在 FireWire 控制器
- ipx / appletalk:已淘汰协议,无业务依赖
- irda:红外通信,云环境零适用
- usb-storage:VPS 不接 USB 存储,且曾有提权漏洞(CVE-2018-1000001)
- dccp / sctp:除非明确使用,否则禁用可减小网络栈攻击面











