Rocky 9 安装 FreeIPA 4.13 实战:ipa-server-install 与 DNS/NTP 决策

Rocky Linux 9.3 上 ipa-server 4.13.4 全流程安装实测:AppStream/离线双方案、集成 DNS 与 NTP 决策、Ubuntu 22.04 客户端跨发行版入域,附 7 条真实排障实录。

FreeIPAFreeIPARocky LinuxKerberos2026/10/28

Rocky 9 安装 FreeIPA 4.13 实战:ipa-server-install 与 DNS/NTP 决策

目标:在一台 Rocky Linux 9.3 服务器上从零完成 FreeIPA 4.13.4 服务端安装(含集成 DNS 决策、DS/ADMIN 口令、全栈服务验证),并实测一台 Ubuntu 22.04 客户端真实入域。全流程已在 Rocky Linux 9.3(ipa1.ipa.lab,域 ipa.lab)+ Ubuntu 22.04(client1.ipa.lab)双机实测通过。

一、环境信息

  • 服务端:Rocky Linux 9.3(x86_64),主机名 ipa1.ipa.lab,IP 10.89.71.10
  • 客户端:Ubuntu 22.04(x86_64),主机名 client1.ipa.lab,IP 10.89.71.20
  • FreeIPA:ipa-server-4.13.4-1.el9_8(Rocky 9 AppStream 实装)、389-ds-base-2.8.0-11.el9_8、krb5-server-1.21.1-10.el9_8
  • 客户端包:freeipa-client 4.9.8(Ubuntu 22.04 universe 仓库,与服务端 4.13 跨版本互通实测)
  • 域规划:DNS 域 ipa.lab,Kerberos realm IPA.LAB,NetBIOS 名自动推导
  • 安装决策:--setup-dns 开启集成 DNS(forwarder 223.5.5.5)、--no-ntp(本环境时间由外部统一管理,见三、3 的权衡说明)
  • 管理员:admin / 口令 q1w2e3r4;DS 目录管理器(cn=Directory Manager)口令同 q1w2e3r4

二、前置条件

安装器会逐项强制检查,先在服务器上确认这四项再动手:

  1. 主机名是 FQDN 且解析正确(Kerberos realm 从域名推导,装完改主机名等于重装):
hostnamectl set-hostname ipa1.ipa.lab
hostname -f

回显(实测):

ipa1.ipa.lab
  1. /etc/hosts 中 FQDN 指向非环回 IP。安装器会拒绝 127.0.0.1 映射(本地链路解析如 nss-myhostname 指向 ::1 不影响,files 顺序在前即可):
getent hosts ipa1.ipa.lab

回显(实测):

10.89.71.10	ipa1.ipa.lab ipa1
  1. 时间同步。Kerberos 默认允许 5 分钟时钟偏移,生产机必须开 chronyd。本环境由外部设施统一授时,安装时用 --no-ntp 显式跳过(安装器会在结尾重申提醒,见四、7 回显):

💡 技术拓展:时间同步方案对比——

方案特点适用
chronyIPA 默认,抗断网漂移好,ARM/虚机友好RHEL 系默认选择
ntpd (ntp.org)传统实现,配置面广存量老系统
systemd-timesyncd轻量 SNTP 客户端桌面/无域环境

本文因实验环境已有统一授时,选 --no-ntp 跳过;真实生产服务器建议保留 chrony 由 IPA 管理(不传 --no-ntp,或用 --ntp-pool cn.pool.ntp.org 指定上游)。

  1. 内存 ≥ 4GB(安装器硬性建议,DS+PKI+DNS 同机吃内存;不足 1.2GB 直接拒绝)。极低配环境可加 --skip-mem-check,见九、排障实录 2。

三、版本选型说明

  1. 上游版本:freeipa.org 官网 Releases 当前主推 4.13.4(GitHub tag release-4-13-4,查询日期 2026-10-28)。4.13 相对 4.12 的安装面变化:--dns-forwarder 更名为 --forwarder、新增 DNS-over-TLS 一组参数(--dns-over-tls/--dot-forwarder/--dns-policy)。
  2. 发行版来源:Rocky 9 AppStream 仓库自带 ipa-server 4.13.4-1.el9_8,与上游同步,无需第三方源。查实装版本:
