设置 samba-ad-dc
注释
Active Directory 命名
在以下所有示例中,将 EXAMPLE 替换为您的 NetBIOS 域名(大写),将 example.com 替换为您的 DNS 域名,将 HOSTNAME 替换为您的系统主机名(大写),并将 hostname 替换为您的系统主机名。
在选择您的域名之前,请参考 Active Directory 命名 FAQ。
MS-SNTP 签名支持
AD 域时间同步需要 MS-SNTP 签名支持,因此请务必检查您选择部署的 NTP 服务器是否支持它。
Alpine 仓库中可用的一些 NTP 服务器版本(chrony、openntpd、busybox)目前不支持它。这将导致域的时间同步问题,请预先知悉。
支持 MS-SNTP 签名的 NTP 实现
- chrony(版本 >= 3.2) Alpine edge 仓库中的软件包 源代码下载 v3.2 - 源代码提交
- ntp.org "ntpd" 服务器 - 下载 ntpd
- Windows
在 Alpine 3.6.2 上安装 Chrony 3.2 版本
取消注释并固定 /etc/apk/repositories 中的 edge/main 仓库
请注意,以下 URL 无效,仅用于说明目的。请替换为您安装使用的有效仓库 URL。
有关更多详细信息,请参阅 软件包仓库固定。
https://mirror/alpine/v3.6/main @edge https://mirror/alpine/edge/main
更新软件包索引
apk update
使用 @edge 标签升级 chrony
apk add chrony chrony@edge
使用 @edge 标签升级 chrony-doc
apk add chrony-doc chrony-doc@edge
确认已安装的版本来自 edge 仓库
cat /etc/apk/world
chrony@edge chrony-doc@edge
重启 chronyd 以使用新升级的版本
/etc/init.d/chronyd restart
安装
安装软件包
apk add samba-dc krb5
编辑 hosts 文件
您需要修改您的 /etc/hosts 文件,使其看起来类似于这样。
127.0.0.1 localhost.localdomain localhost 10.1.1.10 hostname.example.com hostname
创建 smb.conf
Alpine 软件包中没有提供示例配置文件,因此您需要在 /etc/samba/smb.conf 创建一个。
[global] server role = domain controller workgroup = EXAMPLE realm = example.com netbios name = HOSTNAME passdb backend = samba4 idmap_ldb:use rfc2307 = yes [netlogon] path = /var/lib/samba/sysvol/example.com/scripts read only = No [sysvol] path = /var/lib/samba/sysvol read only = No
配置 Samba 域
使用您的域信息回答问题
samba-tool domain provision --use-rfc2307 --interactive
使用 SAMBA_INTERNAL DNS 选项。当询问转发器 IP 时,选择您的互联网 DNS 服务器。您可以使用您的 ISP 或其他公共服务(如 Google)。
配置 resolv.conf
修改您的 /etc/resolv.conf 以包含您的新域作为搜索域,并将自身指向为第一个名称服务器。
search example.com nameserver 10.1.1.10
配置 Kerberos
您需要将 krb5.conf 替换为指向 samba 生成的那个文件的链接。
ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf
安装新的 init 脚本
截至 2016 年 3 月 31 日和 Alpine 3.3.3,包含的 samba init 脚本不支持将其作为域控制器启动。 像下面这样修改您的 /etc/init.d/samba 脚本。
#!/sbin/openrc-run extra_started_commands="reload" DAEMON=${SVCNAME#samba.} SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1` if [ "$SERVER_ROLE" = "active directory domain controller" ]; then daemon_list="samba" elif [ "$DAEMON" != "samba" ]; then daemon_list=$DAEMON fi depend() { need net after firewall } start_samba() { mkdir -p /var/run/samba start-stop-daemon --start --quiet --exec /usr/sbin/samba -- } stop_samba() { start-stop-daemon --stop --quiet --pidfile /var/run/samba/samba.pid } start_smbd() { start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- \ ${smbd_options:-"-D"} } stop_smbd() { start-stop-daemon --stop --quiet --pidfile /var/run/samba/smbd.pid } start_nmbd() { start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- \ ${nmbd_options:-"-D"} } stop_nmbd() { start-stop-daemon --stop --quiet --pidfile /var/run/samba/nmbd.pid } start_winbindd() { start-stop-daemon --start --quiet --exec /usr/sbin/winbindd -- \ $winbindd_options } stop_winbindd() { start-stop-daemon --stop --quiet --pidfile /var/run/samba/winbindd.pid } start() { for i in $daemon_list; do ebegin "Starting $i" start_$i eend $? done } stop() { for i in $daemon_list; do ebegin "Stopping $i" stop_$i eend $? done } reload() { for i in $daemon_list; do ebegin "Reloading $i" killall -HUP $i eend $? done }
配置 Samba 服务
运行此命令以在启动时启动服务。
rc-update add samba
运行此命令以立即启动服务。
rc-service samba start