12.10. 配置文件

12.10.1. /etc 布局

在配置信息中有很多的目录,这些包括:

/etc一般的系统配置信息。这儿的数据是与特定系统相关的。
/etc/defaults系统配置文件的默认版本。
/etc/mail额外的 sendmail(8) 配置信息,其他 MTA 配置文件。
/etc/ppp用于用户级和内核级 ppp 程序的配置。
/etc/namedbnamed(8) 数据的默认位置。通常 named.conf 和区域文件存放在这里。
/usr/local/etc被安装的应用程序配置文件。可以参考每个应用程序的子目录。
/usr/local/etc/rc.d被安装程序的 启动/停止 脚本。
/var/db特定系统自动产生的数据库文件,像 package 数据库,位置数据库等等。

12.10.2. 主机名

12.10.2.1. /etc/resolv.conf

/etc/resolv.conf 指示了 FreeBSD 如何访问域名系统(DNS)。

resolv.conf 中最常见的记录是:

nameserver按顺序要查询的名字服务器的 IP 地址,最多三个。
search 搜索机器名的列表。这通常由本地机器名的域决定。
domain本地域名。

一个典型的 resolv.conf 文件:

search example.com
nameserver 147.11.1.11
nameserver 147.11.100.30

注意:

只能使用一个 searchdomain 选项。

如果您在使用 DHCP,dhclient(8) 经常使用从 DHCP 服务器接受来的信息重写 resolv.conf

12.10.2.2. /etc/hosts

/etc/hosts 是 Internet 早期使用的一个简单文本数据库。 它结合 DNS 和 NIS 提供名字到 IP 地址的映射。 通过局域网连接的机器可以用这个简单的命名方案来替代设置一个 named(8) 服务器。另外,/etc/hosts 也可以提供一个 Internet 名称的本地纪录以减轻需要从外部查询带来的负担。

# $FreeBSD$
#
#
# Host Database
#
# This file should contain the addresses and aliases for local hosts that
# share this file.  Replace 'my.domain' below with the domainname of your
# machine.
#
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.
#
#
::1			localhost localhost.my.domain
127.0.0.1		localhost localhost.my.domain
#
# Imaginary network.
#10.0.0.2		myname.my.domain myname
#10.0.0.3		myfriend.my.domain myfriend
#
# According to RFC 1918, you can use the following IP networks for
# private nets which will never be connected to the Internet:
#
#	10.0.0.0	-   10.255.255.255
#	172.16.0.0	-   172.31.255.255
#	192.168.0.0	-   192.168.255.255
#
# In case you want to be able to connect to the Internet, you need
# real official assigned numbers.  Do not try to invent your own network
# numbers but instead get one from your network provider (if any) or
# from your regional registry (ARIN, APNIC, LACNIC, RIPE NCC, or AfriNIC.)
#

/etc/hosts 用简单的格式:

[Internet address] [official hostname] [alias1] [alias2] ...

例如:

10.0.0.1 myRealHostname.example.com myRealHostname foobar1 foobar2

参考 hosts(5) 以获得更多信息。

12.10.3. 日志文件配置

12.10.3.1. syslog.conf

syslog.confsyslogd(8) 程序的配置文件。 它指出了的 syslog 哪种信息类型被存储在特定的日志文件中。

# $FreeBSD$
#
#       Spaces ARE valid field separators in this file. However,
#       other *nix-like systems still insist on using tabs as field
#       separators. If you are sharing this file between systems, you
#       may want to use only tabs as field separators here.
#       Consult the syslog.conf(5) manual page.
*.err;kern.debug;auth.notice;mail.crit          /dev/console
*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
security.*                                      /var/log/security
mail.info                                       /var/log/maillog
lpr.info                                        /var/log/lpd-errs
cron.*                                          /var/log/cron
*.err                                           root
*.notice;news.err                               root
*.alert                                         root
*.emerg                                         *
# uncomment this to log all writes to /dev/console to /var/log/console.log
#console.info                                   /var/log/console.log
# uncomment this to enable logging of all log messages to /var/log/all.log
#*.*                                            /var/log/all.log
# uncomment this to enable logging to a remote log host named loghost
#*.*                                            @loghost
# uncomment these if you're running inn
# news.crit                                     /var/log/news/news.crit
# news.err                                      /var/log/news/news.err
# news.notice                                   /var/log/news/news.notice
!startslip
*.*                                             /var/log/slip.log
!ppp
*.*                                             /var/log/ppp.log

参考 syslog.conf(5) 手册页以获得更多信息

12.10.3.2. newsyslog.conf

newsyslog.conf 是一个通常用 cron(8) 计划运行的 newsyslog(8) 程序的配置文件。 newsyslog(8) 指出了什么时候日志文件需要打包或者重新整理。 比如 logfile 被移动到 logfile.0logfile.0 被移动到 logfile.1 等等。另外,日志文件可以用 gzip(1) 来压缩,它们是这样的命名格式: logfile.0.gzlogfile.1.gz 等等。

newsyslog.conf 指出了哪个日志文件要被管理,要保留多少和它们什么时候被创建。 日志文件可以在它们达到一定大小或者在特定的日期被重新整理。

# configuration file for newsyslog
# $FreeBSD$
#
# filename          [owner:group]    mode count size when [ZB] [/pid_file] [sig_num]
/var/log/cron                           600  3     100  *     Z
/var/log/amd.log                        644  7     100  *     Z
/var/log/kerberos.log                   644  7     100  *     Z
/var/log/lpd-errs                       644  7     100  *     Z
/var/log/maillog                        644  7     *    @T00  Z
/var/log/sendmail.st                    644  10    *    168   B
/var/log/messages                       644  5     100  *     Z
/var/log/all.log                        600  7     *    @T00  Z
/var/log/slip.log                       600  3     100  *     Z
/var/log/ppp.log                        600  3     100  *     Z
/var/log/security                       600  10    100  *     Z
/var/log/wtmp                           644  3     *    @01T05 B
/var/log/daily.log                      640  7     *    @T00  Z
/var/log/weekly.log                     640  5     1    $W6D0 Z
/var/log/monthly.log                    640  12    *    $M1D0 Z
/var/log/console.log                    640  5     100  *     Z

参考 newsyslog(8) 手册页以获得更多信息。

12.10.4. sysctl.conf

sysctl.confrc.conf 这两个文件的风格很接近。 其中的配置均为 变量=值 这样的形式。 在这个文件中配置的值, 均会在系统进入多用户模式之后进行实际的修改操作。 需要注意的是, 并不是所有的变量都能够在多用户模式下修改。

如果希望关闭对收到致命的信号退出的进程进行记录, 并阻止普通用户看到其他用户的进程, 可以在 sysctl.conf 中进行下列配置:

# 不记录由于致命信号导致的进程退出 (例如信号 11,访问越界)
kern.logsigexit=0

# 阻止用户看到以其他用户 UID 身份执行的进程。
security.bsd.see_other_uids=0

本文档和其它文档可从这里下载: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

如果对于FreeBSD有问题,请先阅读 文档,如不能解决再联系 <[email protected]>.

关于本文档的问题请发信联系 <[email protected]>.