dnf list available ipa-server --showduplicates | tail -3

回显(实测):

ipa-server.x86_64    4.13.4-1.el9_8    appstream
ipa-server.x86_64    4.12.2-1.el9_5    appstream
ipa-server.x86_64    4.12.0-1.el9_5    appstream
  1. 客户端兼容:Ubuntu 22.04 的 freeipa-client 4.9.8 加入 4.13 服务端实测成功(IPA 客户端协议向后兼容,服务端 API 版本 2.257 实测响应)。
  2. 选型结论:生产用「发行版仓库 + 4.13.x 最新小版本」;4.12 及以下不要新装(4.13 修复了 idp-add 前置授权检查等安全问题,见 4.13.4 Release Notes)。

四、在线安装方案(A:AppStream 仓库,推荐)

4.1 方案说明

Rocky 9 自带 AppStream 源直接 dnf install,这是官方推荐路径;再由 ipa-server-install 一键完成 389DS/Kerberos/Dogtag CA/BIND/httpd 的接线。全程约 8~12 分钟(大部分耗在 PKI 证书子系统)。

4.2 安装软件包

dnf install -y freeipa-server freeipa-server-dns

⚠️ freeipa-server-dns 是集成 DNS 的独立子包,必须与 ipa-server 同装,否则 --setup-dns 会因缺 bind-dyndb-ldap 报错。仅做副本不接 DNS 时可省。

回显(实测节选,共 565 个包):

Installing       : bind-dyndb-ldap-11.10-5.el9.x86_64                 502/565
Installing       : ipa-server-4.13.4-1.el9_8.x86_64                   512/565
...

安装完成复核(实测):

rpm -q ipa-server ipa-client 389-ds-base krb5-server
ipa-server-4.13.4-1.el9_8.x86_64
ipa-client-4.13.4-1.el9_8.x86_64
389-ds-base-2.8.0-11.el9_8.x86_64
krb5-server-1.21.1-10.el9_8.x86_64

4.3 --setup-dns 决策

集成 DNS(--setup-dns)不是可选项而是强推荐:客户端发现 IPA 服务器靠 DNS SRV 记录(_ldap._tcp.ipa.lab),没有域 DNS 就得逐台改解析配置,ipa-client-install 的自动发现也会失效。三种 DNS 取舍:

  • --setup-dns --forwarder=<上游DNS>:IPA 自建域内 DNS,非本域查询转发上游。本文实测采用(forwarder 223.5.5.5)。
  • --setup-dns --no-forwarders:只解析本域,封闭内网适用。
  • 不装 DNS:需要外部 DNS 服务器手工维护 SRV 记录,运维成本高,不建议。

区域更新策略实测(装完可查,机器只能更新自己的记录):

ipa dnszone-show ipa.lab --all | grep -i "update policy"

回显(实测):

  BIND update policy: grant IPA.LAB krb5-self * A; grant IPA.LAB krb5-self * AAAA; grant IPA.LAB krb5-self * SSHFP;
  Dynamic update: True

4.4 执行 ipa-server-install

交互模式(不带 -U)会依次询问 domain/realm/DS 口令/ADMIN 口令并要求确认,适合首次部署逐项过目;自动化场景用 -U 无人值守。本文实测命令:

ipa-server-install -U --skip-mem-check \
  --domain=ipa.lab --realm=IPA.LAB \
  --ds-password=q1w2e3r4 --admin-password=q1w2e3r4 \
  --setup-dns --forwarder=223.5.5.5 \
  --no-dnssec-validation --no-ntp

参数逐项说明:

参数作用注意
-U无人值守,全部取默认/显式传参缺省项会报错而不是交互
--skip-mem-check跳过可用内存检测仅低配/受限环境用,见九、2
--domainDNS 域,决定 LDAP 后缀 dc=ipa,dc=lab装完不可改
--realmKerberos realm,通常=域名大写装完不可改
--ds-passwordcn=Directory Manager 口令建议与 admin 口令分开管理
--admin-passwordadmin 用户口令kinit admin 用
--setup-dns安装集成 DNS需 freeipa-server-dns 包
--forwarder上游 DNS,可多次传4.13 前的旧参数名 --dns-forwarder 已废弃
--no-dnssec-validation不校验上游 DNSSEC实验环境简化;生产建议保留校验
--no-ntp跳过 chrony 配置生产建议去掉此参数让 IPA 管 NTP

