Red Hat 7.1 引入 xinetd(eXtended InterNET services daemon)取代傳統 inetd,並預設啟用 ipchains 防火牆。預設安裝關閉 FTP、Telnet 等服務,導致許多管理者連線失敗。本文詳細說明完整啟用流程。
主設定檔 /etc/xinetd.conf 只定義全域預設值,各服務獨立配置於 /etc/xinetd.d/ 目錄下,每服務一檔,格式:
service service_name
{
socket_type = stream # stream/dgram/raw
protocol = tcp
port = 21
server = /usr/sbin/in.proftpd
server_args = -c /etc/proftpd.conf
wait = no # no=多執行緒, yes=單執行緒
user = root
group = root
disable = no # yes=停用, no=啟用
log_on_success = HOST PID
log_on_failure = HOST
}
編輯 /etc/xinetd.d/proftpd(或同名檔):
service ftp
{
disable = no
socket_type = stream
protocol = tcp
port = 21
user = root
server = /usr/local/sbin/in.proftpd
wait = no
}
編輯 /etc/xinetd.d/telnet:
service telnet
{
disable = no
socket_type = stream
protocol = tcp
port = 23
user = root
server = /usr/sbin/in.telnetd
wait = no
}
/etc/rc.d/init.d/xinetd restart
# 或
killall -HUP xinetd
本機測試:telnet localhost、ftp localhost 應正常連線。
區域網其他機器仍無法連線,因 ipchains 預設封鎖 0~1023 埠。編輯 /etc/sysconfig/ipchains:
# 修改前(封鎖)
-A input -p tcp -s 0/0 -d 0/0 0:1023 -y -j REJECT
-A input -p udp -s 0/0 -d 0/0 0:1023 -j REJECT
# 修改後(允許 FTP 21、Telnet 23)
-A input -p tcp -s 0/0 -d 0/0 21 -j ACCEPT
-A input -p tcp -s 0/0 -d 0/0 23 -j ACCEPT
-A input -p udp -s 0/0 -d 0/0 21 -j ACCEPT
-A input -p udp -s 0/0 -d 0/0 23 -j ACCEPT
或直接將兩行 0:1023 REJECT 改為 ACCEPT(較不安全)。修改後重開機或執行 /etc/rc.d/init.d/ipchains restart。
rlogin、talk、finger、pop3、imap 等服務皆在 /etc/xinetd.d/ 有對應檔案,修改 disable = no 並開放對應埠口即可。建議深入研讀 man xinetd.conf 與 man ipchains 掌握進階存取控制(only_from、no_access、access_times 等)。