Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

Linux 網路伺服器核心配置檔詳解與安全加固指南

編輯:關於伺服器

建置安全的 Linux 伺服器,首重熟悉網路服務相關配置檔的用途與安全設定。Linux 的 TCP/IP 參數主要透過純文字檔案管理,雖可用 linuxconf/netconf 等工具輔助,但理解檔案結構才能精準控制與稽核。本文梳理核心配置檔並給出加固建議。

核心網路配置檔速覽

檔案路徑用途關鍵參數範例
/etc/conf.modules(舊)
/etc/modules.conf / /etc/modprobe.d/
核心模組載入參數,特別是多網卡(ISA 需指定 IO、IRQ)alias eth0 3c509
options 3c509 io=0x300,0x320
/etc/HOSTNAME主機完整網域名稱(FQDN)deep.openarch.com
/etc/sysconfig/network-scripts/ifcfg-ethN各網卡 IP、掩碼、閘道、啟動協議DEVICE=eth0
IPADDR=208.164.186.1
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
/etc/resolv.confDNS 解析器設定:搜尋域、名稱伺服器順序search openarch.com
nameserver 208.164.186.1
nameserver 208.164.186.2
/etc/host.conf主機名解析順序與防偽裝order bind,hosts
multi on
nospoof on
/etc/sysconfig/network全域網路參數:啟用轉發、主機名、預設閘道NETWORK=yes
FORWARD_IPV4=yes
GATEWAY=192.168.1.1
/etc/hosts靜態名稱對應表(DNS 前優先查詢)127.0.0.1 localhost
208.164.186.1 gate.openarch.com gate
/etc/inetd.conf / /etc/xinetd.d/超級守護進程服務啟用控制(舊版 inetd / 新版 xinetd)以 # 註解停用 ftp、telnet、finger 等高風險服務

安全加固關鍵步驟

1. 精簡 inetd/xinetd 服務

# 僅保留必須服務,其餘全部註解
# 修改後重載
killall -HUP inetd   # 或 systemctl reload xinetd

2. 鎖定關鍵配置檔權限

chmod 600 /etc/inetd.conf
chown root:root /etc/inetd.conf
chattr +i /etc/inetd.conf   # 防竄改,需改時先 chattr -i

3. 管理獨立守護進程(非 inetd 管轄)

如 sendmail、named、httpd 等,使用 chkconfig 或 systemctl 關閉非必要服務:

chkconfig --level 35 named off
systemctl disable --now telnet.socket

修改生效通用指令

/etc/rc.d/init.d/network restart   # SysVinit
# 或
systemctl restart NetworkManager   # systemd

最佳實踐提醒

  • 所有網卡配置採靜態 IP,避免 DHCP 不可控風險;
  • /etc/hosts 必含本機 FQDN 解析,防單點 DNS 故障導致服務啟動卡頓;
  • 定期稽核 netstat -tulnp 與 ss -tulnp,確認僅預期埠對外開放;
  • 配合 iptables/nftables 做主機層防火牆,實現纏繞防禦。
Copyright © Windows教程網 All Rights Reserved