回显(实测,头部预检与配置摘要):

Checking DNS domain ipa.lab., please wait ...

The log file for this installation can be found in /var/log/ipaserver-install.log
==============================================================================
This program will set up the IPA Server.
Version 4.13.4

This includes:
  * Configure a stand-alone CA (dogtag) for certificate management
  * Create and configure an instance of Directory Server
  * Create and configure a Kerberos Key Distribution Center (KDC)
  * Configure Apache (httpd)
  * Configure DNS (bind)
  * Configure SID generation
  * Configure the KDC to enable PKINIT

Excluded by options:
  * Configure the NTP client (chronyd)

Warning: skipping DNS resolution of host ipa1.ipa.lab
Trust is configured but no NetBIOS domain name found, setting it now.

The IPA Master Server will be configured with:
Hostname:       ipa1.ipa.lab
IP address(es): 10.89.71.10
Domain name:    ipa.lab
Realm name:     IPA.LAB

The CA will be configured with:
Subject DN:   CN=Certificate Authority,O=IPA.LAB
Subject base: O=IPA.LAB
Chaining:     self-signed

BIND DNS server will be configured to serve IPA domain with:
Forwarders:       223.5.5.5
Forward policy:   only
Reverse zone(s):  No reverse zone

随后进入四个配置阶段(实测耗时参考):directory server 约 30 秒 → pki-tomcatd 证书服务器约 3 分钟(最慢,32 个子步骤)→ KDC/httpd/DNS 约 2 分钟 → 客户端组件与 SID 生成约 1 分钟。

4.5 安装完成确认与端口清单

回显(实测,安装成功尾部输出,端口清单是生产放行防火墙的权威依据):

The ipa-server-install command was successful
==============================================================================
Setup complete

Next steps:
	1. You must make sure these network ports are open:
		TCP Ports:
		  * 80, 443: HTTP/HTTPS
		  * 389, 636: LDAP/LDAPS
		  * 88, 464: kerberos
		  * 53: bind
		UDP Ports:
		  * 88, 464: kerberos
		  * 53: bind

	2. You can now obtain a kerberos ticket using the command: 'kinit admin'
	   This ticket will allow you to use the IPA tools (e.g., ipa user-add)
	   and the web user interface.
	3. Kerberos requires time synchronization between clients
	   and servers for correct operation. You should consider enabling chronyd.

Be sure to back up the CA certificates stored in /root/cacert.p12
These files are required to create replicas. The password for these
files is the Directory Manager password

真实服务器开启防火墙(命令+预期结果,本环境防火墙由网络层统一管控未启用 firewalld):

firewall-cmd --permanent --add-service={freeipa-ldap,freeipa-ldaps,dns,ntp,kerberos,kpasswd} && firewall-cmd --reload

预期结果:输出 success 两行;firewall-cmd --list-services 应包含 freeipa-ldap、dns、kerberos 等 6 项。

4.6 全栈服务验证

ipactl status

回显(实测,9 个服务全部 RUNNING 才算安装成功):

Directory Service: RUNNING
krb5kdc Service: RUNNING
kadmin Service: RUNNING
named Service: RUNNING
httpd Service: RUNNING
ipa-custodia Service: RUNNING
pki-tomcatd Service: RUNNING
ipa-otpd Service: RUNNING
ipa-dnskeysyncd Service: RUNNING

管理票据与 API 连通(实测):

kinit admin
ipa ping
Password for admin@IPA.LAB:
--------------------------------------------
IPA server version 4.13.4. API version 2.257
--------------------------------------------

端口监听复核(实测,ss -tlnp 节选):

*:389
*:636
*:8443
0.0.0.0:443
0.0.0.0:88
10.89.71.10:53

五、离线包安装方案(B:断网内网)

5.1 方案说明

内网服务器无外网时,在一台联网同版本机器上 dnf download 全量依赖包,拷贝到目标机本地安装。IPA 依赖约 565 包、总体积 400MB+,务必用 --resolve 拉全。

