Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

FreeBSD 基本服務設定入門

FreeBSD 的系統設定集中在 /etc/rc.conf 與 /etc/defaults/rc.conf,編輯工具則常使用 ee。以下整理最基礎的網路與 SSH 設定。

一、網路設定

登入後先用 ifconfig 確認網卡識別名稱與狀態:

ifconfig

狀態顯示 status: active 才代表可用。接著編輯 /etc/rc.conf:

ifconfig_rl0="inet 192.168.1.103 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
hostname="yourhostname.com.cn"

讓設定生效有三種方式:重開機(reboot)、執行 sh /etc/rc,或直接跑 /etc/netstart。測試:ping 192.168.1.1。

二、設定 DNS 以訪問外網

編輯(或新建)/etc/resolv.conf:

nameserver 192.168.1.1

測試 ping www.baidu.com 有回應即可。

常見故障

  • 網卡顯示 status: no carrier:先用 ping 127.0.0.1 測回環,能通代表網卡沒壞,否則檢查網線與交換設備。
  • 外網不通且出現 cannot resolve ... Host name lookup failure:多半是 resolv.conf 沒寫對。

三、SSH 服務

編輯 /etc/inetd.conf,把 ssh 兩行前面的 # 去掉:

ssh stream tcp  nowait root /usr/sbin/sshd
ssh stream tcp6 nowait root /usr/sbin/sshd

要允許 root 遠端登入,編輯 /etc/ssh/sshd_config(注意是 sshd_config,寫成 ssh_config 會導致認證失敗),在末尾加上:

PermitRootLogin yes
PasswordAuthentication yes
PermitEmptyPasswords no

重啟服務:

/etc/rc.d/sshd restart

之後就能用 PuTTY 等工具從 Windows 連線管理。

若希望 root 不能遠端登入,把 PermitRootLogin 設為 no,改用普通帳號登入後 su 切換;同時確認 PasswordAuthentication yes 與 PermitEmptyPasswords no 的設定。

Copyright © Linux教程網 All Rights Reserved