5.2 下载与安装步骤

联网机(同 Rocky 9.3,命令+预期结果):

mkdir -p /opt/ipa-offline && dnf download --resolve --destdir=/opt/ipa-offline freeipa-server freeipa-server-dns

预期结果:末行输出下载统计,ls /opt/ipa-offline | wc -l 应 ≥ 500(同版本仓库解析出的全量依赖)。

目标机(拷入目录后本地整目录安装,命令+预期结果):

dnf install -y /opt/ipa-offline/*.rpm

预期结果:与在线安装一致的事务摘要(Installing N/N 完成后 Complete!),rpm -q ipa-server 返回 4.13.4-1.el9_8;随后 4.4 起步骤完全相同。

5.3 与在线方案差异提示

离线包不包含安装后 dnf update 的增量修复;安全升级(如 4.13.4 的 idp-add 修复)需要重新制作离线包。离线机上 ipa-healthcheck、oddjob-mkhomedir 等辅助包也要提前一并 download,否则客户端侧功能缺件。

六、方案对比与选择建议

维度A:在线 AppStreamB:离线包
网络要求服务器可达镜像源仅需介质拷贝
版本新鲜度随仓库实时冻结在打包时刻
依赖完整性dnf 自动解析--resolve 需一次拉全
适用规模单台~批量(配 Ansible)批量同构内网
推荐度默认选择安全管控严格的环境

选择建议:能连内网镜像源选 A;完全隔离环境用 B 并同步规划升级通道。

七、客户端入域实测(Ubuntu 22.04 跨发行版)

7.1 客户端 DNS 指向 IPA

客户端发现依赖域 DNS,先把解析指向 IPA 服务器并验证(实测):

printf 'nameserver 10.89.71.10\nsearch ipa.lab\n' > /etc/resolv.conf
getent hosts ipa1.ipa.lab
10.89.71.10     ipa1.ipa.lab

服务端区域里此刻已能看到客户端 A 记录(安装时自动注册,实测):

ipa dnsrecord-find ipa.lab client1
  Record name: client1
  A record: 10.89.71.20

7.2 安装客户端包

apt-get update && apt-get install -y freeipa-client oddjob-mkhomedir

回显(实测节选,共 212 个包):

Get:113 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnss3 amd64 2:3.98-0ubuntu0.22.04.5 [1346 kB]
...

7.3 执行 ipa-client-install

ipa-client-install --domain=ipa.lab --server=ipa1.ipa.lab \
  --principal=admin -w q1w2e3r4 --mkhomedir -U --no-ntp

参数说明:--server 显式指定 IPA 主机(省去 SRV 自动发现歧义)、--principal/-w 用 admin 完成主机注册、--mkhomedir 首次登录自动建 home、--no-ntp 与服务端一致跳过时间组件。

回显(实测,尾部关键行):

Successfully retrieved CA cert
    Subject:     CN=Certificate Authority,O=IPA.LAB
    Issuer:      CN=Certificate Authority,O=IPA.LAB
    Valid From:  2026-10-28 06:24:59
    Valid Until: 2046-10-28 06:24:59

Enrolled in IPA realm IPA.LAB
Created /etc/ipa/default.conf
Configured /etc/sssd/sssd.conf
Configured /etc/krb5.conf for IPA realm IPA.LAB
Systemwide CA database updated.
Hostname (client1.ipa.lab) does not have A/AAAA record.
Missing reverse record(s) for address(es): 10.89.71.20.
SSSD enabled
Configured /etc/openldap/ldap.conf
/etc/ssh/ssh_config not found, skipping configuration
/etc/ssh/sshd_config not found, skipping configuration
Configuring ipa.lab as NIS domain.
Client configuration complete.
The ipa-client-install command was successful

⚠️ 中间两行告警是排障入口:A 记录实际已注册成功(7.1 已验证 dnsrecord-find 可见),告警指向的是反向记录(PTR)缺失——安装时未创建反向区域,IPA 无法登记 10.89.71.20 的 PTR。处置见九、排障实录 3。

7.4 入域效果验证

域账号即时可见(实测,UID 863200000 段为 IPA 身份空间特征):

id admin
uid=863200000(admin) gid=863200000(admins) groups=863200000(admins)
getent passwd dev01
dev01:*:863200003:863200003:Dev One:/home/dev01:/bin/sh

SSSD 在线状态与 HBAC 判定(实测;Ubuntu 需补装 sssd-tools):

apt-get install -y sssd-tools
sssctl domain-status ipa.lab
Online status: Online

Active servers:
IPA: ipa1.ipa.lab

八、配置说明

安装器落盘的关键文件与改动(全部为实测路径):

文件内容改动要点
/etc/ipa/default.confIPA 客户端/服务端全局配置domain/realm/server
/etc/sssd/sssd.confSSSD 域接入配置ipa 域段、缓存参数
/etc/krb5.confKerberos 配置realm→KDC 映射
/etc/openldap/ldap.conf系统 LDAP 客户端 CA指向 /etc/ipa/ca.crt
/etc/ipa/ca.crtIPA 根 CA 证书客户端信任链根基
/etc/krb5.keytab主机 keytab(客户端)host/client1.ipa.lab@IPA.LAB
/var/log/ipaserver-install.log服务端安装全量日志排障第一入口
/root/cacert.p12CA 证书备份(PKCS12)建副本必需,DS 口令保护

服务端服务管理统一走 ipactl(stop/start/restart/status),它会按依赖顺序编排 9 个服务;也可 systemctl status ipa 查看聚合单元。日常配置操作(用户/策略/DNS)不再改本地文件,统一走 ipa 命令族,详见 《FreeIPA 4.13 配置参数详解》与《FreeIPA 4.13 常用 CLI 命令与工具详解》。

九、常见问题(排障实录)

9.1 ipa-server-install: error: no such option: --dns-forwarder

现象:按旧版文档写 --dns-forwarder=223.5.5.5 直接报错退出(实测回显):

ipa-server-install: error: no such option: --dns-forwarder
EXIT:2

定位:ipa-server-install --help 确认 4.13 参数族已更名(实测节选):

--forwarder=FORWARDERS
                    Add a DNS forwarder. This option can be used multiple
--auto-forwarders   Use DNS forwarders configured in /etc/resolv.conf

解决:改用 --forwarder=223.5.5.5。经验:4.12→4.13 升级脚本前先 --help 过一遍 DNS 参数。

9.2 Unable to determine the amount of available RAM

现象:安装器启动即失败(实测回显):

Unable to determine the amount of available RAM
The ipa-server-install command failed. See /var/log/ipaserver-install.log for more information
EXIT:1

定位:/var/log/ipaserver-install.log 指向 installutils.py 的 check_available_memory:环境被识别为受限隔离环境时,IPA 走 cgroup 文件判读,要求存在 cgroup v1 的 memory/memory.limit_in_bytes 或 cgroup v2 的 memory.max;而 cgroup v2 根层级天然没有 memory.max 文件(限制只存在于子层级),于是两条路径都失败直接抛错。真实物理机/常规虚拟机走 psutil 读 /proc/meminfo,不会触发此问题。

解决:内存确实充足时加官方参数 --skip-mem-check 重跑(实测一次通过):

ipa-server-install -U --skip-mem-check --domain=ipa.lab ...

安装器源码注释确认了该回退逻辑:「Use --skip-mem-check to suppress this check.」(/usr/lib/python3.9/site-packages/ipaserver/install/installutils.py)

9.3 客户端告警 Hostname does not have A/AAAA record / Missing reverse record

现象:ipa-client-install 成功但尾部报 does not have A/AAAA record 与 Missing reverse record(s) for address(es): 10.89.71.20(实测回显见 7.3)。

定位:正向记录其实已注册(ipa dnsrecord-find ipa.lab client1 可见 A 10.89.71.20),真实缺口是反向区域:安装服务端时未建 reverse zone(摘要里 Reverse zone(s): No reverse zone),PTR 无处落。

解决(二选一):服务端补建反向区域并登记 PTR(命令+预期结果):

ipa dnszone-add 71.89.10.in-addr.arpa
ipa dnsrecord-add 71.89.10.in-addr.arpa 20 --ptr-rec=client1.ipa.lab.

预期结果:两条命令各返回 Zone name / Record name 确认块;客户端重跑 ipa-client-install 告警消失。或卸载重装客户端时改用 --enable-dns-updates 让客户端用 GSS-TSIG 自行维护记录(需反向区域先存在)。

9.4 host-add 报 DNS reverse zone not managed

现象(实测):

ipa: WARNING: The host was added but the DNS update failed with: DNS reverse zone 10.in-addr.arpa. for IP address 10.89.71.30 is not managed by this server

原因与解决:ipa host-add web01.ipa.lab --ip-address=10.89.71.30 会尝试同步登记正/反向记录,反向区域未托管时回退为仅登记正向。host 条目创建成功(后续 ipa host-find 可见),需要 PTR 时按 9.3 先 dnszone-add 反向区域。此告警不阻断入域流程。

9.5 nsupdate GSS-TSIG 动态更新被拒(REFUSED)

现象:admin 票据下 nsupdate -g 给别的机器加 A 记录,实测回显:

update failed: REFUSED
nsupdate exit: 2

定位:区域更新策略默认 grant IPA.LAB krb5-self * A; ...(实测查询见 4.3)。krb5-self 的语义是机器主体只能更新自己主机名的记录——admin@IPA.LAB 给 app1.ipa.lab 加记录不满足 self 匹配,BIND 按策略拒绝。这是设计行为而非故障。

解决:客户端机器用自己的 keytab 主体更新自身记录(实测成功):

kinit -k 'host/client1.ipa.lab@IPA.LAB' -t /etc/krb5.keytab
nsupdate -g <<'EOF'
server 10.89.71.10
update delete client1.ipa.lab. A
update add client1.ipa.lab. 86400 A 10.89.71.20
send
EOF
nsupdate exit: 0
dig +short @10.89.71.10 client1.ipa.lab A
10.89.71.20

确需授权管理员批量维护记录时,用 ipa dnszone-mod ipa.lab --update-policy='...' 调整策略,或直接走 ipa dnsrecord-add(经 API 有权限控制)。

9.6 kinit 首登改密脚本交互失败

现象:printf "旧\n新\n新" | kinit dev01 卡在 Cannot read password while getting initial credentials(实测)。kinit 的改密提示走 tty,普通管道喂不进。

解决:交互终端人工完成;自动化场景用 pty 驱动脚本(本文实测用的 Python pty 方案)或改走 ldappasswd -Y GSSAPI -s <新口令>(管理员重置路径)。注意两者密码策略执行点不同,见下条。

9.7 密码策略在管理员重置路径不拦截

现象(实测):developers 组策略 minlength=10(ipa pwpolicy-add developers --priority=1 --minlength=10 --maxlife=90 --history=5),组员 dev02 用 GSSAPI ldappasswd 被管理员设置 8 位口令成功、无报错。

定位:IPA 口令质量检查的强制点在用户自改路径(kpasswd/kinit 首登改密,走 KDC 策略);管理员重置路径(ldappasswd/ldap 管理绑定)不执行组策略质量检查。

解决:验证策略用用户自改路径实测——kpasswd 提交 8 位口令被拒(实测回显):

Password change rejected: Password is too short
Password not changed.

提交 10 位合规口令成功(实测回显):

Enter new password:
Enter it again:
Password changed.

十、卸载与清理

服务端卸载(实测命令+预期结果):

ipa-server-install --uninstall -U

预期结果:逐项输出 Removing IPA client、各服务 Stopping ...,末行 Uninstallation complete。随后清包:

dnf remove -y freeipa-server freeipa-server-dns
rm -rf /var/lib/ipa /etc/ipa /root/cacert.p12

客户端卸载(实测命令,回显末行 Unenrolling client 与 Client uninstall complete):

ipa-client-install --uninstall -U
apt-get remove -y freeipa-client sssd-tools && rm -rf /etc/ipa /var/lib/sss

服务端侧同步清理客户端主机条目(实测):

ipa host-del client1.ipa.lab

预期结果:无输出即成功(ipa host-find 不再返回该主机);DNS 记录按需 ipa dnsrecord-del。

十一、参考链接